mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
042a9d2b2c
* Reorganize plugins per agreed structure (#271) Split the dotnet plugin into domain-specific plugins per discussion in #271: - dotnet: narrowed to common everyday C#/.NET coding tasks - dotnet-diag: perf investigations, debugging, incident analysis - dotnet-data: data access and Entity Framework - dotnet-aspnet, dotnet-wpf, dotnet-winforms, dotnet-maui: scaffolded empty to convey intent for future framework-specific skills Moved skills, tests, and CODEOWNERS entries accordingly. No file content was changed; all skill/test moves are pure renames. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Improve dotnet-diag and dotnet-winforms descriptions - dotnet-diag: add '.NET' qualifier to clarify scope - dotnet-winforms: use official 'Windows Forms (WinForms)' name Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add .NET qualifier to dotnet-data description Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove empty plugins; list them in CONTRIBUTING.md as future options Remove the four empty placeholder plugins (dotnet-aspnet, dotnet-wpf, dotnet-winforms, dotnet-maui) that had only plugin.json and no skills. Add a 'Plugin organization' section to CONTRIBUTING.md that describes the domain-specific plugin groupings introduced in this PR and lists the four removed plugin names as reserved candidates for future contributions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Create dotnet-upgrade plugin with migration/upgrade skills Move migrate-nullable-references, thread-abort-migration, and dotnet-aot-compat from dotnet to the new dotnet-upgrade plugin. Update CODEOWNERS paths (same owners), CONTRIBUTING.md plugin table, and fix the thread-abort-migration SKILL.md link in CONTRIBUTING.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
689 lines
40 KiB
C#
689 lines
40 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
// <auto-generated/>
|
|
|
|
#nullable disable
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Azure.Core;
|
|
using Azure.Core.Pipeline;
|
|
using Azure.ResourceManager.ManagementGroups.Models;
|
|
using Azure.ResourceManager.Resources;
|
|
|
|
namespace Azure.ResourceManager.ManagementGroups
|
|
{
|
|
/// <summary>
|
|
/// A class representing a collection of <see cref="ManagementGroupResource"/> and their operations.
|
|
/// Each <see cref="ManagementGroupResource"/> in the collection will belong to the same instance of <see cref="TenantResource"/>.
|
|
/// To get a <see cref="ManagementGroupCollection"/> instance call the GetManagementGroups method from an instance of <see cref="TenantResource"/>.
|
|
/// </summary>
|
|
public partial class ManagementGroupCollection : ArmCollection, IEnumerable<ManagementGroupResource>, IAsyncEnumerable<ManagementGroupResource>
|
|
{
|
|
private readonly ClientDiagnostics _managementGroupClientDiagnostics;
|
|
private readonly ManagementGroupsRestOperations _managementGroupRestClient;
|
|
private readonly ClientDiagnostics _entitiesClientDiagnostics;
|
|
private readonly EntitiesRestOperations _entitiesRestClient;
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="ManagementGroupCollection"/> class for mocking. </summary>
|
|
protected ManagementGroupCollection()
|
|
{
|
|
}
|
|
|
|
/// <summary> Initializes a new instance of the <see cref="ManagementGroupCollection"/> class. </summary>
|
|
/// <param name="client"> The client parameters to use in these operations. </param>
|
|
/// <param name="id"> The identifier of the parent resource that is the target of operations. </param>
|
|
internal ManagementGroupCollection(ArmClient client, ResourceIdentifier id) : base(client, id)
|
|
{
|
|
_managementGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ManagementGroups", ManagementGroupResource.ResourceType.Namespace, Diagnostics);
|
|
TryGetApiVersion(ManagementGroupResource.ResourceType, out string managementGroupApiVersion);
|
|
_managementGroupRestClient = new ManagementGroupsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managementGroupApiVersion);
|
|
_entitiesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ManagementGroups", ProviderConstants.DefaultProviderNamespace, Diagnostics);
|
|
_entitiesRestClient = new EntitiesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint);
|
|
#if DEBUG
|
|
ValidateResourceId(Id);
|
|
#endif
|
|
}
|
|
|
|
internal static void ValidateResourceId(ResourceIdentifier id)
|
|
{
|
|
if (id.ResourceType != TenantResource.ResourceType)
|
|
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TenantResource.ResourceType), nameof(id));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create or update a management group.
|
|
/// If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_CreateOrUpdate</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></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="groupId"> Management Group ID. </param>
|
|
/// <param name="content"> Management group creation parameters. </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> or <paramref name="content"/> is null. </exception>
|
|
public virtual async Task<ArmOperation<ManagementGroupResource>> CreateOrUpdateAsync(WaitUntil waitUntil, string groupId, ManagementGroupCreateOrUpdateContent content, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
Argument.AssertNotNull(content, nameof(content));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.CreateOrUpdate");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = await _managementGroupRestClient.CreateOrUpdateAsync(groupId, content, cacheControl, cancellationToken).ConfigureAwait(false);
|
|
var operation = new ManagementGroupsArmOperation<ManagementGroupResource>(new ManagementGroupOperationSource(Client), _managementGroupClientDiagnostics, Pipeline, _managementGroupRestClient.CreateCreateOrUpdateRequest(groupId, content, cacheControl).Request, response, OperationFinalStateVia.AzureAsyncOperation);
|
|
if (waitUntil == WaitUntil.Completed)
|
|
await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
|
|
return operation;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create or update a management group.
|
|
/// If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_CreateOrUpdate</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></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="groupId"> Management Group ID. </param>
|
|
/// <param name="content"> Management group creation parameters. </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> or <paramref name="content"/> is null. </exception>
|
|
public virtual ArmOperation<ManagementGroupResource> CreateOrUpdate(WaitUntil waitUntil, string groupId, ManagementGroupCreateOrUpdateContent content, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
Argument.AssertNotNull(content, nameof(content));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.CreateOrUpdate");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = _managementGroupRestClient.CreateOrUpdate(groupId, content, cacheControl, cancellationToken);
|
|
var operation = new ManagementGroupsArmOperation<ManagementGroupResource>(new ManagementGroupOperationSource(Client), _managementGroupClientDiagnostics, Pipeline, _managementGroupRestClient.CreateCreateOrUpdateRequest(groupId, content, cacheControl).Request, response, OperationFinalStateVia.AzureAsyncOperation);
|
|
if (waitUntil == WaitUntil.Completed)
|
|
operation.WaitForCompletion(cancellationToken);
|
|
return operation;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the details of the management group.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_Get</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="groupId"> Management Group ID. </param>
|
|
/// <param name="expand"> The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. </param>
|
|
/// <param name="recurse"> The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. </param>
|
|
/// <param name="filter"> A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription'). </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> is null. </exception>
|
|
public virtual async Task<Response<ManagementGroupResource>> GetAsync(string groupId, ManagementGroupExpandType? expand = null, bool? recurse = null, string filter = null, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.Get");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = await _managementGroupRestClient.GetAsync(groupId, expand, recurse, filter, cacheControl, cancellationToken).ConfigureAwait(false);
|
|
if (response.Value == null)
|
|
throw new RequestFailedException(response.GetRawResponse());
|
|
return Response.FromValue(new ManagementGroupResource(Client, response.Value), response.GetRawResponse());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the details of the management group.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_Get</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="groupId"> Management Group ID. </param>
|
|
/// <param name="expand"> The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. </param>
|
|
/// <param name="recurse"> The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. </param>
|
|
/// <param name="filter"> A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription'). </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> is null. </exception>
|
|
public virtual Response<ManagementGroupResource> Get(string groupId, ManagementGroupExpandType? expand = null, bool? recurse = null, string filter = null, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.Get");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = _managementGroupRestClient.Get(groupId, expand, recurse, filter, cacheControl, cancellationToken);
|
|
if (response.Value == null)
|
|
throw new RequestFailedException(response.GetRawResponse());
|
|
return Response.FromValue(new ManagementGroupResource(Client, response.Value), response.GetRawResponse());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// List management groups for the authenticated user.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_List</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="skipToken">
|
|
/// Page continuation token is only used if a previous operation returned a partial result.
|
|
/// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls.
|
|
///
|
|
/// </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <returns> An async collection of <see cref="ManagementGroupResource"/> that may take multiple service requests to iterate over. </returns>
|
|
public virtual AsyncPageable<ManagementGroupResource> GetAllAsync(string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default)
|
|
{
|
|
HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateListRequest(cacheControl, skipToken);
|
|
HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateListNextPageRequest(nextLink, cacheControl, skipToken);
|
|
return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagementGroupResource(Client, ManagementGroupData.DeserializeManagementGroupData(e)), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupCollection.GetAll", "value", "@nextLink", cancellationToken);
|
|
}
|
|
|
|
/// <summary>
|
|
/// List management groups for the authenticated user.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_List</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="skipToken">
|
|
/// Page continuation token is only used if a previous operation returned a partial result.
|
|
/// If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that specifies a starting point to use for subsequent calls.
|
|
///
|
|
/// </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <returns> A collection of <see cref="ManagementGroupResource"/> that may take multiple service requests to iterate over. </returns>
|
|
public virtual Pageable<ManagementGroupResource> GetAll(string cacheControl = null, string skipToken = null, CancellationToken cancellationToken = default)
|
|
{
|
|
HttpMessage FirstPageRequest(int? pageSizeHint) => _managementGroupRestClient.CreateListRequest(cacheControl, skipToken);
|
|
HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _managementGroupRestClient.CreateListNextPageRequest(nextLink, cacheControl, skipToken);
|
|
return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagementGroupResource(Client, ManagementGroupData.DeserializeManagementGroupData(e)), _managementGroupClientDiagnostics, Pipeline, "ManagementGroupCollection.GetAll", "value", "@nextLink", cancellationToken);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if the specified management group name is valid and unique
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/checkNameAvailability</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_CheckNameAvailability</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="content"> Management group name availability check parameters. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
|
|
public virtual async Task<Response<ManagementGroupNameAvailabilityResult>> CheckNameAvailabilityAsync(ManagementGroupNameAvailabilityContent content, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNull(content, nameof(content));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.CheckNameAvailability");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = await _managementGroupRestClient.CheckNameAvailabilityAsync(content, cancellationToken).ConfigureAwait(false);
|
|
return response;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if the specified management group name is valid and unique
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/checkNameAvailability</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_CheckNameAvailability</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="content"> Management group name availability check parameters. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception>
|
|
public virtual Response<ManagementGroupNameAvailabilityResult> CheckNameAvailability(ManagementGroupNameAvailabilityContent content, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNull(content, nameof(content));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.CheckNameAvailability");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = _managementGroupRestClient.CheckNameAvailability(content, cancellationToken);
|
|
return response;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/getEntities</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>Entities_List</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="options"> A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <returns> An async collection of <see cref="EntityData"/> that may take multiple service requests to iterate over. </returns>
|
|
public virtual AsyncPageable<EntityData> GetEntitiesAsync(ManagementGroupCollectionGetEntitiesOptions options, CancellationToken cancellationToken = default)
|
|
{
|
|
options ??= new ManagementGroupCollectionGetEntitiesOptions();
|
|
|
|
HttpMessage FirstPageRequest(int? pageSizeHint) => _entitiesRestClient.CreateListRequest(options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl);
|
|
HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _entitiesRestClient.CreateListNextPageRequest(nextLink, options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl);
|
|
return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => EntityData.DeserializeEntityData(e), _entitiesClientDiagnostics, Pipeline, "ManagementGroupCollection.GetEntities", "value", "nextLink", cancellationToken);
|
|
}
|
|
|
|
/// <summary>
|
|
/// List all entities (Management Groups, Subscriptions, etc.) for the authenticated user.
|
|
///
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/getEntities</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>Entities_List</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="options"> A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <returns> A collection of <see cref="EntityData"/> that may take multiple service requests to iterate over. </returns>
|
|
public virtual Pageable<EntityData> GetEntities(ManagementGroupCollectionGetEntitiesOptions options, CancellationToken cancellationToken = default)
|
|
{
|
|
options ??= new ManagementGroupCollectionGetEntitiesOptions();
|
|
|
|
HttpMessage FirstPageRequest(int? pageSizeHint) => _entitiesRestClient.CreateListRequest(options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl);
|
|
HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _entitiesRestClient.CreateListNextPageRequest(nextLink, options.SkipToken, options.Skip, options.Top, options.Select, options.Search, options.Filter, options.View, options.GroupName, options.CacheControl);
|
|
return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => EntityData.DeserializeEntityData(e), _entitiesClientDiagnostics, Pipeline, "ManagementGroupCollection.GetEntities", "value", "nextLink", cancellationToken);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks to see if the resource exists in azure.
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_Get</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="groupId"> Management Group ID. </param>
|
|
/// <param name="expand"> The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. </param>
|
|
/// <param name="recurse"> The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. </param>
|
|
/// <param name="filter"> A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription'). </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> is null. </exception>
|
|
public virtual async Task<Response<bool>> ExistsAsync(string groupId, ManagementGroupExpandType? expand = null, bool? recurse = null, string filter = null, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.Exists");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = await _managementGroupRestClient.GetAsync(groupId, expand, recurse, filter, cacheControl, cancellationToken: cancellationToken).ConfigureAwait(false);
|
|
return Response.FromValue(response.Value != null, response.GetRawResponse());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks to see if the resource exists in azure.
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_Get</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="groupId"> Management Group ID. </param>
|
|
/// <param name="expand"> The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. </param>
|
|
/// <param name="recurse"> The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. </param>
|
|
/// <param name="filter"> A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription'). </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> is null. </exception>
|
|
public virtual Response<bool> Exists(string groupId, ManagementGroupExpandType? expand = null, bool? recurse = null, string filter = null, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.Exists");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = _managementGroupRestClient.Get(groupId, expand, recurse, filter, cacheControl, cancellationToken: cancellationToken);
|
|
return Response.FromValue(response.Value != null, response.GetRawResponse());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to get details for this resource from the service.
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_Get</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="groupId"> Management Group ID. </param>
|
|
/// <param name="expand"> The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. </param>
|
|
/// <param name="recurse"> The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. </param>
|
|
/// <param name="filter"> A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription'). </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> is null. </exception>
|
|
public virtual async Task<NullableResponse<ManagementGroupResource>> GetIfExistsAsync(string groupId, ManagementGroupExpandType? expand = null, bool? recurse = null, string filter = null, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.GetIfExists");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = await _managementGroupRestClient.GetAsync(groupId, expand, recurse, filter, cacheControl, cancellationToken: cancellationToken).ConfigureAwait(false);
|
|
if (response.Value == null)
|
|
return new NoValueResponse<ManagementGroupResource>(response.GetRawResponse());
|
|
return Response.FromValue(new ManagementGroupResource(Client, response.Value), response.GetRawResponse());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to get details for this resource from the service.
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// <term>Request Path</term>
|
|
/// <description>/providers/Microsoft.Management/managementGroups/{groupId}</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Operation Id</term>
|
|
/// <description>ManagementGroups_Get</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Default Api Version</term>
|
|
/// <description>2021-04-01</description>
|
|
/// </item>
|
|
/// <item>
|
|
/// <term>Resource</term>
|
|
/// <description><see cref="ManagementGroupResource"/></description>
|
|
/// </item>
|
|
/// </list>
|
|
/// </summary>
|
|
/// <param name="groupId"> Management Group ID. </param>
|
|
/// <param name="expand"> The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. </param>
|
|
/// <param name="recurse"> The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. </param>
|
|
/// <param name="filter"> A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription'). </param>
|
|
/// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. </param>
|
|
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
|
/// <exception cref="ArgumentException"> <paramref name="groupId"/> is an empty string, and was expected to be non-empty. </exception>
|
|
/// <exception cref="ArgumentNullException"> <paramref name="groupId"/> is null. </exception>
|
|
public virtual NullableResponse<ManagementGroupResource> GetIfExists(string groupId, ManagementGroupExpandType? expand = null, bool? recurse = null, string filter = null, string cacheControl = null, CancellationToken cancellationToken = default)
|
|
{
|
|
Argument.AssertNotNullOrEmpty(groupId, nameof(groupId));
|
|
|
|
using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroupCollection.GetIfExists");
|
|
scope.Start();
|
|
try
|
|
{
|
|
var response = _managementGroupRestClient.Get(groupId, expand, recurse, filter, cacheControl, cancellationToken: cancellationToken);
|
|
if (response.Value == null)
|
|
return new NoValueResponse<ManagementGroupResource>(response.GetRawResponse());
|
|
return Response.FromValue(new ManagementGroupResource(Client, response.Value), response.GetRawResponse());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
scope.Failed(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
IEnumerator<ManagementGroupResource> IEnumerable<ManagementGroupResource>.GetEnumerator()
|
|
{
|
|
return GetAll().GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetAll().GetEnumerator();
|
|
}
|
|
|
|
IAsyncEnumerator<ManagementGroupResource> IAsyncEnumerable<ManagementGroupResource>.GetAsyncEnumerator(CancellationToken cancellationToken)
|
|
{
|
|
return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken);
|
|
}
|
|
}
|
|
}
|