diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs index 051854a8427c..8ec2c2d41568 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs @@ -8,42 +8,44 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmSiteManagerModelFactory { - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Site as ARM Resource. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. /// The resource-specific properties for this resource. /// A new instance for mocking. - public static EdgeSiteData EdgeSiteData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, EdgeSiteProperties properties = null) + public static EdgeSiteData EdgeSiteData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, EdgeSiteProperties properties = default) { return new EdgeSiteData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// Site properties. /// displayName of Site resource. /// Description of Site resource. /// Physical address of the site. /// Key-value pairs for labeling the site resource. /// Provisioning state of last operation. /// A new instance for mocking. - public static EdgeSiteProperties EdgeSiteProperties(string displayName = null, string description = null, EdgeSiteAddressProperties siteAddress = null, IDictionary labels = null, EdgeSiteProvisioningState? provisioningState = null) + public static EdgeSiteProperties EdgeSiteProperties(string displayName = default, string description = default, EdgeSiteAddressProperties siteAddress = default, IDictionary labels = default, EdgeSiteProvisioningState? provisioningState = default) { - labels ??= new Dictionary(); + labels ??= new ChangeTrackingDictionary(); return new EdgeSiteProperties( displayName, @@ -51,7 +53,20 @@ public static EdgeSiteProperties EdgeSiteProperties(string displayName = null, s siteAddress, labels, provisioningState, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); + } + + /// The updatable properties of the Site. + /// displayName of Site resource. + /// Description of Site resource. + /// Physical address of the site. + /// Key-value pairs for labeling the site resource. + /// A new instance for mocking. + public static EdgeSitePatchProperties EdgeSitePatchProperties(string displayName = default, string description = default, EdgeSiteAddressProperties siteAddress = default, IDictionary labels = default) + { + labels ??= new ChangeTrackingDictionary(); + + return new EdgeSitePatchProperties(displayName, description, siteAddress, labels, additionalBinaryDataProperties: null); } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..985315fb2ddc --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly SitesByServiceGroup _client; + private readonly string _servicegroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SitesByServiceGroup client used to send requests. + /// The name of the service group. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT(SitesByServiceGroup client, string servicegroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _servicegroupName = servicegroupName; + _context = context; + } + + /// Gets the pages of SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + SiteListResult result = SiteListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByServiceGroupRequest(nextLink, _servicegroupName, _context) : _client.CreateGetByServiceGroupRequest(_servicegroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.GetEdgeSites"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesByServiceGroupGetByServiceGroupCollectionResultOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesByServiceGroupGetByServiceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..553c42ce42c6 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesByServiceGroupGetByServiceGroupCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesByServiceGroupGetByServiceGroupCollectionResultOfT : Pageable + { + private readonly SitesByServiceGroup _client; + private readonly string _servicegroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of SitesByServiceGroupGetByServiceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SitesByServiceGroup client used to send requests. + /// The name of the service group. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SitesByServiceGroupGetByServiceGroupCollectionResultOfT(SitesByServiceGroup client, string servicegroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _servicegroupName = servicegroupName; + _context = context; + } + + /// Gets the pages of SitesByServiceGroupGetByServiceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SitesByServiceGroupGetByServiceGroupCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + SiteListResult result = SiteListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByServiceGroupRequest(nextLink, _servicegroupName, _context) : _client.CreateGetByServiceGroupRequest(_servicegroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.GetEdgeSites"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesBySubscriptionGetAllAsyncCollectionResultOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesBySubscriptionGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..3a2b791d760a --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesBySubscriptionGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesBySubscriptionGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly SitesBySubscription _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of SitesBySubscriptionGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SitesBySubscription client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SitesBySubscriptionGetAllAsyncCollectionResultOfT(SitesBySubscription client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of SitesBySubscriptionGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SitesBySubscriptionGetAllAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + SiteListResult result = SiteListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _context) : _client.CreateGetAllRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.GetEdgeSites"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesBySubscriptionGetAllCollectionResultOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesBySubscriptionGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..315140dd8a5b --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesBySubscriptionGetAllCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesBySubscriptionGetAllCollectionResultOfT : Pageable + { + private readonly SitesBySubscription _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of SitesBySubscriptionGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SitesBySubscription client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SitesBySubscriptionGetAllCollectionResultOfT(SitesBySubscription client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of SitesBySubscriptionGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SitesBySubscriptionGetAllCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + SiteListResult result = SiteListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _context) : _client.CreateGetAllRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.GetEdgeSites"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..10db5164cd0f --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesGetByResourceGroupAsyncCollectionResultOfT.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Sites _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of SitesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Sites client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SitesGetByResourceGroupAsyncCollectionResultOfT(Sites client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of SitesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SitesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + SiteListResult result = SiteListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("EdgeSiteCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesGetByResourceGroupCollectionResultOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..3c2e1113ec0a --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/CollectionResults/SitesGetByResourceGroupCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Sites _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of SitesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Sites client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SitesGetByResourceGroupCollectionResultOfT(Sites client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of SitesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SitesGetByResourceGroupCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + SiteListResult result = SiteListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("EdgeSiteCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteCollection.cs new file mode 100644 index 000000000000..0cad79273fa4 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteCollection.cs @@ -0,0 +1,588 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.SiteManager +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetEdgeSites method from an instance of . + /// + public partial class EdgeSiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _sitesClientDiagnostics; + private readonly Sites _sitesRestClient; + private readonly ClientDiagnostics _sitesBySubscriptionClientDiagnostics; + private readonly SitesBySubscription _sitesBySubscriptionRestClient; + private readonly ClientDiagnostics _sitesByServiceGroupClientDiagnostics; + private readonly SitesByServiceGroup _sitesByServiceGroupRestClient; + + /// Initializes a new instance of EdgeSiteCollection for mocking. + protected EdgeSiteCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal EdgeSiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(EdgeSiteResource.ResourceType, out string edgeSiteApiVersion); + _sitesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", EdgeSiteResource.ResourceType.Namespace, Diagnostics); + _sitesRestClient = new Sites(_sitesClientDiagnostics, Pipeline, Endpoint, edgeSiteApiVersion ?? "2025-06-01"); + _sitesBySubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", EdgeSiteResource.ResourceType.Namespace, Diagnostics); + _sitesBySubscriptionRestClient = new SitesBySubscription(_sitesBySubscriptionClientDiagnostics, Pipeline, Endpoint, edgeSiteApiVersion ?? "2025-06-01"); + _sitesByServiceGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", EdgeSiteResource.ResourceType.Namespace, Diagnostics); + _sitesByServiceGroupRestClient = new SitesByServiceGroup(_sitesByServiceGroupClientDiagnostics, Pipeline, Endpoint, edgeSiteApiVersion ?? "2025-06-01"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } + } + + /// + /// Create a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Site. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, EdgeSiteData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + SiteManagerArmOperation operation = new SiteManagerArmOperation( + new EdgeSiteOperationSource(Client), + _sitesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the Site. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, EdgeSiteData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + SiteManagerArmOperation operation = new SiteManagerArmOperation( + new EdgeSiteOperationSource(Client), + _sitesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the Site. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the Site. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites. + /// + /// + /// Operation Id. + /// Sites_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new SitesGetByResourceGroupAsyncCollectionResultOfT(_sitesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new EdgeSiteResource(Client, data)); + } + + /// + /// List a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites. + /// + /// + /// Operation Id. + /// Sites_ListByResourceGroup. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new SitesGetByResourceGroupCollectionResultOfT(_sitesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new EdgeSiteResource(Client, data)); + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the Site. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EdgeSiteData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the Site. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EdgeSiteData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the Site. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EdgeSiteData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the Site. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, siteName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((EdgeSiteData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + /// The cancellation token to use. + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.Serialization.cs index f5fa730277ed..cc21e660035a 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.Serialization.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.SiteManager.Models; namespace Azure.ResourceManager.SiteManager { - public partial class EdgeSiteData : IUtf8JsonSerializable, IJsonModel + /// Site as ARM Resource. + public partial class EdgeSiteData : ResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSiteData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -45,87 +46,101 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - EdgeSiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EdgeSiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EdgeSiteData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSiteData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEdgeSiteData(document.RootElement, options); } - internal static EdgeSiteData DeserializeEdgeSiteData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EdgeSiteData DeserializeEdgeSiteData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - EdgeSiteProperties properties = default; ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + EdgeSiteProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = EdgeSiteProperties.DeserializeEdgeSiteProperties(property.Value, options); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("name"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("type"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("systemData"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSiteManagerContext.Default); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerSiteManagerContext.Default); + properties = EdgeSiteProperties.DeserializeEdgeSiteProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new EdgeSiteData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -135,15 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EdgeSiteData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeEdgeSiteData(document.RootElement, options); } default: @@ -151,6 +171,26 @@ EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(EdgeSiteData edgeSiteData) + { + if (edgeSiteData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(edgeSiteData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static EdgeSiteData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEdgeSiteData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.cs index 5de4183138ab..373b015a85ca 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteData.cs @@ -13,43 +13,11 @@ namespace Azure.ResourceManager.SiteManager { - /// - /// A class representing the EdgeSite data model. - /// Site as ARM Resource - /// + /// Site as ARM Resource. public partial class EdgeSiteData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public EdgeSiteData() @@ -57,16 +25,16 @@ public EdgeSiteData() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal EdgeSiteData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, EdgeSiteProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal EdgeSiteData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, EdgeSiteProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource-specific properties for this resource. diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteResource.Serialization.cs new file mode 100644 index 000000000000..968868eb441a --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteResource.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.SiteManager +{ + /// + public partial class EdgeSiteResource : IJsonModel + { + private static IJsonModel s_dataDeserializationInstance; + + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new EdgeSiteData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + /// The reader for deserializing the model. + /// The client options for reading and writing models. + EdgeSiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerSiteManagerContext.Default); + + /// The binary data to be processed. + /// The client options for reading and writing models. + EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSiteManagerContext.Default); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteResource.cs new file mode 100644 index 000000000000..6f031db10e23 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/EdgeSiteResource.cs @@ -0,0 +1,1035 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + /// + /// A class representing a EdgeSite along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetEdgeSites method. + /// + public partial class EdgeSiteResource : ArmResource + { + private readonly ClientDiagnostics _sitesClientDiagnostics; + private readonly Sites _sitesRestClient; + private readonly ClientDiagnostics _sitesBySubscriptionClientDiagnostics; + private readonly SitesBySubscription _sitesBySubscriptionRestClient; + private readonly ClientDiagnostics _sitesByServiceGroupClientDiagnostics; + private readonly SitesByServiceGroup _sitesByServiceGroupRestClient; + private readonly EdgeSiteData _data; + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Edge/sites"; + + /// Initializes a new instance of EdgeSiteResource for mocking. + protected EdgeSiteResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal EdgeSiteResource(ArmClient client, EdgeSiteData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal EdgeSiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(ResourceType, out string edgeSiteApiVersion); + _sitesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); + _sitesRestClient = new Sites(_sitesClientDiagnostics, Pipeline, Endpoint, edgeSiteApiVersion ?? "2025-06-01"); + _sitesBySubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); + _sitesBySubscriptionRestClient = new SitesBySubscription(_sitesBySubscriptionClientDiagnostics, Pipeline, Endpoint, edgeSiteApiVersion ?? "2025-06-01"); + _sitesByServiceGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); + _sitesByServiceGroupRestClient = new SitesByServiceGroup(_sitesByServiceGroupClientDiagnostics, Pipeline, Endpoint, edgeSiteApiVersion ?? "2025-06-01"); + ValidateResourceId(id); + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + public virtual EdgeSiteData Data + { + get + { + if (!HasData) + { + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } + return _data; + } + } + + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The siteName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string siteName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Update. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(EdgeSitePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, EdgeSitePatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Update. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual Response Update(EdgeSitePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, EdgeSitePatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Delete. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SiteManagerArmOperation operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// Sites_Delete. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesClientDiagnostics.CreateScope("EdgeSiteResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SiteManagerArmOperation operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesBySubscription_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesBySubscriptionClientDiagnostics.CreateScope("EdgeSiteResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesBySubscriptionRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesBySubscription_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesBySubscriptionClientDiagnostics.CreateScope("EdgeSiteResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesBySubscriptionRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesBySubscription_Update. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(EdgeSitePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _sitesBySubscriptionClientDiagnostics.CreateScope("EdgeSiteResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesBySubscriptionRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.Name, EdgeSitePatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesBySubscription_Update. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual Response Update(EdgeSitePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _sitesBySubscriptionClientDiagnostics.CreateScope("EdgeSiteResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesBySubscriptionRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.Name, EdgeSitePatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesBySubscription_Delete. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesBySubscriptionClientDiagnostics.CreateScope("EdgeSiteResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesBySubscriptionRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SiteManagerArmOperation operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesBySubscription_Delete. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _sitesBySubscriptionClientDiagnostics.CreateScope("EdgeSiteResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesBySubscriptionRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SiteManagerArmOperation operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using DiagnosticScope scope = _sitesByServiceGroupClientDiagnostics.CreateScope("EdgeSiteResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesByServiceGroupRestClient.CreateGetRequest(servicegroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_Get. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using DiagnosticScope scope = _sitesByServiceGroupClientDiagnostics.CreateScope("EdgeSiteResource.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesByServiceGroupRestClient.CreateGetRequest(servicegroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// update Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_Update. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The name of the service group. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateAsync(string servicegroupName, EdgeSitePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _sitesByServiceGroupClientDiagnostics.CreateScope("EdgeSiteResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesByServiceGroupRestClient.CreateUpdateRequest(servicegroupName, Id.Name, EdgeSitePatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// update Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_Update. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// The name of the service group. + /// Resource create parameters. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Update(string servicegroupName, EdgeSitePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _sitesByServiceGroupClientDiagnostics.CreateScope("EdgeSiteResource.Update"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesByServiceGroupRestClient.CreateUpdateRequest(servicegroupName, Id.Name, EdgeSitePatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(EdgeSiteData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new EdgeSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// delete Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_Delete. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task DeleteAsync(WaitUntil waitUntil, string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using DiagnosticScope scope = _sitesByServiceGroupClientDiagnostics.CreateScope("EdgeSiteResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesByServiceGroupRestClient.CreateDeleteRequest(servicegroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SiteManagerArmOperation operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// delete Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_Delete. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// Resource. + /// . + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation Delete(WaitUntil waitUntil, string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using DiagnosticScope scope = _sitesByServiceGroupClientDiagnostics.CreateScope("EdgeSiteResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sitesByServiceGroupRestClient.CreateDeleteRequest(servicegroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + SiteManagerArmOperation operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs index e59a3330f8df..93d6028618ef 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs @@ -5,148 +5,34 @@ #nullable disable -using System; -using System.Threading; -using System.Threading.Tasks; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableSiteManagerArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableSiteManagerArmClient for mocking. protected MockableSiteManagerArmClient() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableSiteManagerArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableSiteManagerArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of ServiceGroupEdgeSiteResources in the ArmClient. - /// The scope that the resource will apply against. - /// An object representing collection of ServiceGroupEdgeSiteResources and their operations over a ServiceGroupEdgeSiteResource. - public virtual ServiceGroupEdgeSiteCollection GetServiceGroupEdgeSites(ResourceIdentifier scope) - { - if (!scope.ResourceType.Equals("Microsoft.Management/serviceGroups")) - { - throw new ArgumentException(string.Format("Invalid resource type {0}, expected Microsoft.Management/serviceGroups", scope.ResourceType)); - } - return new ServiceGroupEdgeSiteCollection(Client, scope); - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. - /// The name of the Site. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetServiceGroupEdgeSiteAsync(ResourceIdentifier scope, string siteName, CancellationToken cancellationToken = default) - { - return await GetServiceGroupEdgeSites(scope).GetAsync(siteName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The scope that the resource will apply against. - /// The name of the Site. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetServiceGroupEdgeSite(ResourceIdentifier scope, string siteName, CancellationToken cancellationToken = default) - { - return GetServiceGroupEdgeSites(scope).Get(siteName, cancellationToken); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual ResourceGroupEdgeSiteResource GetResourceGroupEdgeSiteResource(ResourceIdentifier id) - { - ResourceGroupEdgeSiteResource.ValidateResourceId(id); - return new ResourceGroupEdgeSiteResource(Client, id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// The resource ID of the resource to get. - /// Returns a object. - public virtual SubscriptionEdgeSiteResource GetSubscriptionEdgeSiteResource(ResourceIdentifier id) - { - SubscriptionEdgeSiteResource.ValidateResourceId(id); - return new SubscriptionEdgeSiteResource(Client, id); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. - /// Returns a object. - public virtual ServiceGroupEdgeSiteResource GetServiceGroupEdgeSiteResource(ResourceIdentifier id) + /// Returns a object. + public virtual EdgeSiteResource GetEdgeSiteResource(ResourceIdentifier id) { - ServiceGroupEdgeSiteResource.ValidateResourceId(id); - return new ServiceGroupEdgeSiteResource(Client, id); + EdgeSiteResource.ValidateResourceId(id); + return new EdgeSiteResource(Client, id); } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs index 97fc2f01139d..83247f0c5a04 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs @@ -8,56 +8,50 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableSiteManagerResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableSiteManagerResourceGroupResource for mocking. protected MockableSiteManagerResourceGroupResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableSiteManagerResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) + /// Gets a collection of EdgeSites in the . + /// An object representing collection of EdgeSites and their operations over a EdgeSiteResource. + public virtual EdgeSiteCollection GetEdgeSites() { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of ResourceGroupEdgeSiteResources in the ResourceGroupResource. - /// An object representing collection of ResourceGroupEdgeSiteResources and their operations over a ResourceGroupEdgeSiteResource. - public virtual ResourceGroupEdgeSiteCollection GetResourceGroupEdgeSites() - { - return GetCachedClient(client => new ResourceGroupEdgeSiteCollection(client, Id)); + return GetCachedClient(client => new EdgeSiteCollection(client, Id)); } /// /// Get a Site /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. /// /// - /// Default Api Version - /// 2025-06-01 + /// Operation Id. + /// Sites_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-06-01. /// /// /// @@ -66,29 +60,27 @@ public virtual ResourceGroupEdgeSiteCollection GetResourceGroupEdgeSites() /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual async Task> GetResourceGroupEdgeSiteAsync(string siteName, CancellationToken cancellationToken = default) + public virtual async Task> GetEdgeSiteAsync(string siteName, CancellationToken cancellationToken = default) { - return await GetResourceGroupEdgeSites().GetAsync(siteName, cancellationToken).ConfigureAwait(false); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + return await GetEdgeSites().GetAsync(siteName, cancellationToken).ConfigureAwait(false); } /// /// Get a Site /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}. /// /// - /// Default Api Version - /// 2025-06-01 + /// Operation Id. + /// Sites_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-06-01. /// /// /// @@ -97,9 +89,11 @@ public virtual async Task> GetResourceGr /// is null. /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] - public virtual Response GetResourceGroupEdgeSite(string siteName, CancellationToken cancellationToken = default) + public virtual Response GetEdgeSite(string siteName, CancellationToken cancellationToken = default) { - return GetResourceGroupEdgeSites().Get(siteName, cancellationToken); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + return GetEdgeSites().Get(siteName, cancellationToken); } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs index 6ad1d47bfa8e..2f7c9a870d48 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs @@ -7,99 +7,91 @@ using System; using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableSiteManagerSubscriptionResource : ArmResource { - /// Initializes a new instance of the class for mocking. + private ClientDiagnostics _sitesBySubscriptionClientDiagnostics; + private SitesBySubscription _sitesBySubscriptionRestClient; + + /// Initializes a new instance of MockableSiteManagerSubscriptionResource for mocking. protected MockableSiteManagerSubscriptionResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableSiteManagerSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private ClientDiagnostics SitesBySubscriptionClientDiagnostics => _sitesBySubscriptionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SiteManager.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - /// Gets a collection of SubscriptionEdgeSiteResources in the SubscriptionResource. - /// An object representing collection of SubscriptionEdgeSiteResources and their operations over a SubscriptionEdgeSiteResource. - public virtual SubscriptionEdgeSiteCollection GetSubscriptionEdgeSites() - { - return GetCachedClient(client => new SubscriptionEdgeSiteCollection(client, Id)); - } + private SitesBySubscription SitesBySubscriptionRestClient => _sitesBySubscriptionRestClient ??= new SitesBySubscription(SitesBySubscriptionClientDiagnostics, Pipeline, Endpoint, "2025-06-01"); /// - /// Get a Site + /// List Site resources by subscription ID /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites. /// /// - /// Operation Id - /// Site_Get + /// Operation Id. + /// SitesBySubscription_List. /// /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-06-01. /// /// /// - /// The name of the Site. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetSubscriptionEdgeSiteAsync(string siteName, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEdgeSitesAsync(CancellationToken cancellationToken = default) { - return await GetSubscriptionEdgeSites().GetAsync(siteName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new SitesBySubscriptionGetAllAsyncCollectionResultOfT(SitesBySubscriptionRestClient, Guid.Parse(Id.SubscriptionId), context), data => new EdgeSiteResource(Client, data)); } /// - /// Get a Site + /// List Site resources by subscription ID /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites. /// /// - /// Default Api Version - /// 2025-06-01 + /// Operation Id. + /// SitesBySubscription_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-06-01. /// /// /// - /// The name of the Site. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetSubscriptionEdgeSite(string siteName, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEdgeSites(CancellationToken cancellationToken = default) { - return GetSubscriptionEdgeSites().Get(siteName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new SitesBySubscriptionGetAllCollectionResultOfT(SitesBySubscriptionRestClient, Guid.Parse(Id.SubscriptionId), context), data => new EdgeSiteResource(Client, data)); } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerTenantResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerTenantResource.cs new file mode 100644 index 000000000000..c09d3d99b03b --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerTenantResource.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager; + +namespace Azure.ResourceManager.SiteManager.Mocking +{ + /// A class to add extension methods to . + public partial class MockableSiteManagerTenantResource : ArmResource + { + private ClientDiagnostics _sitesByServiceGroupClientDiagnostics; + private SitesByServiceGroup _sitesByServiceGroupRestClient; + + /// Initializes a new instance of MockableSiteManagerTenantResource for mocking. + protected MockableSiteManagerTenantResource() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableSiteManagerTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics SitesByServiceGroupClientDiagnostics => _sitesByServiceGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SiteManager.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); + + private SitesByServiceGroup SitesByServiceGroupRestClient => _sitesByServiceGroupRestClient ??= new SitesByServiceGroup(SitesByServiceGroupClientDiagnostics, Pipeline, Endpoint, "2025-06-01"); + + /// + /// list Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_ListByServiceGroup. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetEdgeSitesAsync(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new SitesByServiceGroupGetByServiceGroupAsyncCollectionResultOfT(SitesByServiceGroupRestClient, servicegroupName, context), data => new EdgeSiteResource(Client, data)); + } + + /// + /// list Site at SG scope + /// + /// + /// Request Path. + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites. + /// + /// + /// Operation Id. + /// SitesByServiceGroup_ListByServiceGroup. + /// + /// + /// Default Api Version. + /// 2025-06-01. + /// + /// + /// + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetEdgeSites(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new SitesByServiceGroupGetByServiceGroupCollectionResultOfT(SitesByServiceGroupRestClient, servicegroupName, context), data => new EdgeSiteResource(Client, data)); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs index 9eed5159978e..e8ce94de1eb5 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs @@ -8,7 +8,9 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; using Azure.ResourceManager.SiteManager.Mocking; @@ -17,358 +19,175 @@ namespace Azure.ResourceManager.SiteManager /// A class to add extension methods to Azure.ResourceManager.SiteManager. public static partial class SiteManagerExtensions { + /// private static MockableSiteManagerArmClient GetMockableSiteManagerArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableSiteManagerArmClient(client0)); + return client.GetCachedClient(client0 => new MockableSiteManagerArmClient(client0, ResourceIdentifier.Root)); } - private static MockableSiteManagerResourceGroupResource GetMockableSiteManagerResourceGroupResource(ArmResource resource) + /// + private static MockableSiteManagerResourceGroupResource GetMockableSiteManagerResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableSiteManagerResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableSiteManagerResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableSiteManagerSubscriptionResource GetMockableSiteManagerSubscriptionResource(ArmResource resource) + /// + private static MockableSiteManagerSubscriptionResource GetMockableSiteManagerSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableSiteManagerSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableSiteManagerSubscriptionResource(client, subscriptionResource.Id)); } - /// - /// Gets a collection of ServiceGroupEdgeSiteResources in the ArmClient. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. Expected resource type includes the following: Microsoft.Management/serviceGroups. - /// is null. - /// An object representing collection of ServiceGroupEdgeSiteResources and their operations over a ServiceGroupEdgeSiteResource. - public static ServiceGroupEdgeSiteCollection GetServiceGroupEdgeSites(this ArmClient client, ResourceIdentifier scope) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableSiteManagerArmClient(client).GetServiceGroupEdgeSites(scope); - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. Expected resource type includes the following: Microsoft.Management/serviceGroups. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static async Task> GetServiceGroupEdgeSiteAsync(this ArmClient client, ResourceIdentifier scope, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(client, nameof(client)); - - return await GetMockableSiteManagerArmClient(client).GetServiceGroupEdgeSiteAsync(scope, siteName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. Expected resource type includes the following: Microsoft.Management/serviceGroups. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static Response GetServiceGroupEdgeSite(this ArmClient client, ResourceIdentifier scope, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableSiteManagerArmClient(client).GetServiceGroupEdgeSite(scope, siteName, cancellationToken); - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// is null. - /// Returns a object. - public static ResourceGroupEdgeSiteResource GetResourceGroupEdgeSiteResource(this ArmClient client, ResourceIdentifier id) + /// + private static MockableSiteManagerTenantResource GetMockableSiteManagerTenantResource(TenantResource tenantResource) { - Argument.AssertNotNull(client, nameof(client)); - - return GetMockableSiteManagerArmClient(client).GetResourceGroupEdgeSiteResource(id); + return tenantResource.GetCachedClient(client => new MockableSiteManagerTenantResource(client, tenantResource.Id)); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. - /// Returns a object. - public static SubscriptionEdgeSiteResource GetSubscriptionEdgeSiteResource(this ArmClient client, ResourceIdentifier id) + /// Returns a object. + public static EdgeSiteResource GetEdgeSiteResource(this ArmClient client, ResourceIdentifier id) { Argument.AssertNotNull(client, nameof(client)); - return GetMockableSiteManagerArmClient(client).GetSubscriptionEdgeSiteResource(id); + return GetMockableSiteManagerArmClient(client).GetEdgeSiteResource(id); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets a collection of EdgeSites in the /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// is null. - /// Returns a object. - public static ServiceGroupEdgeSiteResource GetServiceGroupEdgeSiteResource(this ArmClient client, ResourceIdentifier id) + /// The the method will execute against. + /// is null. + /// An object representing collection of EdgeSites and their operations over a EdgeSiteResource. + public static EdgeSiteCollection GetEdgeSites(this ResourceGroupResource resourceGroupResource) { - Argument.AssertNotNull(client, nameof(client)); + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); - return GetMockableSiteManagerArmClient(client).GetServiceGroupEdgeSiteResource(id); + return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetEdgeSites(); } /// - /// Gets a collection of ResourceGroupEdgeSiteResources in the ResourceGroupResource. + /// Get a Site /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. + /// The name of the Site. + /// The cancellation token to use. /// is null. - /// An object representing collection of ResourceGroupEdgeSiteResources and their operations over a ResourceGroupEdgeSiteResource. - public static ResourceGroupEdgeSiteCollection GetResourceGroupEdgeSites(this ResourceGroupResource resourceGroupResource) + [ForwardsClientCalls] + public static async Task> GetEdgeSiteAsync(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); - return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetResourceGroupEdgeSites(); + return await GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetEdgeSiteAsync(siteName, cancellationToken).ConfigureAwait(false); } /// /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The name of the Site. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] - public static async Task> GetResourceGroupEdgeSiteAsync(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) + public static Response GetEdgeSite(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); - return await GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetResourceGroupEdgeSiteAsync(siteName, cancellationToken).ConfigureAwait(false); + return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetEdgeSite(siteName, cancellationToken); } /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// + /// List Site resources by subscription ID /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The name of the Site. + /// The the method will execute against. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static Response GetResourceGroupEdgeSite(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetEdgeSitesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetResourceGroupEdgeSite(siteName, cancellationToken); + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetEdgeSitesAsync(cancellationToken); } /// - /// Gets a collection of SubscriptionEdgeSiteResources in the SubscriptionResource. + /// List Site resources by subscription ID /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. + /// The cancellation token to use. /// is null. - /// An object representing collection of SubscriptionEdgeSiteResources and their operations over a SubscriptionEdgeSiteResource. - public static SubscriptionEdgeSiteCollection GetSubscriptionEdgeSites(this SubscriptionResource subscriptionResource) + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetEdgeSites(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSubscriptionEdgeSites(); + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetEdgeSites(cancellationToken); } /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// + /// list Site at SG scope /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The name of the Site. + /// The the method will execute against. + /// The name of the service group. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static async Task> GetSubscriptionEdgeSiteAsync(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetEdgeSitesAsync(this TenantResource tenantResource, string servicegroupName, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - return await GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSubscriptionEdgeSiteAsync(siteName, cancellationToken).ConfigureAwait(false); + return GetMockableSiteManagerTenantResource(tenantResource).GetEdgeSitesAsync(servicegroupName, cancellationToken); } /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// + /// list Site at SG scope /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The name of the Site. + /// The the method will execute against. + /// The name of the service group. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public static Response GetSubscriptionEdgeSite(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetEdgeSites(this TenantResource tenantResource, string servicegroupName, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSubscriptionEdgeSite(siteName, cancellationToken); + return GetMockableSiteManagerTenantResource(tenantResource).GetEdgeSites(servicegroupName, cancellationToken); } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs index a33cae7b9b4a..17963b14d1dd 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.SiteManager { - internal static class Argument + internal static partial class Argument { + /// The value. + /// The name. public static void AssertNotNull(T value, string name) { if (value is null) @@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name) } } + /// The value. + /// The name. public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(IEnumerable value, string name) { if (value is null) @@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(string value, string name) { if (value is null) @@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name) throw new ArgumentException("Value cannot be an empty string.", name); } } - - public static void AssertNotNullOrWhiteSpace(string value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); - } - } - - public static void AssertNotDefault(ref T value, string name) - where T : struct, IEquatable - { - if (value.Equals(default)) - { - throw new ArgumentException("Value cannot be empty.", name); - } - } - - public static void AssertInRange(T value, T minimum, T maximum, string name) - where T : notnull, IComparable - { - if (minimum.CompareTo(value) > 0) - { - throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); - } - if (maximum.CompareTo(value) < 0) - { - throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); - } - } - - public static void AssertEnumDefined(Type enumType, object value, string name) - { - if (!Enum.IsDefined(enumType, value)) - { - throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); - } - } - - public static T CheckNotNull(T value, string name) - where T : class - { - AssertNotNull(value, name); - return value; - } - - public static string CheckNotNullOrEmpty(string value, string name) - { - AssertNotNullOrEmpty(value, name); - return value; - } - - public static void AssertNull(T value, string name, string message = null) - { - if (value != null) - { - throw new ArgumentException(message ?? "Value must be null.", name); - } - } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..ac70ae40df18 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs index d1195c913a7f..05ba92deaba9 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.SiteManager { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; @@ -19,6 +20,7 @@ public ChangeTrackingDictionary() { } + /// The inner dictionary. public ChangeTrackingDictionary(IDictionary dictionary) { if (dictionary == null) @@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary) _innerDictionary = new Dictionary(dictionary); } + /// The inner dictionary. public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) { if (dictionary == null) @@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerDictionary == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + /// Gets the Keys. public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + /// Gets the Values. public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + /// Gets or sets the value associated with the specified key. public TValue this[TKey key] { get @@ -67,8 +76,10 @@ public TValue this[TKey key] } } + /// Gets the Keys. IEnumerable IReadOnlyDictionary.Keys => Keys; + /// Gets the Values. IEnumerable IReadOnlyDictionary.Values => Values; public IEnumerator> GetEnumerator() @@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(KeyValuePair item) { EnsureDictionary().Add(item); @@ -99,6 +111,7 @@ public void Clear() EnsureDictionary().Clear(); } + /// The item to search for. public bool Contains(KeyValuePair item) { if (IsUndefined) @@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item) return EnsureDictionary().Contains(item); } + /// The array to copy. + /// The index. public void CopyTo(KeyValuePair[] array, int index) { if (IsUndefined) @@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index) EnsureDictionary().CopyTo(array, index); } + /// The item to remove. public bool Remove(KeyValuePair item) { if (IsUndefined) @@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item) return EnsureDictionary().Remove(item); } + /// The key. + /// The value to add. public void Add(TKey key, TValue value) { EnsureDictionary().Add(key, value); } + /// The key to search for. public bool ContainsKey(TKey key) { if (IsUndefined) @@ -140,6 +159,7 @@ public bool ContainsKey(TKey key) return EnsureDictionary().ContainsKey(key); } + /// The key. public bool Remove(TKey key) { if (IsUndefined) @@ -149,6 +169,8 @@ public bool Remove(TKey key) return EnsureDictionary().Remove(key); } + /// The key to search for. + /// The value. public bool TryGetValue(TKey key, out TValue value) { if (IsUndefined) diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs index d7c37dce15ea..46e80e68c1f7 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.SiteManager { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; @@ -20,6 +20,7 @@ public ChangeTrackingList() { } + /// The inner list. public ChangeTrackingList(IList innerList) { if (innerList != null) @@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList) } } + /// The inner list. public ChangeTrackingList(IReadOnlyList innerList) { if (innerList != null) @@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerList == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureList().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + /// Gets or sets the value associated with the specified key. public T this[int index] { get @@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(T item) { EnsureList().Add(item); @@ -95,6 +102,7 @@ public void Clear() EnsureList().Clear(); } + /// The item. public bool Contains(T item) { if (IsUndefined) @@ -104,6 +112,8 @@ public bool Contains(T item) return EnsureList().Contains(item); } + /// The array to copy to. + /// The array index. public void CopyTo(T[] array, int arrayIndex) { if (IsUndefined) @@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex) EnsureList().CopyTo(array, arrayIndex); } + /// The item. public bool Remove(T item) { if (IsUndefined) @@ -122,6 +133,7 @@ public bool Remove(T item) return EnsureList().Remove(item); } + /// The item. public int IndexOf(T item) { if (IsUndefined) @@ -131,11 +143,14 @@ public int IndexOf(T item) return EnsureList().IndexOf(item); } + /// The inner list. + /// The item. public void Insert(int index, T item) { EnsureList().Insert(index, item); } + /// The inner list. public void RemoveAt(int index) { if (IsUndefined) diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..3b04d8b280b0 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.SiteManager +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..2533ebf99637 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.SiteManager +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..06584bbae07b --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.SiteManager +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..057b824d2ec3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.SiteManager +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..854c23271e62 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.SiteManager +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ErrorResult.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..59e7a920ce13 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs index ce0d722494ae..470fd0e1cc1d 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs @@ -11,18 +11,16 @@ using System.Diagnostics; using System.Globalization; using System.Text.Json; -using System.Xml; -using Azure.Core; namespace Azure.ResourceManager.SiteManager { - internal static class ModelSerializationExtensions + internal static partial class ModelSerializationExtensions { - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); - internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; public static object GetObject(this JsonElement element) { @@ -48,14 +46,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var jsonProperty in element.EnumerateObject()) { dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); } return dictionary; case JsonValueKind.Array: - var list = new List(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -93,7 +91,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -107,14 +105,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) { - throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); } public static string GetRequiredString(this JsonElement element) { - var value = element.GetString(); + string value = element.GetString(); if (value == null) { throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); @@ -181,9 +179,6 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, Mode case IJsonModel jsonModel: jsonModel.Write(writer, options ?? WireOptions); break; - case IUtf8JsonSerializable serializable: - serializable.Write(writer); - break; case byte[] bytes: writer.WriteBase64StringValue(bytes); break; @@ -259,151 +254,5 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo { writer.WriteObjectValue(value, options); } - - internal static bool IsSentinelValue(BinaryData value) - { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; - ReadOnlySpan valueSpan = value.ToMemory().Span; - return sentinelSpan.SequenceEqual(valueSpan); - } - - internal static class TypeFormatters - { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; - - public static string ToString(bool value) => value ? "true" : "false"; - - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; - - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(byte[] value, string format) => format switch - { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; - int size = checked(numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) - { - char ch = output[i]; - if (ch == '+') - { - output[i] = '-'; - } - else - { - if (ch == '/') - { - output[i] = '_'; - } - else - { - if (ch == '=') - { - break; - } - } - } - } - - return new string(output, 0, i); - } - - public static byte[] FromBase64UrlString(string value) - { - int paddingCharsToAdd = (value.Length % 4) switch - { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) - { - char ch = value[i]; - if (ch == '-') - { - output[i] = '+'; - } - else - { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } - } - } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); - } - - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch - { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; - - public static string ConvertToString(object value, string format = null) => value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; - } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs index eeaa7c102d82..45e0c90c8d79 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.SiteManager { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -28,7 +28,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -38,14 +38,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/PageableWrapper.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..831bb25d73b3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..7cf4cbf73e23 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/RequestContextExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..a37610e61507 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.SiteManager +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/SerializationFormat.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..d00e157e41c2 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.SiteManager +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/TypeFormatters.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..64424a538d38 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.SiteManager +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs index 5c17e9380373..508aaedc5853 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.SiteManager { - internal class Utf8JsonRequestContent : RequestContent + internal partial class Utf8JsonRequestContent : RequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; @@ -25,20 +25,26 @@ public Utf8JsonRequestContent() JsonWriter = new Utf8JsonWriter(_stream); } + /// Gets the JsonWriter. public Utf8JsonWriter JsonWriter { get; } + /// The stream containing the data to be written. + /// The cancellation token to use. public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) { await JsonWriter.FlushAsync().ConfigureAwait(false); await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); } + /// The stream containing the data to be written. + /// The cancellation token to use. public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) { JsonWriter.Flush(); _content.WriteTo(stream, cancellationToken); } + /// public override bool TryComputeLength(out long length) { length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/EdgeSiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/EdgeSiteOperationSource.cs new file mode 100644 index 000000000000..047e20f30b82 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/EdgeSiteOperationSource.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.SiteManager +{ + /// + internal partial class EdgeSiteOperationSource : IOperationSource + { + private readonly ArmClient _client; + + /// + /// + internal EdgeSiteOperationSource(ArmClient client) + { + _client = client; + } + + /// The response from the service. + /// The cancellation token to use. + /// + EdgeSiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + EdgeSiteData data = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new EdgeSiteResource(_client, data); + } + + /// The response from the service. + /// The cancellation token to use. + /// + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + EdgeSiteData data = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new EdgeSiteResource(_client, data); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupEdgeSiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupEdgeSiteOperationSource.cs deleted file mode 100644 index 2eb6c5b9382d..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupEdgeSiteOperationSource.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.ClientModel.Primitives; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; - -namespace Azure.ResourceManager.SiteManager -{ - internal class ResourceGroupEdgeSiteOperationSource : IOperationSource - { - private readonly ArmClient _client; - - internal ResourceGroupEdgeSiteOperationSource(ArmClient client) - { - _client = client; - } - - ResourceGroupEdgeSiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - return new ResourceGroupEdgeSiteResource(_client, data); - } - - async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - return await Task.FromResult(new ResourceGroupEdgeSiteResource(_client, data)).ConfigureAwait(false); - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ServiceGroupEdgeSiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ServiceGroupEdgeSiteOperationSource.cs deleted file mode 100644 index fec437be7073..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ServiceGroupEdgeSiteOperationSource.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.ClientModel.Primitives; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; - -namespace Azure.ResourceManager.SiteManager -{ - internal class ServiceGroupEdgeSiteOperationSource : IOperationSource - { - private readonly ArmClient _client; - - internal ServiceGroupEdgeSiteOperationSource(ArmClient client) - { - _client = client; - } - - ServiceGroupEdgeSiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - return new ServiceGroupEdgeSiteResource(_client, data); - } - - async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - return await Task.FromResult(new ServiceGroupEdgeSiteResource(_client, data)).ConfigureAwait(false); - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs index 5d2722d72105..1eea74cd390d 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.SiteManager { -#pragma warning disable SA1649 // File name should match first type name - internal class SiteManagerArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class SiteManagerArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected SiteManagerArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal SiteManagerArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal SiteManagerArmOperation(Response response, RehydrationToken? rehydratio _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal SiteManagerArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,48 +58,49 @@ internal SiteManagerArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeli _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "SiteManagerArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "SiteManagerArmOperation", + null, + new SequentialDelayStrategy()); } + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. private string GetOperationId(RehydrationToken? rehydrationToken) { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); + return rehydrationToken?.Id; } - /// - public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// + /// public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - /// - public override bool HasCompleted => _operation.HasCompleted; - - /// + /// public override Response GetRawResponse() => _operation.RawResponse; - /// + /// public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - /// + /// public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - /// + /// public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); - /// + /// public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); - /// + /// public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); - /// + /// public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs index 43c91ab66f90..424fb96a1d41 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.SiteManager { -#pragma warning disable SA1649 // File name should match first type name - internal class SiteManagerArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class SiteManagerArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected SiteManagerArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal SiteManagerArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal SiteManagerArmOperation(Response response, RehydrationToken? rehydra _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal SiteManagerArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,54 +59,55 @@ internal SiteManagerArmOperation(IOperationSource source, ClientDiagnostics c _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "SiteManagerArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "SiteManagerArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); - } - /// + /// Gets the Id. public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// - public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - - /// + /// Gets the Value. public override T Value => _operation.Value; - /// + /// Gets the HasValue. public override bool HasValue => _operation.HasValue; - /// + /// Gets the HasCompleted. public override bool HasCompleted => _operation.HasCompleted; - /// + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// public override Response GetRawResponse() => _operation.RawResponse; - /// + /// public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - /// + /// public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - /// + /// public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); - /// + /// public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); - /// + /// public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); - /// + /// public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionEdgeSiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionEdgeSiteOperationSource.cs deleted file mode 100644 index e6651da10e5f..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionEdgeSiteOperationSource.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.ClientModel.Primitives; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; - -namespace Azure.ResourceManager.SiteManager -{ - internal class SubscriptionEdgeSiteOperationSource : IOperationSource - { - private readonly ArmClient _client; - - internal SubscriptionEdgeSiteOperationSource(ArmClient client) - { - _client = client; - } - - SubscriptionEdgeSiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - return new SubscriptionEdgeSiteResource(_client, data); - } - - async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) - { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); - return await Task.FromResult(new SubscriptionEdgeSiteResource(_client, data)).ConfigureAwait(false); - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs index 0abe9edf2623..8d7babbb4b2d 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs @@ -6,6 +6,7 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.Models; using Azure.ResourceManager.SiteManager.Models; @@ -13,18 +14,16 @@ namespace Azure.ResourceManager.SiteManager { /// /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// For more information /// [ModelReaderWriterBuildable(typeof(EdgeSiteAddressProperties))] [ModelReaderWriterBuildable(typeof(EdgeSiteData))] [ModelReaderWriterBuildable(typeof(EdgeSitePatch))] [ModelReaderWriterBuildable(typeof(EdgeSitePatchProperties))] [ModelReaderWriterBuildable(typeof(EdgeSiteProperties))] - [ModelReaderWriterBuildable(typeof(ResourceGroupEdgeSiteResource))] + [ModelReaderWriterBuildable(typeof(EdgeSiteResource))] [ModelReaderWriterBuildable(typeof(ResponseError))] - [ModelReaderWriterBuildable(typeof(ServiceGroupEdgeSiteResource))] [ModelReaderWriterBuildable(typeof(SiteListResult))] - [ModelReaderWriterBuildable(typeof(SubscriptionEdgeSiteResource))] [ModelReaderWriterBuildable(typeof(SystemData))] public partial class AzureResourceManagerSiteManagerContext : ModelReaderWriterContext { diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.Serialization.cs index c93e48d3df86..4a773b0fb019 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.Serialization.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { - public partial class EdgeSiteAddressProperties : IUtf8JsonSerializable, IJsonModel + /// Site address properties. + public partial class EdgeSiteAddressProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSiteAddressProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(StreetAddress1)) { writer.WritePropertyName("streetAddress1"u8); @@ -64,15 +64,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("postalCode"u8); writer.WriteStringValue(PostalCode); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -81,22 +81,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EdgeSiteAddressProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EdgeSiteAddressProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EdgeSiteAddressProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSiteAddressProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEdgeSiteAddressProperties(document.RootElement, options); } - internal static EdgeSiteAddressProperties DeserializeEdgeSiteAddressProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EdgeSiteAddressProperties DeserializeEdgeSiteAddressProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -107,46 +112,44 @@ internal static EdgeSiteAddressProperties DeserializeEdgeSiteAddressProperties(J string stateOrProvince = default; string country = default; string postalCode = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("streetAddress1"u8)) + if (prop.NameEquals("streetAddress1"u8)) { - streetAddress1 = property.Value.GetString(); + streetAddress1 = prop.Value.GetString(); continue; } - if (property.NameEquals("streetAddress2"u8)) + if (prop.NameEquals("streetAddress2"u8)) { - streetAddress2 = property.Value.GetString(); + streetAddress2 = prop.Value.GetString(); continue; } - if (property.NameEquals("city"u8)) + if (prop.NameEquals("city"u8)) { - city = property.Value.GetString(); + city = prop.Value.GetString(); continue; } - if (property.NameEquals("stateOrProvince"u8)) + if (prop.NameEquals("stateOrProvince"u8)) { - stateOrProvince = property.Value.GetString(); + stateOrProvince = prop.Value.GetString(); continue; } - if (property.NameEquals("country"u8)) + if (prop.NameEquals("country"u8)) { - country = property.Value.GetString(); + country = prop.Value.GetString(); continue; } - if (property.NameEquals("postalCode"u8)) + if (prop.NameEquals("postalCode"u8)) { - postalCode = property.Value.GetString(); + postalCode = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new EdgeSiteAddressProperties( streetAddress1, streetAddress2, @@ -154,13 +157,16 @@ internal static EdgeSiteAddressProperties DeserializeEdgeSiteAddressProperties(J stateOrProvince, country, postalCode, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -170,15 +176,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - EdgeSiteAddressProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + EdgeSiteAddressProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EdgeSiteAddressProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeEdgeSiteAddressProperties(document.RootElement, options); } default: @@ -186,6 +197,7 @@ EdgeSiteAddressProperties IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.cs index 1d30f94bdc0e..9f4d26528a13 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteAddressProperties.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SiteManager.Models /// Site address properties. public partial class EdgeSiteAddressProperties { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public EdgeSiteAddressProperties() @@ -57,8 +28,8 @@ public EdgeSiteAddressProperties() /// State or province of the address. /// Country of the address. /// Postal or ZIP code of the address. - /// Keeps track of any properties unknown to the library. - internal EdgeSiteAddressProperties(string streetAddress1, string streetAddress2, string city, string stateOrProvince, string country, string postalCode, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal EdgeSiteAddressProperties(string streetAddress1, string streetAddress2, string city, string stateOrProvince, string country, string postalCode, IDictionary additionalBinaryDataProperties) { StreetAddress1 = streetAddress1; StreetAddress2 = streetAddress2; @@ -66,19 +37,24 @@ internal EdgeSiteAddressProperties(string streetAddress1, string streetAddress2, StateOrProvince = stateOrProvince; Country = country; PostalCode = postalCode; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// First line of the street address. public string StreetAddress1 { get; set; } + /// Second line of the street address. public string StreetAddress2 { get; set; } + /// City of the address. public string City { get; set; } + /// State or province of the address. public string StateOrProvince { get; set; } + /// Country of the address. public string Country { get; set; } + /// Postal or ZIP code of the address. public string PostalCode { get; set; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.Serialization.cs index 3f3b86f726dd..574941eb94b9 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.Serialization.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { - public partial class EdgeSitePatch : IUtf8JsonSerializable, IJsonModel + /// The type used for update operations of the Site. + public partial class EdgeSitePatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +30,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSitePatch)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -56,53 +57,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EdgeSitePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EdgeSitePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EdgeSitePatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSitePatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEdgeSitePatch(document.RootElement, options); } - internal static EdgeSitePatch DeserializeEdgeSitePatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EdgeSitePatch DeserializeEdgeSitePatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } EdgeSitePatchProperties properties = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = EdgeSitePatchProperties.DeserializeEdgeSitePatchProperties(property.Value, options); + properties = EdgeSitePatchProperties.DeserializeEdgeSitePatchProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new EdgeSitePatch(properties, serializedAdditionalRawData); + return new EdgeSitePatch(properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -112,15 +119,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - EdgeSitePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + EdgeSitePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EdgeSitePatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeEdgeSitePatch(document.RootElement, options); } default: @@ -128,6 +140,19 @@ EdgeSitePatch IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(EdgeSitePatch edgeSitePatch) + { + if (edgeSitePatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(edgeSitePatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.cs index 71f3da0f665d..e57f621138df 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatch.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.SiteManager.Models /// The type used for update operations of the Site. public partial class EdgeSitePatch { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public EdgeSitePatch() @@ -52,11 +23,11 @@ public EdgeSitePatch() /// Initializes a new instance of . /// The updatable properties of the Site. - /// Keeps track of any properties unknown to the library. - internal EdgeSitePatch(EdgeSitePatchProperties properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal EdgeSitePatch(EdgeSitePatchProperties properties, IDictionary additionalBinaryDataProperties) { Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The updatable properties of the Site. diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.Serialization.cs index 4f041daed869..20b9d4dd75e0 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.Serialization.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { - public partial class EdgeSitePatchProperties : IUtf8JsonSerializable, IJsonModel + /// The updatable properties of the Site. + public partial class EdgeSitePatchProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSitePatchProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(DisplayName)) { writer.WritePropertyName("displayName"u8); @@ -56,19 +56,24 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Labels) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -77,22 +82,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EdgeSitePatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EdgeSitePatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EdgeSitePatchProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSitePatchProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEdgeSitePatchProperties(document.RootElement, options); } - internal static EdgeSitePatchProperties DeserializeEdgeSitePatchProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EdgeSitePatchProperties DeserializeEdgeSitePatchProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -101,56 +111,64 @@ internal static EdgeSitePatchProperties DeserializeEdgeSitePatchProperties(JsonE string description = default; EdgeSiteAddressProperties siteAddress = default; IDictionary labels = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("siteAddress"u8)) + if (prop.NameEquals("siteAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - siteAddress = EdgeSiteAddressProperties.DeserializeEdgeSiteAddressProperties(property.Value, options); + siteAddress = EdgeSiteAddressProperties.DeserializeEdgeSiteAddressProperties(prop.Value, options); continue; } - if (property.NameEquals("labels"u8)) + if (prop.NameEquals("labels"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } labels = dictionary; continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new EdgeSitePatchProperties(displayName, description, siteAddress, labels ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new EdgeSitePatchProperties(displayName, description, siteAddress, labels ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -160,15 +178,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpt } } - EdgeSitePatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + EdgeSitePatchProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EdgeSitePatchProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeEdgeSitePatchProperties(document.RootElement, options); } default: @@ -176,6 +199,7 @@ EdgeSitePatchProperties IPersistableModel.Create(Binary } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.cs index 3c81d6790923..d93399c57f03 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSitePatchProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { /// The updatable properties of the Site. public partial class EdgeSitePatchProperties { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public EdgeSitePatchProperties() @@ -56,22 +28,25 @@ public EdgeSitePatchProperties() /// Description of Site resource. /// Physical address of the site. /// Key-value pairs for labeling the site resource. - /// Keeps track of any properties unknown to the library. - internal EdgeSitePatchProperties(string displayName, string description, EdgeSiteAddressProperties siteAddress, IDictionary labels, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal EdgeSitePatchProperties(string displayName, string description, EdgeSiteAddressProperties siteAddress, IDictionary labels, IDictionary additionalBinaryDataProperties) { DisplayName = displayName; Description = description; SiteAddress = siteAddress; Labels = labels; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// displayName of Site resource. public string DisplayName { get; set; } + /// Description of Site resource. public string Description { get; set; } + /// Physical address of the site. public EdgeSiteAddressProperties SiteAddress { get; set; } + /// Key-value pairs for labeling the site resource. public IDictionary Labels { get; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.Serialization.cs index 69e966722efc..8458af16c05b 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.Serialization.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { - public partial class EdgeSiteProperties : IUtf8JsonSerializable, IJsonModel + /// Site properties. + public partial class EdgeSiteProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSiteProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(DisplayName)) { writer.WritePropertyName("displayName"u8); @@ -56,6 +56,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Labels) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -65,15 +70,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("provisioningState"u8); writer.WriteStringValue(ProvisioningState.Value.ToString()); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -82,22 +87,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - EdgeSiteProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + EdgeSiteProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EdgeSiteProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(EdgeSiteProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeEdgeSiteProperties(document.RootElement, options); } - internal static EdgeSiteProperties DeserializeEdgeSiteProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EdgeSiteProperties DeserializeEdgeSiteProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -107,71 +117,79 @@ internal static EdgeSiteProperties DeserializeEdgeSiteProperties(JsonElement ele EdgeSiteAddressProperties siteAddress = default; IDictionary labels = default; EdgeSiteProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("displayName"u8)) + if (prop.NameEquals("displayName"u8)) { - displayName = property.Value.GetString(); + displayName = prop.Value.GetString(); continue; } - if (property.NameEquals("description"u8)) + if (prop.NameEquals("description"u8)) { - description = property.Value.GetString(); + description = prop.Value.GetString(); continue; } - if (property.NameEquals("siteAddress"u8)) + if (prop.NameEquals("siteAddress"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - siteAddress = EdgeSiteAddressProperties.DeserializeEdgeSiteAddressProperties(property.Value, options); + siteAddress = EdgeSiteAddressProperties.DeserializeEdgeSiteAddressProperties(prop.Value, options); continue; } - if (property.NameEquals("labels"u8)) + if (prop.NameEquals("labels"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } labels = dictionary; continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new EdgeSiteProvisioningState(property.Value.GetString()); + provisioningState = new EdgeSiteProvisioningState(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new EdgeSiteProperties( displayName, description, siteAddress, labels ?? new ChangeTrackingDictionary(), provisioningState, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -181,15 +199,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - EdgeSiteProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + EdgeSiteProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EdgeSiteProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeEdgeSiteProperties(document.RootElement, options); } default: @@ -197,6 +220,7 @@ EdgeSiteProperties IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.cs index 4a56f00ea941..89c34bf67891 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { /// Site properties. public partial class EdgeSiteProperties { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public EdgeSiteProperties() @@ -57,25 +29,29 @@ public EdgeSiteProperties() /// Physical address of the site. /// Key-value pairs for labeling the site resource. /// Provisioning state of last operation. - /// Keeps track of any properties unknown to the library. - internal EdgeSiteProperties(string displayName, string description, EdgeSiteAddressProperties siteAddress, IDictionary labels, EdgeSiteProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal EdgeSiteProperties(string displayName, string description, EdgeSiteAddressProperties siteAddress, IDictionary labels, EdgeSiteProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) { DisplayName = displayName; Description = description; SiteAddress = siteAddress; Labels = labels; ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// displayName of Site resource. public string DisplayName { get; set; } + /// Description of Site resource. public string Description { get; set; } + /// Physical address of the site. public EdgeSiteAddressProperties SiteAddress { get; set; } + /// Key-value pairs for labeling the site resource. public IDictionary Labels { get; } + /// Provisioning state of last operation. public EdgeSiteProvisioningState? ProvisioningState { get; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProvisioningState.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProvisioningState.cs index 5b2909109e40..1960e630f25b 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProvisioningState.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/EdgeSiteProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { @@ -14,41 +15,62 @@ namespace Azure.ResourceManager.SiteManager.Models public readonly partial struct EdgeSiteProvisioningState : IEquatable { private readonly string _value; + /// Resource has been created. + private const string SucceededValue = "Succeeded"; + /// Resource creation failed. + private const string FailedValue = "Failed"; + /// Resource creation was canceled. + private const string CanceledValue = "Canceled"; /// Initializes a new instance of . + /// The value. /// is null. public EdgeSiteProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string FailedValue = "Failed"; - private const string CanceledValue = "Canceled"; + _value = value; + } /// Resource has been created. public static EdgeSiteProvisioningState Succeeded { get; } = new EdgeSiteProvisioningState(SucceededValue); + /// Resource creation failed. public static EdgeSiteProvisioningState Failed { get; } = new EdgeSiteProvisioningState(FailedValue); + /// Resource creation was canceled. public static EdgeSiteProvisioningState Canceled { get; } = new EdgeSiteProvisioningState(CanceledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(EdgeSiteProvisioningState left, EdgeSiteProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(EdgeSiteProvisioningState left, EdgeSiteProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator EdgeSiteProvisioningState(string value) => new EdgeSiteProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator EdgeSiteProvisioningState?(string value) => value == null ? null : new EdgeSiteProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is EdgeSiteProvisioningState other && Equals(other); - /// + + /// public bool Equals(EdgeSiteProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs index ad8964f23a12..fd66a1a87bed 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { - internal partial class SiteListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a Site list operation. + internal partial class SiteListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SiteListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SiteListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (EdgeSiteData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SiteListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SiteListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SiteListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SiteListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSiteListResult(document.RootElement, options); } - internal static SiteListResult DeserializeSiteListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SiteListResult DeserializeSiteListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(EdgeSiteData.DeserializeEdgeSiteData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new SiteListResult(value, nextLink, serializedAdditionalRawData); + return new SiteListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - SiteListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SiteListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SiteListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSiteListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ SiteListResult IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SiteListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSiteListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs index 161dc6a1c67f..32d9732fb5fb 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.SiteManager; namespace Azure.ResourceManager.SiteManager.Models { /// The response of a Site list operation. internal partial class SiteListResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The Site items on this page. - /// is null. internal SiteListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The Site items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal SiteListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SiteListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal SiteListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Site items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs index ac5d9bb23fcf..c9333647d797 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.SiteManager { - internal static class ProviderConstants + internal static partial class ProviderConstants { + /// Gets the DefaultProviderNamespace. public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteCollection.cs deleted file mode 100644 index 193089578d0d..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteCollection.cs +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.SiteManager -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetResourceGroupEdgeSites method from an instance of . - /// - public partial class ResourceGroupEdgeSiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _resourceGroupEdgeSiteSitesClientDiagnostics; - private readonly SitesRestOperations _resourceGroupEdgeSiteSitesRestClient; - - /// Initializes a new instance of the class for mocking. - protected ResourceGroupEdgeSiteCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal ResourceGroupEdgeSiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _resourceGroupEdgeSiteSitesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceGroupEdgeSiteResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceGroupEdgeSiteResource.ResourceType, out string resourceGroupEdgeSiteSitesApiVersion); - _resourceGroupEdgeSiteSitesRestClient = new SitesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceGroupEdgeSiteSitesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceGroupResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); - } - - /// - /// Create a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_CreateOrUpdate - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, data, cancellationToken).ConfigureAwait(false); - var operation = new SiteManagerArmOperation(new ResourceGroupEdgeSiteOperationSource(Client), _resourceGroupEdgeSiteSitesClientDiagnostics, Pipeline, _resourceGroupEdgeSiteSitesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Create a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_CreateOrUpdate - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, siteName, data, cancellationToken); - var operation = new SiteManagerArmOperation(new ResourceGroupEdgeSiteOperationSource(Client), _resourceGroupEdgeSiteSitesClientDiagnostics, Pipeline, _resourceGroupEdgeSiteSitesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.Get"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.Get"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// List a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites - /// - /// - /// Operation Id - /// Site_ListByResourceGroup - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceGroupEdgeSiteSitesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceGroupEdgeSiteSitesRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceGroupEdgeSiteResource(Client, EdgeSiteData.DeserializeEdgeSiteData(e)), _resourceGroupEdgeSiteSitesClientDiagnostics, Pipeline, "ResourceGroupEdgeSiteCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// List a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites - /// - /// - /// Operation Id - /// Site_ListByResourceGroup - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _resourceGroupEdgeSiteSitesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceGroupEdgeSiteSitesRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceGroupEdgeSiteResource(Client, EdgeSiteData.DeserializeEdgeSiteData(e)), _resourceGroupEdgeSiteSitesClientDiagnostics, Pipeline, "ResourceGroupEdgeSiteCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.Exists"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.Exists"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteCollection.GetIfExists"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteResource.Serialization.cs deleted file mode 100644 index 5e6951924ab2..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteResource.Serialization.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.SiteManager -{ - public partial class ResourceGroupEdgeSiteResource : IJsonModel - { - private static EdgeSiteData s_dataDeserializationInstance; - private static EdgeSiteData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - EdgeSiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerSiteManagerContext.Default); - - EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSiteManagerContext.Default); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteResource.cs deleted file mode 100644 index 47e22f08c291..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupEdgeSiteResource.cs +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.Resources; -using Azure.ResourceManager.SiteManager.Models; - -namespace Azure.ResourceManager.SiteManager -{ - /// - /// A Class representing a ResourceGroupEdgeSite along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetResourceGroupEdgeSiteResource method. - /// Otherwise you can get one from its parent resource using the GetResourceGroupEdgeSite method. - /// - public partial class ResourceGroupEdgeSiteResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The siteName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string siteName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _resourceGroupEdgeSiteSitesClientDiagnostics; - private readonly SitesRestOperations _resourceGroupEdgeSiteSitesRestClient; - private readonly EdgeSiteData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.Edge/sites"; - - /// Initializes a new instance of the class for mocking. - protected ResourceGroupEdgeSiteResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal ResourceGroupEdgeSiteResource(ArmClient client, EdgeSiteData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal ResourceGroupEdgeSiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _resourceGroupEdgeSiteSitesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string resourceGroupEdgeSiteSitesApiVersion); - _resourceGroupEdgeSiteSitesRestClient = new SitesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceGroupEdgeSiteSitesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual EdgeSiteData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteResource.Get"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteResource.Get"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Delete a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Delete - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteResource.Delete"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _resourceGroupEdgeSiteSitesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SiteManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Delete a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Delete - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteResource.Delete"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var uri = _resourceGroupEdgeSiteSitesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SiteManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Update a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Update - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Resource create parameters. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteResource.Update"); - scope.Start(); - try - { - var response = await _resourceGroupEdgeSiteSitesRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Update a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Update - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Resource create parameters. - /// The cancellation token to use. - /// is null. - public virtual Response Update(EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _resourceGroupEdgeSiteSitesClientDiagnostics.CreateScope("ResourceGroupEdgeSiteResource.Update"); - scope.Start(); - try - { - var response = _resourceGroupEdgeSiteSitesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - return Response.FromValue(new ResourceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesByServiceGroupRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesByServiceGroupRestOperations.cs index dcfe55eed6fd..f4db1a16e254 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesByServiceGroupRestOperations.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesByServiceGroupRestOperations.cs @@ -6,527 +6,138 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SiteManager.Models; namespace Azure.ResourceManager.SiteManager { - internal partial class SitesByServiceGroupRestOperations + internal partial class SitesByServiceGroup { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SitesByServiceGroupRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SitesByServiceGroupRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of SitesByServiceGroup for mocking. + protected SitesByServiceGroup() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-06-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateListByServiceGroupRequestUri(string servicegroupName) + /// Initializes a new instance of SitesByServiceGroup. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal SitesByServiceGroup(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); - uri.AppendPath(servicegroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateListByServiceGroupRequest(string servicegroupName) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetByServiceGroupRequest(string servicegroupName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); uri.AppendPath(servicegroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// list Site at SG scope. - /// The name of the service group. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListByServiceGroupAsync(string servicegroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - - using var message = CreateListByServiceGroupRequest(servicegroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// list Site at SG scope. - /// The name of the service group. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response ListByServiceGroup(string servicegroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByServiceGroupRequest(Uri nextPage, string servicegroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - - using var message = CreateListByServiceGroupRequest(servicegroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetRequestUri(string servicegroupName, string siteName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); - uri.AppendPath(servicegroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string servicegroupName, string siteName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); - uri.AppendPath(servicegroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string servicegroupName, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateGetRequest(servicegroupName, siteName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((EdgeSiteData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response Get(string servicegroupName, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateGetRequest(servicegroupName, siteName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((EdgeSiteData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string servicegroupName, string siteName, EdgeSiteData data) + internal HttpMessage CreateGetRequest(string servicegroupName, string siteName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); uri.AppendPath(servicegroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string servicegroupName, string siteName, EdgeSiteData data) + internal HttpMessage CreateCreateOrUpdateRequest(string servicegroupName, string siteName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); uri.AppendPath(servicegroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// create or update Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task CreateOrUpdateAsync(string servicegroupName, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(servicegroupName, siteName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// create or update Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string servicegroupName, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(servicegroupName, siteName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string servicegroupName, string siteName, EdgeSitePatch patch) + internal HttpMessage CreateUpdateRequest(string servicegroupName, string siteName, RequestContent content, RequestContext context) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); - uri.AppendPath(servicegroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string servicegroupName, string siteName, EdgeSitePatch patch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); uri.AppendPath(servicegroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// update Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string servicegroupName, string siteName, EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(servicegroupName, siteName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// update Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response Update(string servicegroupName, string siteName, EdgeSitePatch patch, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(string servicegroupName, string siteName, RequestContext context) { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(servicegroupName, siteName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string servicegroupName, string siteName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); - uri.AppendPath(servicegroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string servicegroupName, string siteName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); uri.AppendPath(servicegroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); - return message; - } - - /// delete Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string servicegroupName, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateDeleteRequest(servicegroupName, siteName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// delete Site at SG scope. - /// The name of the service group. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response Delete(string servicegroupName, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateDeleteRequest(servicegroupName, siteName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByServiceGroupNextPageRequestUri(string nextLink, string servicegroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByServiceGroupNextPageRequest(string nextLink, string servicegroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - - /// list Site at SG scope. - /// The URL to the next page of results. - /// The name of the service group. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListByServiceGroupNextPageAsync(string nextLink, string servicegroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - - using var message = CreateListByServiceGroupNextPageRequest(nextLink, servicegroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// list Site at SG scope. - /// The URL to the next page of results. - /// The name of the service group. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListByServiceGroupNextPage(string nextLink, string servicegroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); - - using var message = CreateListByServiceGroupNextPageRequest(nextLink, servicegroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs index 79d76907ec6a..93a186872fcd 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs @@ -6,527 +6,138 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SiteManager.Models; namespace Azure.ResourceManager.SiteManager { - internal partial class SitesBySubscriptionRestOperations + internal partial class SitesBySubscription { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SitesBySubscriptionRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SitesBySubscriptionRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of SitesBySubscription for mocking. + protected SitesBySubscription() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-06-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateListRequestUri(string subscriptionId) + /// Initializes a new instance of SitesBySubscription. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal SitesBySubscription(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Edge/sites", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateListRequest(string subscriptionId) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetAllRequest(Guid subscriptionId, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.Edge/sites", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List Site resources by subscription ID. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Site resources by subscription ID. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, Guid subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string siteName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string siteName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateGetRequest(subscriptionId, siteName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((EdgeSiteData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string siteName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(Guid subscriptionId, string siteName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateGetRequest(subscriptionId, siteName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((EdgeSiteData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string siteName, EdgeSiteData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string siteName, EdgeSiteData data) + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string siteName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task CreateOrUpdateAsync(string subscriptionId, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string siteName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, siteName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, siteName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string siteName, EdgeSitePatch patch) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string siteName, EdgeSitePatch patch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string siteName, EdgeSitePatch patch, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string siteName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, siteName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string siteName, EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, siteName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string siteName) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string siteName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - _userAgent.Apply(message); - return message; - } - - /// Delete a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateDeleteRequest(subscriptionId, siteName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the Site. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateDeleteRequest(subscriptionId, siteName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - - /// List Site resources by subscription ID. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Site resources by subscription ID. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs index f26b389a5c06..5e90c3c64af4 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs @@ -6,571 +6,148 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.SiteManager.Models; namespace Azure.ResourceManager.SiteManager { - internal partial class SitesRestOperations + internal partial class Sites { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SitesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SitesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of Sites for mocking. + protected Sites() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-06-01"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string siteName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string siteName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string siteName, CancellationToken cancellationToken = default) + /// Initializes a new instance of Sites. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Sites(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, siteName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((EdgeSiteData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, siteName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((EdgeSiteData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string siteName, EdgeSiteData data) + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string siteName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string siteName, EdgeSiteData data) + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string siteName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, siteName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string siteName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, siteName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string siteName, EdgeSitePatch patch) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string siteName, EdgeSitePatch patch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string siteName, EdgeSitePatch patch, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string siteName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, siteName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string siteName, EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, siteName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - EdgeSiteData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = EdgeSiteData.DeserializeEdgeSiteData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string siteName) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites/", false); - uri.AppendPath(siteName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string siteName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites/", false); uri.AppendPath(siteName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string siteName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, siteName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The name of the Site. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, siteName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Edge/sites", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Edge/sites", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List a Site. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// List a Site. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List a Site. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SiteListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SiteListResult.DeserializeSiteListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteCollection.cs deleted file mode 100644 index cd0e86997dc4..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteCollection.cs +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.SiteManager -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetServiceGroupEdgeSites method from an instance of . - /// - public partial class ServiceGroupEdgeSiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics; - private readonly SitesByServiceGroupRestOperations _serviceGroupEdgeSiteSitesByServiceGroupRestClient; - - /// Initializes a new instance of the class for mocking. - protected ServiceGroupEdgeSiteCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal ServiceGroupEdgeSiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ServiceGroupEdgeSiteResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ServiceGroupEdgeSiteResource.ResourceType, out string serviceGroupEdgeSiteSitesByServiceGroupApiVersion); - _serviceGroupEdgeSiteSitesByServiceGroupRestClient = new SitesByServiceGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, serviceGroupEdgeSiteSitesByServiceGroupApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != "Microsoft.Management/serviceGroups") - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, "Microsoft.Management/serviceGroups"), nameof(id)); - } - - /// - /// create or update Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_CreateOrUpdate - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateOrUpdateAsync(Id.Name, siteName, data, cancellationToken).ConfigureAwait(false); - var operation = new SiteManagerArmOperation(new ServiceGroupEdgeSiteOperationSource(Client), _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics, Pipeline, _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateCreateOrUpdateRequest(Id.Name, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// create or update Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_CreateOrUpdate - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateOrUpdate(Id.Name, siteName, data, cancellationToken); - var operation = new SiteManagerArmOperation(new ServiceGroupEdgeSiteOperationSource(Client), _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics, Pipeline, _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateCreateOrUpdateRequest(Id.Name, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.Get"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.GetAsync(Id.Name, siteName, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.Get"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.Get(Id.Name, siteName, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// list Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites - /// - /// - /// Operation Id - /// Site_ListByServiceGroup - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateListByServiceGroupRequest(Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateListByServiceGroupNextPageRequest(nextLink, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ServiceGroupEdgeSiteResource(Client, EdgeSiteData.DeserializeEdgeSiteData(e)), _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics, Pipeline, "ServiceGroupEdgeSiteCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// list Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites - /// - /// - /// Operation Id - /// Site_ListByServiceGroup - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateListByServiceGroupRequest(Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateListByServiceGroupNextPageRequest(nextLink, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ServiceGroupEdgeSiteResource(Client, EdgeSiteData.DeserializeEdgeSiteData(e)), _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics, Pipeline, "ServiceGroupEdgeSiteCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.Exists"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.GetAsync(Id.Name, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.Exists"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.Get(Id.Name, siteName, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.GetAsync(Id.Name, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteCollection.GetIfExists"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.Get(Id.Name, siteName, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteResource.Serialization.cs deleted file mode 100644 index f978e536c359..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteResource.Serialization.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.SiteManager -{ - public partial class ServiceGroupEdgeSiteResource : IJsonModel - { - private static EdgeSiteData s_dataDeserializationInstance; - private static EdgeSiteData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - EdgeSiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerSiteManagerContext.Default); - - EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSiteManagerContext.Default); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteResource.cs deleted file mode 100644 index 8aa99f7d5e8c..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ServiceGroupEdgeSiteResource.cs +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.SiteManager.Models; - -namespace Azure.ResourceManager.SiteManager -{ - /// - /// A Class representing a ServiceGroupEdgeSite along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetServiceGroupEdgeSiteResource method. - /// Otherwise you can get one from its parent resource using the GetServiceGroupEdgeSite method. - /// - public partial class ServiceGroupEdgeSiteResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The servicegroupName. - /// The siteName. - public static ResourceIdentifier CreateResourceIdentifier(string servicegroupName, string siteName) - { - var resourceId = $"/providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics; - private readonly SitesByServiceGroupRestOperations _serviceGroupEdgeSiteSitesByServiceGroupRestClient; - private readonly EdgeSiteData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.Edge/sites"; - - /// Initializes a new instance of the class for mocking. - protected ServiceGroupEdgeSiteResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal ServiceGroupEdgeSiteResource(ArmClient client, EdgeSiteData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal ServiceGroupEdgeSiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string serviceGroupEdgeSiteSitesByServiceGroupApiVersion); - _serviceGroupEdgeSiteSitesByServiceGroupRestClient = new SitesByServiceGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, serviceGroupEdgeSiteSitesByServiceGroupApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual EdgeSiteData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteResource.Get"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.GetAsync(Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteResource.Get"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.Get(Id.Parent.Name, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// delete Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Delete - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteResource.Delete"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.DeleteAsync(Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateDeleteRequestUri(Id.Parent.Name, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SiteManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// delete Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Delete - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteResource.Delete"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.Delete(Id.Parent.Name, Id.Name, cancellationToken); - var uri = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.CreateDeleteRequestUri(Id.Parent.Name, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SiteManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// update Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Update - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Resource create parameters. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteResource.Update"); - scope.Start(); - try - { - var response = await _serviceGroupEdgeSiteSitesByServiceGroupRestClient.UpdateAsync(Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// update Site at SG scope - /// - /// - /// Request Path - /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Update - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Resource create parameters. - /// The cancellation token to use. - /// is null. - public virtual Response Update(EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _serviceGroupEdgeSiteSitesByServiceGroupClientDiagnostics.CreateScope("ServiceGroupEdgeSiteResource.Update"); - scope.Start(); - try - { - var response = _serviceGroupEdgeSiteSitesByServiceGroupRestClient.Update(Id.Parent.Name, Id.Name, patch, cancellationToken); - return Response.FromValue(new ServiceGroupEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteCollection.cs deleted file mode 100644 index f9bec0a7a75d..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteCollection.cs +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Autorest.CSharp.Core; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.Resources; - -namespace Azure.ResourceManager.SiteManager -{ - /// - /// A class representing a collection of and their operations. - /// Each in the collection will belong to the same instance of . - /// To get a instance call the GetSubscriptionEdgeSites method from an instance of . - /// - public partial class SubscriptionEdgeSiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable - { - private readonly ClientDiagnostics _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics; - private readonly SitesBySubscriptionRestOperations _subscriptionEdgeSiteSitesBySubscriptionRestClient; - - /// Initializes a new instance of the class for mocking. - protected SubscriptionEdgeSiteCollection() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. - internal SubscriptionEdgeSiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", SubscriptionEdgeSiteResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(SubscriptionEdgeSiteResource.ResourceType, out string subscriptionEdgeSiteSitesBySubscriptionApiVersion); - _subscriptionEdgeSiteSitesBySubscriptionRestClient = new SitesBySubscriptionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, subscriptionEdgeSiteSitesBySubscriptionApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != SubscriptionResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, SubscriptionResource.ResourceType), nameof(id)); - } - - /// - /// Create a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_CreateOrUpdate - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, siteName, data, cancellationToken).ConfigureAwait(false); - var operation = new SiteManagerArmOperation(new SubscriptionEdgeSiteOperationSource(Client), _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics, Pipeline, _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Create a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_CreateOrUpdate - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The name of the Site. - /// Resource create parameters. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string siteName, EdgeSiteData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - Argument.AssertNotNull(data, nameof(data)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.CreateOrUpdate"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateOrUpdate(Id.SubscriptionId, siteName, data, cancellationToken); - var operation = new SiteManagerArmOperation(new SubscriptionEdgeSiteOperationSource(Client), _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics, Pipeline, _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.Get"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Get(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.Get"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// List Site resources by subscription ID - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites - /// - /// - /// Operation Id - /// Site_List - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateListRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SubscriptionEdgeSiteResource(Client, EdgeSiteData.DeserializeEdgeSiteData(e)), _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics, Pipeline, "SubscriptionEdgeSiteCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// List Site resources by subscription ID - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites - /// - /// - /// Operation Id - /// Site_List - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateListRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SubscriptionEdgeSiteResource(Client, EdgeSiteData.DeserializeEdgeSiteData(e)), _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics, Pipeline, "SubscriptionEdgeSiteCollection.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> ExistsAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.Exists"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Checks to see if the resource exists in azure. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual Response Exists(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.Exists"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, cancellationToken: cancellationToken); - return Response.FromValue(response.Value != null, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual async Task> GetIfExistsAsync(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.GetIfExists"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Tries to get details for this resource from the service. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The name of the Site. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - public virtual NullableResponse GetIfExists(string siteName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteCollection.GetIfExists"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, cancellationToken: cancellationToken); - if (response.Value == null) - return new NoValueResponse(response.GetRawResponse()); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetAll().GetEnumerator(); - } - - IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) - { - return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteResource.Serialization.cs deleted file mode 100644 index 8945d666ec9c..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteResource.Serialization.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.ResourceManager.SiteManager -{ - public partial class SubscriptionEdgeSiteResource : IJsonModel - { - private static EdgeSiteData s_dataDeserializationInstance; - private static EdgeSiteData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - - EdgeSiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerSiteManagerContext.Default); - - EdgeSiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSiteManagerContext.Default); - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteResource.cs deleted file mode 100644 index dbfef3bd39a2..000000000000 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionEdgeSiteResource.cs +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Globalization; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager.Resources; -using Azure.ResourceManager.SiteManager.Models; - -namespace Azure.ResourceManager.SiteManager -{ - /// - /// A Class representing a SubscriptionEdgeSite along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetSubscriptionEdgeSiteResource method. - /// Otherwise you can get one from its parent resource using the GetSubscriptionEdgeSite method. - /// - public partial class SubscriptionEdgeSiteResource : ArmResource - { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The siteName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string siteName) - { - var resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics; - private readonly SitesBySubscriptionRestOperations _subscriptionEdgeSiteSitesBySubscriptionRestClient; - private readonly EdgeSiteData _data; - - /// Gets the resource type for the operations. - public static readonly ResourceType ResourceType = "Microsoft.Edge/sites"; - - /// Initializes a new instance of the class for mocking. - protected SubscriptionEdgeSiteResource() - { - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The resource that is the target of operations. - internal SubscriptionEdgeSiteResource(ArmClient client, EdgeSiteData data) : this(client, data.Id) - { - HasData = true; - _data = data; - } - - /// Initializes a new instance of the class. - /// The client parameters to use in these operations. - /// The identifier of the resource that is the target of operations. - internal SubscriptionEdgeSiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) - { - _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string subscriptionEdgeSiteSitesBySubscriptionApiVersion); - _subscriptionEdgeSiteSitesBySubscriptionRestClient = new SitesBySubscriptionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, subscriptionEdgeSiteSitesBySubscriptionApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif - } - - /// Gets whether or not the current instance has data. - public virtual bool HasData { get; } - - /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. - public virtual EdgeSiteData Data - { - get - { - if (!HasData) - throw new InvalidOperationException("The current instance does not have data, you must call Get first."); - return _data; - } - } - - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) - { - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteResource.Get"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, Id.Name, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Get a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Get - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) - { - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteResource.Get"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, Id.Name, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Delete a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Delete - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteResource.Delete"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.DeleteAsync(Id.SubscriptionId, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SiteManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Delete a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Delete - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteResource.Delete"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.Delete(Id.SubscriptionId, Id.Name, cancellationToken); - var uri = _subscriptionEdgeSiteSitesBySubscriptionRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new SiteManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Update a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Update - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Resource create parameters. - /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteResource.Update"); - scope.Start(); - try - { - var response = await _subscriptionEdgeSiteSitesBySubscriptionRestClient.UpdateAsync(Id.SubscriptionId, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Update a Site - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} - /// - /// - /// Operation Id - /// Site_Update - /// - /// - /// Default Api Version - /// 2025-06-01 - /// - /// - /// Resource - /// - /// - /// - /// - /// Resource create parameters. - /// The cancellation token to use. - /// is null. - public virtual Response Update(EdgeSitePatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _subscriptionEdgeSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionEdgeSiteResource.Update"); - scope.Start(); - try - { - var response = _subscriptionEdgeSiteSitesBySubscriptionRestClient.Update(Id.SubscriptionId, Id.Name, patch, cancellationToken); - return Response.FromValue(new SubscriptionEdgeSiteResource(Client, response.Value), response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml index d6acbfdebb87..618205f37736 100644 --- a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml @@ -1,4 +1,5 @@ directory: specification/edge/Microsoft.Edge.Sites.Management -commit: 555c4e63be2209f2ade0e1a32a043f1587f2f866 +commit: 2190549a182dc973a20692a138590a50326ac4a4 repo: Azure/azure-rest-api-specs -emitterPackageJsonPath: eng/legacy-emitter-package.json +# emitterPackageJsonPath: eng/legacy-emitter-package.json +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"