diff --git a/Packages.Data.props b/Packages.Data.props index bd40c7262bb..cf2dc549d01 100644 --- a/Packages.Data.props +++ b/Packages.Data.props @@ -29,7 +29,7 @@ - + diff --git a/samples/Azure.ResourceManager.Sample/Generated/DedicatedHostGroupResource.cs b/samples/Azure.ResourceManager.Sample/Generated/DedicatedHostGroupResource.cs index 8ac34d5bbdb..f13e8fceceb 100644 --- a/samples/Azure.ResourceManager.Sample/Generated/DedicatedHostGroupResource.cs +++ b/samples/Azure.ResourceManager.Sample/Generated/DedicatedHostGroupResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of DedicatedHostResources and their operations over a DedicatedHostResource. public virtual DedicatedHostCollection GetDedicatedHosts() { - return GetCachedClient(Client => new DedicatedHostCollection(Client, Id)); + return GetCachedClient(client => new DedicatedHostCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual DedicatedHostCollection GetDedicatedHosts() /// The name of the dedicated host. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetDedicatedHostAsync(string hostName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task> GetDedicatedHostAsync /// The name of the dedicated host. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetDedicatedHost(string hostName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { diff --git a/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleArmClient.cs b/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleArmClient.cs new file mode 100644 index 00000000000..dd6a198aa50 --- /dev/null +++ b/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleArmClient.cs @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Sample; + +namespace Azure.ResourceManager.Sample.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableSampleArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableSampleArmClient() + { + } + + /// 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 MockableSampleArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableSampleArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AvailabilitySetResource GetAvailabilitySetResource(ResourceIdentifier id) + { + AvailabilitySetResource.ValidateResourceId(id); + return new AvailabilitySetResource(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 ProximityPlacementGroupResource GetProximityPlacementGroupResource(ResourceIdentifier id) + { + ProximityPlacementGroupResource.ValidateResourceId(id); + return new ProximityPlacementGroupResource(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 DedicatedHostGroupResource GetDedicatedHostGroupResource(ResourceIdentifier id) + { + DedicatedHostGroupResource.ValidateResourceId(id); + return new DedicatedHostGroupResource(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 DedicatedHostResource GetDedicatedHostResource(ResourceIdentifier id) + { + DedicatedHostResource.ValidateResourceId(id); + return new DedicatedHostResource(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 SshPublicKeyResource GetSshPublicKeyResource(ResourceIdentifier id) + { + SshPublicKeyResource.ValidateResourceId(id); + return new SshPublicKeyResource(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 VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(ResourceIdentifier id) + { + VirtualMachineExtensionImageResource.ValidateResourceId(id); + return new VirtualMachineExtensionImageResource(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 VirtualMachineExtensionResource GetVirtualMachineExtensionResource(ResourceIdentifier id) + { + VirtualMachineExtensionResource.ValidateResourceId(id); + return new VirtualMachineExtensionResource(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 VirtualMachineScaleSetVirtualMachineExtensionResource GetVirtualMachineScaleSetVirtualMachineExtensionResource(ResourceIdentifier id) + { + VirtualMachineScaleSetVirtualMachineExtensionResource.ValidateResourceId(id); + return new VirtualMachineScaleSetVirtualMachineExtensionResource(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 VirtualMachineResource GetVirtualMachineResource(ResourceIdentifier id) + { + VirtualMachineResource.ValidateResourceId(id); + return new VirtualMachineResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ImageResource GetImageResource(ResourceIdentifier id) + { + ImageResource.ValidateResourceId(id); + return new ImageResource(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 VirtualMachineScaleSetResource GetVirtualMachineScaleSetResource(ResourceIdentifier id) + { + VirtualMachineScaleSetResource.ValidateResourceId(id); + return new VirtualMachineScaleSetResource(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 VirtualMachineScaleSetExtensionResource GetVirtualMachineScaleSetExtensionResource(ResourceIdentifier id) + { + VirtualMachineScaleSetExtensionResource.ValidateResourceId(id); + return new VirtualMachineScaleSetExtensionResource(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 VirtualMachineScaleSetRollingUpgradeResource GetVirtualMachineScaleSetRollingUpgradeResource(ResourceIdentifier id) + { + VirtualMachineScaleSetRollingUpgradeResource.ValidateResourceId(id); + return new VirtualMachineScaleSetRollingUpgradeResource(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 VirtualMachineScaleSetVmResource GetVirtualMachineScaleSetVmResource(ResourceIdentifier id) + { + VirtualMachineScaleSetVmResource.ValidateResourceId(id); + return new VirtualMachineScaleSetVmResource(Client, id); + } + } +} diff --git a/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleResourceGroupResource.cs b/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleResourceGroupResource.cs new file mode 100644 index 00000000000..590e0a149c6 --- /dev/null +++ b/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleResourceGroupResource.cs @@ -0,0 +1,419 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Sample; +using Azure.ResourceManager.Sample.Models; + +namespace Azure.ResourceManager.Sample.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableSampleResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableSampleResourceGroupResource() + { + } + + /// 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 MockableSampleResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. + public virtual AvailabilitySetCollection GetAvailabilitySets() + { + return GetCachedClient(client => new AvailabilitySetCollection(client, Id)); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAvailabilitySetAsync(string availabilitySetName, CancellationToken cancellationToken = default) + { + return await GetAvailabilitySets().GetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAvailabilitySet(string availabilitySetName, CancellationToken cancellationToken = default) + { + return GetAvailabilitySets().Get(availabilitySetName, cancellationToken); + } + + /// Gets a collection of ProximityPlacementGroupResources in the ResourceGroupResource. + /// An object representing collection of ProximityPlacementGroupResources and their operations over a ProximityPlacementGroupResource. + public virtual ProximityPlacementGroupCollection GetProximityPlacementGroups() + { + return GetCachedClient(client => new ProximityPlacementGroupCollection(client, Id)); + } + + /// + /// Retrieves information about a proximity placement group . + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName} + /// + /// + /// Operation Id + /// ProximityPlacementGroups_Get + /// + /// + /// + /// The name of the proximity placement group. + /// includeColocationStatus=true enables fetching the colocation status of all the resources in the proximity placement group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetProximityPlacementGroupAsync(string proximityPlacementGroupName, string includeColocationStatus = null, CancellationToken cancellationToken = default) + { + return await GetProximityPlacementGroups().GetAsync(proximityPlacementGroupName, includeColocationStatus, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about a proximity placement group . + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName} + /// + /// + /// Operation Id + /// ProximityPlacementGroups_Get + /// + /// + /// + /// The name of the proximity placement group. + /// includeColocationStatus=true enables fetching the colocation status of all the resources in the proximity placement group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetProximityPlacementGroup(string proximityPlacementGroupName, string includeColocationStatus = null, CancellationToken cancellationToken = default) + { + return GetProximityPlacementGroups().Get(proximityPlacementGroupName, includeColocationStatus, cancellationToken); + } + + /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. + public virtual DedicatedHostGroupCollection GetDedicatedHostGroups() + { + return GetCachedClient(client => new DedicatedHostGroupCollection(client, Id)); + } + + /// + /// Retrieves information about a dedicated host group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName} + /// + /// + /// Operation Id + /// DedicatedHostGroups_Get + /// + /// + /// + /// The name of the dedicated host group. + /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDedicatedHostGroupAsync(string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return await GetDedicatedHostGroups().GetAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about a dedicated host group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName} + /// + /// + /// Operation Id + /// DedicatedHostGroups_Get + /// + /// + /// + /// The name of the dedicated host group. + /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDedicatedHostGroup(string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return GetDedicatedHostGroups().Get(hostGroupName, expand, cancellationToken); + } + + /// Gets a collection of SshPublicKeyResources in the ResourceGroupResource. + /// An object representing collection of SshPublicKeyResources and their operations over a SshPublicKeyResource. + public virtual SshPublicKeyCollection GetSshPublicKeys() + { + return GetCachedClient(client => new SshPublicKeyCollection(client, Id)); + } + + /// + /// Retrieves information about an SSH public key. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName} + /// + /// + /// Operation Id + /// SshPublicKeys_Get + /// + /// + /// + /// The name of the SSH public key. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSshPublicKeyAsync(string sshPublicKeyName, CancellationToken cancellationToken = default) + { + return await GetSshPublicKeys().GetAsync(sshPublicKeyName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an SSH public key. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName} + /// + /// + /// Operation Id + /// SshPublicKeys_Get + /// + /// + /// + /// The name of the SSH public key. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSshPublicKey(string sshPublicKeyName, CancellationToken cancellationToken = default) + { + return GetSshPublicKeys().Get(sshPublicKeyName, cancellationToken); + } + + /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. + public virtual VirtualMachineCollection GetVirtualMachines() + { + return GetCachedClient(client => new VirtualMachineCollection(client, Id)); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName} + /// + /// + /// Operation Id + /// VirtualMachines_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineAsync(string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return await GetVirtualMachines().GetAsync(vmName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName} + /// + /// + /// Operation Id + /// VirtualMachines_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachine(string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return GetVirtualMachines().Get(vmName, expand, cancellationToken); + } + + /// Gets a collection of ImageResources in the ResourceGroupResource. + /// An object representing collection of ImageResources and their operations over a ImageResource. + public virtual ImageCollection GetImages() + { + return GetCachedClient(client => new ImageCollection(client, Id)); + } + + /// + /// Gets an image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// The name of the image. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetImageAsync(string imageName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetImages().GetAsync(imageName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// The name of the image. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetImage(string imageName, string expand = null, CancellationToken cancellationToken = default) + { + return GetImages().Get(imageName, expand, cancellationToken); + } + + /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. + public virtual VirtualMachineScaleSetCollection GetVirtualMachineScaleSets() + { + return GetCachedClient(client => new VirtualMachineScaleSetCollection(client, Id)); + } + + /// + /// Display information about a virtual machine scale set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSets_Get + /// + /// + /// + /// The name of the VM scale set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineScaleSetAsync(string vmScaleSetName, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineScaleSets().GetAsync(vmScaleSetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Display information about a virtual machine scale set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSets_Get + /// + /// + /// + /// The name of the VM scale set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineScaleSet(string vmScaleSetName, CancellationToken cancellationToken = default) + { + return GetVirtualMachineScaleSets().Get(vmScaleSetName, cancellationToken); + } + } +} diff --git a/samples/Azure.ResourceManager.Sample/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleSubscriptionResource.cs similarity index 84% rename from samples/Azure.ResourceManager.Sample/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleSubscriptionResource.cs index b9525fc4b28..0fb45b9a8f8 100644 --- a/samples/Azure.ResourceManager.Sample/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/samples/Azure.ResourceManager.Sample/Generated/Extensions/MockableSampleSubscriptionResource.cs @@ -13,12 +13,13 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using Azure.ResourceManager.Sample; using Azure.ResourceManager.Sample.Models; -namespace Azure.ResourceManager.Sample +namespace Azure.ResourceManager.Sample.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableSampleSubscriptionResource : ArmResource { private ClientDiagnostics _availabilitySetClientDiagnostics; private AvailabilitySetsRestOperations _availabilitySetRestClient; @@ -43,15 +44,15 @@ internal partial class SubscriptionResourceExtensionClient : ArmResource private ClientDiagnostics _logAnalyticsClientDiagnostics; private LogAnalyticsRestOperations _logAnalyticsRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableSampleSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableSampleSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -87,12 +88,66 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. /// The name of a supported Azure region. /// The String to use. + /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public virtual VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(AzureLocation location, string publisherName) { return new VirtualMachineExtensionImageCollection(Client, Id, location, publisherName); } + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineExtensionImageAsync(AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineExtensionImage(AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + } + /// /// Lists all availability sets in a subscription. /// @@ -113,7 +168,7 @@ public virtual AsyncPageable GetAvailabilitySetsAsync(s { HttpMessage FirstPageRequest(int? pageSizeHint) => AvailabilitySetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => AvailabilitySetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetAvailabilitySets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetAvailabilitySets", "value", "nextLink", cancellationToken); } /// @@ -136,7 +191,7 @@ public virtual Pageable GetAvailabilitySets(string expa { HttpMessage FirstPageRequest(int? pageSizeHint) => AvailabilitySetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => AvailabilitySetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetAvailabilitySets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetAvailabilitySets", "value", "nextLink", cancellationToken); } /// @@ -158,7 +213,7 @@ public virtual AsyncPageable GetProximityPlacem { HttpMessage FirstPageRequest(int? pageSizeHint) => ProximityPlacementGroupRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ProximityPlacementGroupRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ProximityPlacementGroupResource(Client, ProximityPlacementGroupData.DeserializeProximityPlacementGroupData(e)), ProximityPlacementGroupClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetProximityPlacementGroups", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ProximityPlacementGroupResource(Client, ProximityPlacementGroupData.DeserializeProximityPlacementGroupData(e)), ProximityPlacementGroupClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetProximityPlacementGroups", "value", "nextLink", cancellationToken); } /// @@ -180,7 +235,7 @@ public virtual Pageable GetProximityPlacementGr { HttpMessage FirstPageRequest(int? pageSizeHint) => ProximityPlacementGroupRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ProximityPlacementGroupRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ProximityPlacementGroupResource(Client, ProximityPlacementGroupData.DeserializeProximityPlacementGroupData(e)), ProximityPlacementGroupClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetProximityPlacementGroups", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ProximityPlacementGroupResource(Client, ProximityPlacementGroupData.DeserializeProximityPlacementGroupData(e)), ProximityPlacementGroupClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetProximityPlacementGroups", "value", "nextLink", cancellationToken); } /// @@ -202,7 +257,7 @@ public virtual AsyncPageable GetDedicatedHostGroupsA { HttpMessage FirstPageRequest(int? pageSizeHint) => DedicatedHostGroupRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DedicatedHostGroupRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DedicatedHostGroupResource(Client, DedicatedHostGroupData.DeserializeDedicatedHostGroupData(e)), DedicatedHostGroupClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDedicatedHostGroups", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DedicatedHostGroupResource(Client, DedicatedHostGroupData.DeserializeDedicatedHostGroupData(e)), DedicatedHostGroupClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetDedicatedHostGroups", "value", "nextLink", cancellationToken); } /// @@ -224,7 +279,7 @@ public virtual Pageable GetDedicatedHostGroups(Cance { HttpMessage FirstPageRequest(int? pageSizeHint) => DedicatedHostGroupRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DedicatedHostGroupRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DedicatedHostGroupResource(Client, DedicatedHostGroupData.DeserializeDedicatedHostGroupData(e)), DedicatedHostGroupClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDedicatedHostGroups", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DedicatedHostGroupResource(Client, DedicatedHostGroupData.DeserializeDedicatedHostGroupData(e)), DedicatedHostGroupClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetDedicatedHostGroups", "value", "nextLink", cancellationToken); } /// @@ -246,7 +301,7 @@ public virtual AsyncPageable GetSshPublicKeysAsync(Cancell { HttpMessage FirstPageRequest(int? pageSizeHint) => SshPublicKeyRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => SshPublicKeyRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SshPublicKeyResource(Client, SshPublicKeyData.DeserializeSshPublicKeyData(e)), SshPublicKeyClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetSshPublicKeys", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SshPublicKeyResource(Client, SshPublicKeyData.DeserializeSshPublicKeyData(e)), SshPublicKeyClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetSshPublicKeys", "value", "nextLink", cancellationToken); } /// @@ -268,7 +323,7 @@ public virtual Pageable GetSshPublicKeys(CancellationToken { HttpMessage FirstPageRequest(int? pageSizeHint) => SshPublicKeyRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => SshPublicKeyRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SshPublicKeyResource(Client, SshPublicKeyData.DeserializeSshPublicKeyData(e)), SshPublicKeyClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetSshPublicKeys", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SshPublicKeyResource(Client, SshPublicKeyData.DeserializeSshPublicKeyData(e)), SshPublicKeyClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetSshPublicKeys", "value", "nextLink", cancellationToken); } /// @@ -290,9 +345,16 @@ public virtual Pageable GetSshPublicKeys(CancellationToken /// A valid image SKU. /// A valid image SKU version. /// The cancellation token to use. + /// , , or is an empty string, and was expected to be non-empty. + /// , , or is null. public virtual async Task> GetVirtualMachineImageAsync(AzureLocation location, string publisherName, string offer, string skus, string version, CancellationToken cancellationToken = default) { - using var scope = VirtualMachineImagesClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetVirtualMachineImage"); + Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); + Argument.AssertNotNullOrEmpty(offer, nameof(offer)); + Argument.AssertNotNullOrEmpty(skus, nameof(skus)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = VirtualMachineImagesClientDiagnostics.CreateScope("MockableSampleSubscriptionResource.GetVirtualMachineImage"); scope.Start(); try { @@ -325,9 +387,16 @@ public virtual async Task> GetVirtualMachineImageA /// A valid image SKU. /// A valid image SKU version. /// The cancellation token to use. + /// , , or is an empty string, and was expected to be non-empty. + /// , , or is null. public virtual Response GetVirtualMachineImage(AzureLocation location, string publisherName, string offer, string skus, string version, CancellationToken cancellationToken = default) { - using var scope = VirtualMachineImagesClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetVirtualMachineImage"); + Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); + Argument.AssertNotNullOrEmpty(offer, nameof(offer)); + Argument.AssertNotNullOrEmpty(skus, nameof(skus)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using var scope = VirtualMachineImagesClientDiagnostics.CreateScope("MockableSampleSubscriptionResource.GetVirtualMachineImage"); scope.Start(); try { @@ -356,11 +425,14 @@ public virtual Response GetVirtualMachineImage(AzureLocatio /// /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. + /// is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetVirtualMachineImagesAsync(SubscriptionResourceGetVirtualMachineImagesOptions options, CancellationToken cancellationToken = default) { + Argument.AssertNotNull(options, nameof(options)); + HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListRequest(Id.SubscriptionId, options.Location, options.PublisherName, options.Offer, options.Skus, options.Expand, options.Top, options.Orderby); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachineImages", "", null, cancellationToken); } /// @@ -378,11 +450,14 @@ public virtual AsyncPageable GetVirtualMachineImage /// /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. /// The cancellation token to use. + /// is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetVirtualMachineImages(SubscriptionResourceGetVirtualMachineImagesOptions options, CancellationToken cancellationToken = default) { + Argument.AssertNotNull(options, nameof(options)); + HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListRequest(Id.SubscriptionId, options.Location, options.PublisherName, options.Offer, options.Skus, options.Expand, options.Top, options.Orderby); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachineImages", "", null, cancellationToken); } /// @@ -401,11 +476,15 @@ public virtual Pageable GetVirtualMachineImages(Sub /// The name of a supported Azure region. /// A valid image publisher. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetOffersVirtualMachineImagesAsync(AzureLocation location, string publisherName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); + HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListOffersRequest(Id.SubscriptionId, location, publisherName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetOffersVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetOffersVirtualMachineImages", "", null, cancellationToken); } /// @@ -424,11 +503,15 @@ public virtual AsyncPageable GetOffersVirtualMachin /// The name of a supported Azure region. /// A valid image publisher. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetOffersVirtualMachineImages(AzureLocation location, string publisherName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); + HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListOffersRequest(Id.SubscriptionId, location, publisherName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetOffersVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetOffersVirtualMachineImages", "", null, cancellationToken); } /// @@ -450,7 +533,7 @@ public virtual Pageable GetOffersVirtualMachineImag public virtual AsyncPageable GetPublishersVirtualMachineImagesAsync(AzureLocation location, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListPublishersRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetPublishersVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetPublishersVirtualMachineImages", "", null, cancellationToken); } /// @@ -472,7 +555,7 @@ public virtual AsyncPageable GetPublishersVirtualMa public virtual Pageable GetPublishersVirtualMachineImages(AzureLocation location, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListPublishersRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetPublishersVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetPublishersVirtualMachineImages", "", null, cancellationToken); } /// @@ -492,11 +575,16 @@ public virtual Pageable GetPublishersVirtualMachine /// A valid image publisher. /// A valid image publisher offer. /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetSkusVirtualMachineImagesAsync(AzureLocation location, string publisherName, string offer, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); + Argument.AssertNotNullOrEmpty(offer, nameof(offer)); + HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListSkusRequest(Id.SubscriptionId, location, publisherName, offer); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetSkusVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetSkusVirtualMachineImages", "", null, cancellationToken); } /// @@ -516,11 +604,16 @@ public virtual AsyncPageable GetSkusVirtualMachineI /// A valid image publisher. /// A valid image publisher offer. /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetSkusVirtualMachineImages(AzureLocation location, string publisherName, string offer, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); + Argument.AssertNotNullOrEmpty(offer, nameof(offer)); + HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineImagesRestClient.CreateListSkusRequest(Id.SubscriptionId, location, publisherName, offer); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetSkusVirtualMachineImages", "", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineImageResource.DeserializeVirtualMachineImageResource, VirtualMachineImagesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetSkusVirtualMachineImages", "", null, cancellationToken); } /// @@ -543,7 +636,7 @@ public virtual AsyncPageable GetUsagesAsync(AzureLocation location, { HttpMessage FirstPageRequest(int? pageSizeHint) => UsageRestClient.CreateListRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => UsageRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, SampleUsage.DeserializeSampleUsage, UsageClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetUsages", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, SampleUsage.DeserializeSampleUsage, UsageClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetUsages", "value", "nextLink", cancellationToken); } /// @@ -566,7 +659,7 @@ public virtual Pageable GetUsages(AzureLocation location, Cancellat { HttpMessage FirstPageRequest(int? pageSizeHint) => UsageRestClient.CreateListRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => UsageRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, SampleUsage.DeserializeSampleUsage, UsageClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetUsages", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, SampleUsage.DeserializeSampleUsage, UsageClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetUsages", "value", "nextLink", cancellationToken); } /// @@ -589,7 +682,7 @@ public virtual AsyncPageable GetVirtualMachinesByLocatio { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListByLocationRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListByLocationNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); } /// @@ -612,7 +705,7 @@ public virtual Pageable GetVirtualMachinesByLocation(Azu { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListByLocationRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListByLocationNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); } /// @@ -635,7 +728,7 @@ public virtual AsyncPageable GetVirtualMachinesAsync(str { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListAllRequest(Id.SubscriptionId, statusOnly); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, statusOnly); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachines", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachines", "value", "nextLink", cancellationToken); } /// @@ -658,7 +751,7 @@ public virtual Pageable GetVirtualMachines(string status { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListAllRequest(Id.SubscriptionId, statusOnly); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, statusOnly); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachines", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachines", "value", "nextLink", cancellationToken); } /// @@ -680,7 +773,7 @@ public virtual Pageable GetVirtualMachines(string status public virtual AsyncPageable GetVirtualMachineSizesAsync(AzureLocation location, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineSizesRestClient.CreateListRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineSize.DeserializeVirtualMachineSize, VirtualMachineSizesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineSizes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, VirtualMachineSize.DeserializeVirtualMachineSize, VirtualMachineSizesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachineSizes", "value", null, cancellationToken); } /// @@ -702,7 +795,7 @@ public virtual AsyncPageable GetVirtualMachineSizesAsync(Azu public virtual Pageable GetVirtualMachineSizes(AzureLocation location, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineSizesRestClient.CreateListRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineSize.DeserializeVirtualMachineSize, VirtualMachineSizesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineSizes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, VirtualMachineSize.DeserializeVirtualMachineSize, VirtualMachineSizesClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachineSizes", "value", null, cancellationToken); } /// @@ -724,7 +817,7 @@ public virtual AsyncPageable GetImagesAsync(CancellationToken can { HttpMessage FirstPageRequest(int? pageSizeHint) => ImageRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ImageRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetImages", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetImages", "value", "nextLink", cancellationToken); } /// @@ -746,7 +839,7 @@ public virtual Pageable GetImages(CancellationToken cancellationT { HttpMessage FirstPageRequest(int? pageSizeHint) => ImageRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ImageRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetImages", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetImages", "value", "nextLink", cancellationToken); } /// @@ -768,7 +861,7 @@ public virtual AsyncPageable GetVirtualMachineSc { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineScaleSetRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineScaleSetRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); } /// @@ -790,7 +883,7 @@ public virtual Pageable GetVirtualMachineScaleSe { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineScaleSetRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineScaleSetRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "MockableSampleSubscriptionResource.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); } /// @@ -810,9 +903,12 @@ public virtual Pageable GetVirtualMachineScaleSe /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getRequestRateByInterval Api. /// The cancellation token to use. + /// is null. public virtual async Task> ExportRequestRateByIntervalLogAnalyticAsync(WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportRequestRateByIntervalLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableSampleSubscriptionResource.ExportRequestRateByIntervalLogAnalytic"); scope.Start(); try { @@ -846,9 +942,12 @@ public virtual async Task> ExportRequestRateByInterva /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getRequestRateByInterval Api. /// The cancellation token to use. + /// is null. public virtual ArmOperation ExportRequestRateByIntervalLogAnalytic(WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportRequestRateByIntervalLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableSampleSubscriptionResource.ExportRequestRateByIntervalLogAnalytic"); scope.Start(); try { @@ -882,9 +981,12 @@ public virtual ArmOperation ExportRequestRateByIntervalLogAnalytic /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getThrottledRequests Api. /// The cancellation token to use. + /// is null. public virtual async Task> ExportThrottledRequestsLogAnalyticAsync(WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportThrottledRequestsLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableSampleSubscriptionResource.ExportThrottledRequestsLogAnalytic"); scope.Start(); try { @@ -918,9 +1020,12 @@ public virtual async Task> ExportThrottledRequestsLog /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getThrottledRequests Api. /// The cancellation token to use. + /// is null. public virtual ArmOperation ExportThrottledRequestsLogAnalytic(WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportThrottledRequestsLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableSampleSubscriptionResource.ExportThrottledRequestsLogAnalytic"); scope.Start(); try { diff --git a/samples/Azure.ResourceManager.Sample/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/samples/Azure.ResourceManager.Sample/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index dbe9700070d..00000000000 --- a/samples/Azure.ResourceManager.Sample/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace Azure.ResourceManager.Sample -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. - /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. - public virtual AvailabilitySetCollection GetAvailabilitySets() - { - return GetCachedClient(Client => new AvailabilitySetCollection(Client, Id)); - } - - /// Gets a collection of ProximityPlacementGroupResources in the ResourceGroupResource. - /// An object representing collection of ProximityPlacementGroupResources and their operations over a ProximityPlacementGroupResource. - public virtual ProximityPlacementGroupCollection GetProximityPlacementGroups() - { - return GetCachedClient(Client => new ProximityPlacementGroupCollection(Client, Id)); - } - - /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. - /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. - public virtual DedicatedHostGroupCollection GetDedicatedHostGroups() - { - return GetCachedClient(Client => new DedicatedHostGroupCollection(Client, Id)); - } - - /// Gets a collection of SshPublicKeyResources in the ResourceGroupResource. - /// An object representing collection of SshPublicKeyResources and their operations over a SshPublicKeyResource. - public virtual SshPublicKeyCollection GetSshPublicKeys() - { - return GetCachedClient(Client => new SshPublicKeyCollection(Client, Id)); - } - - /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. - /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. - public virtual VirtualMachineCollection GetVirtualMachines() - { - return GetCachedClient(Client => new VirtualMachineCollection(Client, Id)); - } - - /// Gets a collection of ImageResources in the ResourceGroupResource. - /// An object representing collection of ImageResources and their operations over a ImageResource. - public virtual ImageCollection GetImages() - { - return GetCachedClient(Client => new ImageCollection(Client, Id)); - } - - /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. - /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. - public virtual VirtualMachineScaleSetCollection GetVirtualMachineScaleSets() - { - return GetCachedClient(Client => new VirtualMachineScaleSetCollection(Client, Id)); - } - } -} diff --git a/samples/Azure.ResourceManager.Sample/Generated/Extensions/SampleExtensions.cs b/samples/Azure.ResourceManager.Sample/Generated/Extensions/SampleExtensions.cs index a584b18d777..8b52543819a 100644 --- a/samples/Azure.ResourceManager.Sample/Generated/Extensions/SampleExtensions.cs +++ b/samples/Azure.ResourceManager.Sample/Generated/Extensions/SampleExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Sample.Mocking; using Azure.ResourceManager.Sample.Models; namespace Azure.ResourceManager.Sample @@ -19,309 +20,257 @@ namespace Azure.ResourceManager.Sample /// A class to add extension methods to Azure.ResourceManager.Sample. public static partial class SampleExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableSampleArmClient GetMockableSampleArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableSampleArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableSampleResourceGroupResource GetMockableSampleResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableSampleResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableSampleSubscriptionResource GetMockableSampleSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableSampleSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region AvailabilitySetResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AvailabilitySetResource GetAvailabilitySetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AvailabilitySetResource.ValidateResourceId(id); - return new AvailabilitySetResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetAvailabilitySetResource(id); } - #endregion - #region ProximityPlacementGroupResource /// /// 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. /// Returns a object. public static ProximityPlacementGroupResource GetProximityPlacementGroupResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ProximityPlacementGroupResource.ValidateResourceId(id); - return new ProximityPlacementGroupResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetProximityPlacementGroupResource(id); } - #endregion - #region DedicatedHostGroupResource /// /// 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. /// Returns a object. public static DedicatedHostGroupResource GetDedicatedHostGroupResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DedicatedHostGroupResource.ValidateResourceId(id); - return new DedicatedHostGroupResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetDedicatedHostGroupResource(id); } - #endregion - #region DedicatedHostResource /// /// 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. /// Returns a object. public static DedicatedHostResource GetDedicatedHostResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DedicatedHostResource.ValidateResourceId(id); - return new DedicatedHostResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetDedicatedHostResource(id); } - #endregion - #region SshPublicKeyResource /// /// 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. /// Returns a object. public static SshPublicKeyResource GetSshPublicKeyResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SshPublicKeyResource.ValidateResourceId(id); - return new SshPublicKeyResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetSshPublicKeyResource(id); } - #endregion - #region VirtualMachineExtensionImageResource /// /// 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. /// Returns a object. public static VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineExtensionImageResource.ValidateResourceId(id); - return new VirtualMachineExtensionImageResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineExtensionImageResource(id); } - #endregion - #region VirtualMachineExtensionResource /// /// 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. /// Returns a object. public static VirtualMachineExtensionResource GetVirtualMachineExtensionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineExtensionResource.ValidateResourceId(id); - return new VirtualMachineExtensionResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineExtensionResource(id); } - #endregion - #region VirtualMachineScaleSetVirtualMachineExtensionResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetVirtualMachineExtensionResource GetVirtualMachineScaleSetVirtualMachineExtensionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetVirtualMachineExtensionResource.ValidateResourceId(id); - return new VirtualMachineScaleSetVirtualMachineExtensionResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineScaleSetVirtualMachineExtensionResource(id); } - #endregion - #region VirtualMachineResource /// /// 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. /// Returns a object. public static VirtualMachineResource GetVirtualMachineResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineResource.ValidateResourceId(id); - return new VirtualMachineResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineResource(id); } - #endregion - #region ImageResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static ImageResource GetImageResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ImageResource.ValidateResourceId(id); - return new ImageResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetImageResource(id); } - #endregion - #region VirtualMachineScaleSetResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetResource GetVirtualMachineScaleSetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetResource.ValidateResourceId(id); - return new VirtualMachineScaleSetResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineScaleSetResource(id); } - #endregion - #region VirtualMachineScaleSetExtensionResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetExtensionResource GetVirtualMachineScaleSetExtensionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetExtensionResource.ValidateResourceId(id); - return new VirtualMachineScaleSetExtensionResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineScaleSetExtensionResource(id); } - #endregion - #region VirtualMachineScaleSetRollingUpgradeResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetRollingUpgradeResource GetVirtualMachineScaleSetRollingUpgradeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetRollingUpgradeResource.ValidateResourceId(id); - return new VirtualMachineScaleSetRollingUpgradeResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineScaleSetRollingUpgradeResource(id); } - #endregion - #region VirtualMachineScaleSetVmResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetVmResource GetVirtualMachineScaleSetVmResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetVmResource.ValidateResourceId(id); - return new VirtualMachineScaleSetVmResource(client, id); - } - ); + return GetMockableSampleArmClient(client).GetVirtualMachineScaleSetVmResource(id); } - #endregion - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAvailabilitySets(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetAvailabilitySets(); } /// @@ -336,16 +285,20 @@ public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupRe /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetAvailabilitySetAsync(this ResourceGroupResource resourceGroupResource, string availabilitySetName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetAvailabilitySets().GetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetAvailabilitySetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); } /// @@ -360,24 +313,34 @@ public static async Task> GetAvailabilitySetAs /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetAvailabilitySet(this ResourceGroupResource resourceGroupResource, string availabilitySetName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetAvailabilitySets().Get(availabilitySetName, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetAvailabilitySet(availabilitySetName, cancellationToken); } - /// Gets a collection of ProximityPlacementGroupResources in the ResourceGroupResource. + /// + /// Gets a collection of ProximityPlacementGroupResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ProximityPlacementGroupResources and their operations over a ProximityPlacementGroupResource. public static ProximityPlacementGroupCollection GetProximityPlacementGroups(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetProximityPlacementGroups(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetProximityPlacementGroups(); } /// @@ -392,17 +355,21 @@ public static ProximityPlacementGroupCollection GetProximityPlacementGroups(this /// ProximityPlacementGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the proximity placement group. /// includeColocationStatus=true enables fetching the colocation status of all the resources in the proximity placement group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetProximityPlacementGroupAsync(this ResourceGroupResource resourceGroupResource, string proximityPlacementGroupName, string includeColocationStatus = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetProximityPlacementGroups().GetAsync(proximityPlacementGroupName, includeColocationStatus, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetProximityPlacementGroupAsync(proximityPlacementGroupName, includeColocationStatus, cancellationToken).ConfigureAwait(false); } /// @@ -417,25 +384,35 @@ public static async Task> GetProximity /// ProximityPlacementGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the proximity placement group. /// includeColocationStatus=true enables fetching the colocation status of all the resources in the proximity placement group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetProximityPlacementGroup(this ResourceGroupResource resourceGroupResource, string proximityPlacementGroupName, string includeColocationStatus = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetProximityPlacementGroups().Get(proximityPlacementGroupName, includeColocationStatus, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetProximityPlacementGroup(proximityPlacementGroupName, includeColocationStatus, cancellationToken); } - /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// + /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. public static DedicatedHostGroupCollection GetDedicatedHostGroups(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDedicatedHostGroups(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetDedicatedHostGroups(); } /// @@ -450,17 +427,21 @@ public static DedicatedHostGroupCollection GetDedicatedHostGroups(this ResourceG /// DedicatedHostGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the dedicated host group. /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDedicatedHostGroupAsync(this ResourceGroupResource resourceGroupResource, string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDedicatedHostGroups().GetAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetDedicatedHostGroupAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -475,25 +456,35 @@ public static async Task> GetDedicatedHostG /// DedicatedHostGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the dedicated host group. /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDedicatedHostGroup(this ResourceGroupResource resourceGroupResource, string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDedicatedHostGroups().Get(hostGroupName, expand, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetDedicatedHostGroup(hostGroupName, expand, cancellationToken); } - /// Gets a collection of SshPublicKeyResources in the ResourceGroupResource. + /// + /// Gets a collection of SshPublicKeyResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SshPublicKeyResources and their operations over a SshPublicKeyResource. public static SshPublicKeyCollection GetSshPublicKeys(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSshPublicKeys(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetSshPublicKeys(); } /// @@ -508,16 +499,20 @@ public static SshPublicKeyCollection GetSshPublicKeys(this ResourceGroupResource /// SshPublicKeys_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the SSH public key. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSshPublicKeyAsync(this ResourceGroupResource resourceGroupResource, string sshPublicKeyName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetSshPublicKeys().GetAsync(sshPublicKeyName, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetSshPublicKeyAsync(sshPublicKeyName, cancellationToken).ConfigureAwait(false); } /// @@ -532,24 +527,34 @@ public static async Task> GetSshPublicKeyAsync(th /// SshPublicKeys_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the SSH public key. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSshPublicKey(this ResourceGroupResource resourceGroupResource, string sshPublicKeyName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetSshPublicKeys().Get(sshPublicKeyName, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetSshPublicKey(sshPublicKeyName, cancellationToken); } - /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// + /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. public static VirtualMachineCollection GetVirtualMachines(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVirtualMachines(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetVirtualMachines(); } /// @@ -564,17 +569,21 @@ public static VirtualMachineCollection GetVirtualMachines(this ResourceGroupReso /// VirtualMachines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineAsync(this ResourceGroupResource resourceGroupResource, string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVirtualMachines().GetAsync(vmName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetVirtualMachineAsync(vmName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -589,25 +598,35 @@ public static async Task> GetVirtualMachineAsyn /// VirtualMachines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachine(this ResourceGroupResource resourceGroupResource, string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVirtualMachines().Get(vmName, expand, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetVirtualMachine(vmName, expand, cancellationToken); } - /// Gets a collection of ImageResources in the ResourceGroupResource. + /// + /// Gets a collection of ImageResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ImageResources and their operations over a ImageResource. public static ImageCollection GetImages(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetImages(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetImages(); } /// @@ -622,17 +641,21 @@ public static ImageCollection GetImages(this ResourceGroupResource resourceGroup /// Images_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the image. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetImageAsync(this ResourceGroupResource resourceGroupResource, string imageName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetImages().GetAsync(imageName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetImageAsync(imageName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -647,25 +670,35 @@ public static async Task> GetImageAsync(this ResourceGro /// Images_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the image. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetImage(this ResourceGroupResource resourceGroupResource, string imageName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetImages().Get(imageName, expand, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetImage(imageName, expand, cancellationToken); } - /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// + /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. public static VirtualMachineScaleSetCollection GetVirtualMachineScaleSets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVirtualMachineScaleSets(); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSets(); } /// @@ -680,16 +713,20 @@ public static VirtualMachineScaleSetCollection GetVirtualMachineScaleSets(this R /// VirtualMachineScaleSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineScaleSetAsync(this ResourceGroupResource resourceGroupResource, string vmScaleSetName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVirtualMachineScaleSets().GetAsync(vmScaleSetName, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSetAsync(vmScaleSetName, cancellationToken).ConfigureAwait(false); } /// @@ -704,30 +741,38 @@ public static async Task> GetVirtualMac /// VirtualMachineScaleSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineScaleSet(this ResourceGroupResource resourceGroupResource, string vmScaleSetName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVirtualMachineScaleSets().Get(vmScaleSetName, cancellationToken); + return GetMockableSampleResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSet(vmScaleSetName, cancellationToken); } - /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// The name of a supported Azure region. /// The String to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); } /// @@ -742,6 +787,10 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -749,12 +798,12 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// The String to use. /// The String to use. /// The cancellation token to use. - /// , or is an empty string, and was expected to be non-empty. /// , or is null. + /// , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineExtensionImageAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImageAsync(location, publisherName, type, version, cancellationToken).ConfigureAwait(false); } /// @@ -769,6 +818,10 @@ public static async Task> GetVirt /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -776,12 +829,12 @@ public static async Task> GetVirt /// The String to use. /// The String to use. /// The cancellation token to use. - /// , or is an empty string, and was expected to be non-empty. /// , or is null. + /// , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineExtensionImage(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImage(location, publisherName, type, version, cancellationToken); } /// @@ -796,6 +849,10 @@ public static Response GetVirtualMachineEx /// AvailabilitySets_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -803,7 +860,7 @@ public static Response GetVirtualMachineEx /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAvailabilitySetsAsync(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetAvailabilitySetsAsync(expand, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetAvailabilitySetsAsync(expand, cancellationToken); } /// @@ -818,6 +875,10 @@ public static AsyncPageable GetAvailabilitySetsAsync(th /// AvailabilitySets_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -825,7 +886,7 @@ public static AsyncPageable GetAvailabilitySetsAsync(th /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAvailabilitySets(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetAvailabilitySets(expand, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetAvailabilitySets(expand, cancellationToken); } /// @@ -840,13 +901,17 @@ public static Pageable GetAvailabilitySets(this Subscri /// ProximityPlacementGroups_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetProximityPlacementGroupsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetProximityPlacementGroupsAsync(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetProximityPlacementGroupsAsync(cancellationToken); } /// @@ -861,13 +926,17 @@ public static AsyncPageable GetProximityPlaceme /// ProximityPlacementGroups_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetProximityPlacementGroups(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetProximityPlacementGroups(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetProximityPlacementGroups(cancellationToken); } /// @@ -882,13 +951,17 @@ public static Pageable GetProximityPlacementGro /// DedicatedHostGroups_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetDedicatedHostGroupsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDedicatedHostGroupsAsync(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetDedicatedHostGroupsAsync(cancellationToken); } /// @@ -903,13 +976,17 @@ public static AsyncPageable GetDedicatedHostGroupsAs /// DedicatedHostGroups_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetDedicatedHostGroups(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDedicatedHostGroups(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetDedicatedHostGroups(cancellationToken); } /// @@ -924,13 +1001,17 @@ public static Pageable GetDedicatedHostGroups(this S /// SshPublicKeys_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetSshPublicKeysAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSshPublicKeysAsync(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetSshPublicKeysAsync(cancellationToken); } /// @@ -945,13 +1026,17 @@ public static AsyncPageable GetSshPublicKeysAsync(this Sub /// SshPublicKeys_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetSshPublicKeys(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSshPublicKeys(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetSshPublicKeys(cancellationToken); } /// @@ -966,6 +1051,10 @@ public static Pageable GetSshPublicKeys(this SubscriptionR /// VirtualMachineImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -978,12 +1067,7 @@ public static Pageable GetSshPublicKeys(this SubscriptionR /// , , or is null. public static async Task> GetVirtualMachineImageAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string offer, string skus, string version, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - Argument.AssertNotNullOrEmpty(offer, nameof(offer)); - Argument.AssertNotNullOrEmpty(skus, nameof(skus)); - Argument.AssertNotNullOrEmpty(version, nameof(version)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineImageAsync(location, publisherName, offer, skus, version, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineImageAsync(location, publisherName, offer, skus, version, cancellationToken).ConfigureAwait(false); } /// @@ -998,6 +1082,10 @@ public static async Task> GetVirtualMachineImageAs /// VirtualMachineImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1010,12 +1098,7 @@ public static async Task> GetVirtualMachineImageAs /// , , or is null. public static Response GetVirtualMachineImage(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string offer, string skus, string version, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - Argument.AssertNotNullOrEmpty(offer, nameof(offer)); - Argument.AssertNotNullOrEmpty(skus, nameof(skus)); - Argument.AssertNotNullOrEmpty(version, nameof(version)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineImage(location, publisherName, offer, skus, version, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineImage(location, publisherName, offer, skus, version, cancellationToken); } /// @@ -1030,6 +1113,10 @@ public static Response GetVirtualMachineImage(this Subscrip /// VirtualMachineImages_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. @@ -1038,9 +1125,7 @@ public static Response GetVirtualMachineImage(this Subscrip /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachineImagesAsync(this SubscriptionResource subscriptionResource, SubscriptionResourceGetVirtualMachineImagesOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineImagesAsync(options, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineImagesAsync(options, cancellationToken); } /// @@ -1055,6 +1140,10 @@ public static AsyncPageable GetVirtualMachineImages /// VirtualMachineImages_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. @@ -1063,9 +1152,7 @@ public static AsyncPageable GetVirtualMachineImages /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachineImages(this SubscriptionResource subscriptionResource, SubscriptionResourceGetVirtualMachineImagesOptions options, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(options, nameof(options)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineImages(options, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineImages(options, cancellationToken); } /// @@ -1080,6 +1167,10 @@ public static Pageable GetVirtualMachineImages(this /// VirtualMachineImages_ListOffers /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1090,9 +1181,7 @@ public static Pageable GetVirtualMachineImages(this /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetOffersVirtualMachineImagesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetOffersVirtualMachineImagesAsync(location, publisherName, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetOffersVirtualMachineImagesAsync(location, publisherName, cancellationToken); } /// @@ -1107,6 +1196,10 @@ public static AsyncPageable GetOffersVirtualMachine /// VirtualMachineImages_ListOffers /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1117,9 +1210,7 @@ public static AsyncPageable GetOffersVirtualMachine /// A collection of that may take multiple service requests to iterate over. public static Pageable GetOffersVirtualMachineImages(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetOffersVirtualMachineImages(location, publisherName, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetOffersVirtualMachineImages(location, publisherName, cancellationToken); } /// @@ -1134,6 +1225,10 @@ public static Pageable GetOffersVirtualMachineImage /// VirtualMachineImages_ListPublishers /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1141,7 +1236,7 @@ public static Pageable GetOffersVirtualMachineImage /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetPublishersVirtualMachineImagesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetPublishersVirtualMachineImagesAsync(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetPublishersVirtualMachineImagesAsync(location, cancellationToken); } /// @@ -1156,6 +1251,10 @@ public static AsyncPageable GetPublishersVirtualMac /// VirtualMachineImages_ListPublishers /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1163,7 +1262,7 @@ public static AsyncPageable GetPublishersVirtualMac /// A collection of that may take multiple service requests to iterate over. public static Pageable GetPublishersVirtualMachineImages(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetPublishersVirtualMachineImages(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetPublishersVirtualMachineImages(location, cancellationToken); } /// @@ -1178,6 +1277,10 @@ public static Pageable GetPublishersVirtualMachineI /// VirtualMachineImages_ListSkus /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1189,10 +1292,7 @@ public static Pageable GetPublishersVirtualMachineI /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetSkusVirtualMachineImagesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string offer, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - Argument.AssertNotNullOrEmpty(offer, nameof(offer)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSkusVirtualMachineImagesAsync(location, publisherName, offer, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetSkusVirtualMachineImagesAsync(location, publisherName, offer, cancellationToken); } /// @@ -1207,6 +1307,10 @@ public static AsyncPageable GetSkusVirtualMachineIm /// VirtualMachineImages_ListSkus /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -1218,10 +1322,7 @@ public static AsyncPageable GetSkusVirtualMachineIm /// A collection of that may take multiple service requests to iterate over. public static Pageable GetSkusVirtualMachineImages(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string offer, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - Argument.AssertNotNullOrEmpty(offer, nameof(offer)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSkusVirtualMachineImages(location, publisherName, offer, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetSkusVirtualMachineImages(location, publisherName, offer, cancellationToken); } /// @@ -1236,6 +1337,10 @@ public static Pageable GetSkusVirtualMachineImages( /// Usage_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which resource usage is queried. @@ -1243,7 +1348,7 @@ public static Pageable GetSkusVirtualMachineImages( /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetUsagesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetUsagesAsync(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetUsagesAsync(location, cancellationToken); } /// @@ -1258,6 +1363,10 @@ public static AsyncPageable GetUsagesAsync(this SubscriptionResourc /// Usage_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which resource usage is queried. @@ -1265,7 +1374,7 @@ public static AsyncPageable GetUsagesAsync(this SubscriptionResourc /// A collection of that may take multiple service requests to iterate over. public static Pageable GetUsages(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetUsages(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetUsages(location, cancellationToken); } /// @@ -1280,6 +1389,10 @@ public static Pageable GetUsages(this SubscriptionResource subscrip /// VirtualMachines_ListByLocation /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1287,7 +1400,7 @@ public static Pageable GetUsages(this SubscriptionResource subscrip /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachinesByLocationAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachinesByLocationAsync(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachinesByLocationAsync(location, cancellationToken); } /// @@ -1302,6 +1415,10 @@ public static AsyncPageable GetVirtualMachinesByLocation /// VirtualMachines_ListByLocation /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1309,7 +1426,7 @@ public static AsyncPageable GetVirtualMachinesByLocation /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachinesByLocation(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachinesByLocation(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachinesByLocation(location, cancellationToken); } /// @@ -1324,6 +1441,10 @@ public static Pageable GetVirtualMachinesByLocation(this /// VirtualMachines_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. @@ -1331,7 +1452,7 @@ public static Pageable GetVirtualMachinesByLocation(this /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachinesAsync(this SubscriptionResource subscriptionResource, string statusOnly = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachinesAsync(statusOnly, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachinesAsync(statusOnly, cancellationToken); } /// @@ -1346,6 +1467,10 @@ public static AsyncPageable GetVirtualMachinesAsync(this /// VirtualMachines_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. @@ -1353,7 +1478,7 @@ public static AsyncPageable GetVirtualMachinesAsync(this /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachines(this SubscriptionResource subscriptionResource, string statusOnly = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachines(statusOnly, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachines(statusOnly, cancellationToken); } /// @@ -1368,6 +1493,10 @@ public static Pageable GetVirtualMachines(this Subscript /// VirtualMachineSizes_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location upon which virtual-machine-sizes is queried. @@ -1375,7 +1504,7 @@ public static Pageable GetVirtualMachines(this Subscript /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachineSizesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineSizesAsync(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineSizesAsync(location, cancellationToken); } /// @@ -1390,6 +1519,10 @@ public static AsyncPageable GetVirtualMachineSizesAsync(this /// VirtualMachineSizes_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location upon which virtual-machine-sizes is queried. @@ -1397,7 +1530,7 @@ public static AsyncPageable GetVirtualMachineSizesAsync(this /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachineSizes(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineSizes(location, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineSizes(location, cancellationToken); } /// @@ -1412,13 +1545,17 @@ public static Pageable GetVirtualMachineSizes(this Subscript /// Images_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetImagesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetImagesAsync(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetImagesAsync(cancellationToken); } /// @@ -1433,13 +1570,17 @@ public static AsyncPageable GetImagesAsync(this SubscriptionResou /// Images_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetImages(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetImages(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetImages(cancellationToken); } /// @@ -1454,13 +1595,17 @@ public static Pageable GetImages(this SubscriptionResource subscr /// VirtualMachineScaleSets_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachineScaleSetsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineScaleSetsAsync(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineScaleSetsAsync(cancellationToken); } /// @@ -1475,13 +1620,17 @@ public static AsyncPageable GetVirtualMachineSca /// VirtualMachineScaleSets_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachineScaleSets(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineScaleSets(cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).GetVirtualMachineScaleSets(cancellationToken); } /// @@ -1496,6 +1645,10 @@ public static Pageable GetVirtualMachineScaleSet /// LogAnalytics_ExportRequestRateByInterval /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -1505,9 +1658,7 @@ public static Pageable GetVirtualMachineScaleSet /// is null. public static async Task> ExportRequestRateByIntervalLogAnalyticAsync(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).ExportRequestRateByIntervalLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleSubscriptionResource(subscriptionResource).ExportRequestRateByIntervalLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); } /// @@ -1522,6 +1673,10 @@ public static async Task> ExportRequestRateByInterval /// LogAnalytics_ExportRequestRateByInterval /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -1531,9 +1686,7 @@ public static async Task> ExportRequestRateByInterval /// is null. public static ArmOperation ExportRequestRateByIntervalLogAnalytic(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).ExportRequestRateByIntervalLogAnalytic(waitUntil, location, content, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).ExportRequestRateByIntervalLogAnalytic(waitUntil, location, content, cancellationToken); } /// @@ -1548,6 +1701,10 @@ public static ArmOperation ExportRequestRateByIntervalLogAnalytic( /// LogAnalytics_ExportThrottledRequests /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -1557,9 +1714,7 @@ public static ArmOperation ExportRequestRateByIntervalLogAnalytic( /// is null. public static async Task> ExportThrottledRequestsLogAnalyticAsync(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).ExportThrottledRequestsLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); + return await GetMockableSampleSubscriptionResource(subscriptionResource).ExportThrottledRequestsLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); } /// @@ -1574,6 +1729,10 @@ public static async Task> ExportThrottledRequestsLogA /// LogAnalytics_ExportThrottledRequests /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -1583,9 +1742,7 @@ public static async Task> ExportThrottledRequestsLogA /// is null. public static ArmOperation ExportThrottledRequestsLogAnalytic(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).ExportThrottledRequestsLogAnalytic(waitUntil, location, content, cancellationToken); + return GetMockableSampleSubscriptionResource(subscriptionResource).ExportThrottledRequestsLogAnalytic(waitUntil, location, content, cancellationToken); } } } diff --git a/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineResource.cs b/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineResource.cs index ea262b19c4d..2106d063abe 100644 --- a/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineResource.cs +++ b/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineResource.cs @@ -97,7 +97,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of VirtualMachineExtensionResources and their operations over a VirtualMachineExtensionResource. public virtual VirtualMachineExtensionCollection GetVirtualMachineExtensions() { - return GetCachedClient(Client => new VirtualMachineExtensionCollection(Client, Id)); + return GetCachedClient(client => new VirtualMachineExtensionCollection(client, Id)); } /// @@ -116,8 +116,8 @@ public virtual VirtualMachineExtensionCollection GetVirtualMachineExtensions() /// The name of the virtual machine extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetVirtualMachineExtensionAsync(string vmExtensionName, string expand = null, CancellationToken cancellationToken = default) { @@ -140,8 +140,8 @@ public virtual async Task> GetVirtualM /// The name of the virtual machine extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetVirtualMachineExtension(string vmExtensionName, string expand = null, CancellationToken cancellationToken = default) { diff --git a/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetResource.cs b/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetResource.cs index 443ff317fa1..40d423fa03f 100644 --- a/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetResource.cs +++ b/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetResource.cs @@ -102,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of VirtualMachineScaleSetExtensionResources and their operations over a VirtualMachineScaleSetExtensionResource. public virtual VirtualMachineScaleSetExtensionCollection GetVirtualMachineScaleSetExtensions() { - return GetCachedClient(Client => new VirtualMachineScaleSetExtensionCollection(Client, Id)); + return GetCachedClient(client => new VirtualMachineScaleSetExtensionCollection(client, Id)); } /// @@ -121,8 +121,8 @@ public virtual VirtualMachineScaleSetExtensionCollection GetVirtualMachineScaleS /// The name of the VM scale set extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetVirtualMachineScaleSetExtensionAsync(string vmssExtensionName, string expand = null, CancellationToken cancellationToken = default) { @@ -145,8 +145,8 @@ public virtual async Task> Get /// The name of the VM scale set extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetVirtualMachineScaleSetExtension(string vmssExtensionName, string expand = null, CancellationToken cancellationToken = default) { @@ -164,7 +164,7 @@ public virtual VirtualMachineScaleSetRollingUpgradeResource GetVirtualMachineSca /// An object representing collection of VirtualMachineScaleSetVmResources and their operations over a VirtualMachineScaleSetVmResource. public virtual VirtualMachineScaleSetVmCollection GetVirtualMachineScaleSetVms() { - return GetCachedClient(Client => new VirtualMachineScaleSetVmCollection(Client, Id)); + return GetCachedClient(client => new VirtualMachineScaleSetVmCollection(client, Id)); } /// @@ -183,8 +183,8 @@ public virtual VirtualMachineScaleSetVmCollection GetVirtualMachineScaleSetVms() /// The instance ID of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetVirtualMachineScaleSetVmAsync(string instanceId, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { @@ -207,8 +207,8 @@ public virtual async Task> GetVirtual /// The instance ID of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetVirtualMachineScaleSetVm(string instanceId, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { diff --git a/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetVmResource.cs b/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetVmResource.cs index b7e5086e8a4..20e2c47c6a0 100644 --- a/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetVmResource.cs +++ b/samples/Azure.ResourceManager.Sample/Generated/VirtualMachineScaleSetVmResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of VirtualMachineScaleSetVirtualMachineExtensionResources and their operations over a VirtualMachineScaleSetVirtualMachineExtensionResource. public virtual VirtualMachineScaleSetVirtualMachineExtensionCollection GetVirtualMachineScaleSetVirtualMachineExtensions() { - return GetCachedClient(Client => new VirtualMachineScaleSetVirtualMachineExtensionCollection(Client, Id)); + return GetCachedClient(client => new VirtualMachineScaleSetVirtualMachineExtensionCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual VirtualMachineScaleSetVirtualMachineExtensionCollection GetVirtua /// The name of the virtual machine extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetVirtualMachineScaleSetVirtualMachineExtensionAsync(string vmExtensionName, string expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task The name of the virtual machine extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetVirtualMachineScaleSetVirtualMachineExtension(string vmExtensionName, string expand = null, CancellationToken cancellationToken = default) { diff --git a/samples/Azure.ResourceManager.Storage/Generated/BlobServiceResource.cs b/samples/Azure.ResourceManager.Storage/Generated/BlobServiceResource.cs index bdddb8932a8..85119b48ec3 100644 --- a/samples/Azure.ResourceManager.Storage/Generated/BlobServiceResource.cs +++ b/samples/Azure.ResourceManager.Storage/Generated/BlobServiceResource.cs @@ -93,7 +93,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of BlobContainerResources and their operations over a BlobContainerResource. public virtual BlobContainerCollection GetBlobContainers() { - return GetCachedClient(Client => new BlobContainerCollection(Client, Id)); + return GetCachedClient(client => new BlobContainerCollection(client, Id)); } /// @@ -111,8 +111,8 @@ public virtual BlobContainerCollection GetBlobContainers() /// /// The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetBlobContainerAsync(string containerName, CancellationToken cancellationToken = default) { @@ -134,8 +134,8 @@ public virtual async Task> GetBlobContainerAsync /// /// The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetBlobContainer(string containerName, CancellationToken cancellationToken = default) { diff --git a/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageArmClient.cs b/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageArmClient.cs new file mode 100644 index 00000000000..9497463532e --- /dev/null +++ b/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageArmClient.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Storage; + +namespace Azure.ResourceManager.Storage.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableStorageArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableStorageArmClient() + { + } + + /// 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 MockableStorageArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableStorageArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 BlobServiceResource GetBlobServiceResource(ResourceIdentifier id) + { + BlobServiceResource.ValidateResourceId(id); + return new BlobServiceResource(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 BlobContainerResource GetBlobContainerResource(ResourceIdentifier id) + { + BlobContainerResource.ValidateResourceId(id); + return new BlobContainerResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ImmutabilityPolicyResource GetImmutabilityPolicyResource(ResourceIdentifier id) + { + ImmutabilityPolicyResource.ValidateResourceId(id); + return new ImmutabilityPolicyResource(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 FileServiceResource GetFileServiceResource(ResourceIdentifier id) + { + FileServiceResource.ValidateResourceId(id); + return new FileServiceResource(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 FileShareResource GetFileShareResource(ResourceIdentifier id) + { + FileShareResource.ValidateResourceId(id); + return new FileShareResource(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 StorageAccountResource GetStorageAccountResource(ResourceIdentifier id) + { + StorageAccountResource.ValidateResourceId(id); + return new StorageAccountResource(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 DeletedAccountResource GetDeletedAccountResource(ResourceIdentifier id) + { + DeletedAccountResource.ValidateResourceId(id); + return new DeletedAccountResource(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 ManagementPolicyResource GetManagementPolicyResource(ResourceIdentifier id) + { + ManagementPolicyResource.ValidateResourceId(id); + return new ManagementPolicyResource(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 BlobInventoryPolicyResource GetBlobInventoryPolicyResource(ResourceIdentifier id) + { + BlobInventoryPolicyResource.ValidateResourceId(id); + return new BlobInventoryPolicyResource(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 StoragePrivateEndpointConnectionResource GetStoragePrivateEndpointConnectionResource(ResourceIdentifier id) + { + StoragePrivateEndpointConnectionResource.ValidateResourceId(id); + return new StoragePrivateEndpointConnectionResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ObjectReplicationPolicyResource GetObjectReplicationPolicyResource(ResourceIdentifier id) + { + ObjectReplicationPolicyResource.ValidateResourceId(id); + return new ObjectReplicationPolicyResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual EncryptionScopeResource GetEncryptionScopeResource(ResourceIdentifier id) + { + EncryptionScopeResource.ValidateResourceId(id); + return new EncryptionScopeResource(Client, id); + } + } +} diff --git a/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageResourceGroupResource.cs b/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageResourceGroupResource.cs new file mode 100644 index 00000000000..b68017e2f5c --- /dev/null +++ b/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageResourceGroupResource.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Storage; +using Azure.ResourceManager.Storage.Models; + +namespace Azure.ResourceManager.Storage.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableStorageResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableStorageResourceGroupResource() + { + } + + /// 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 MockableStorageResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of StorageAccountResources in the ResourceGroupResource. + /// An object representing collection of StorageAccountResources and their operations over a StorageAccountResource. + public virtual StorageAccountCollection GetStorageAccounts() + { + return GetCachedClient(client => new StorageAccountCollection(client, Id)); + } + + /// + /// Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName} + /// + /// + /// Operation Id + /// StorageAccounts_GetProperties + /// + /// + /// + /// The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + /// May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats and blobRestoreStatus. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetStorageAccountAsync(string accountName, StorageAccountExpand? expand = null, CancellationToken cancellationToken = default) + { + return await GetStorageAccounts().GetAsync(accountName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName} + /// + /// + /// Operation Id + /// StorageAccounts_GetProperties + /// + /// + /// + /// The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. + /// May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats and blobRestoreStatus. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetStorageAccount(string accountName, StorageAccountExpand? expand = null, CancellationToken cancellationToken = default) + { + return GetStorageAccounts().Get(accountName, expand, cancellationToken); + } + } +} diff --git a/samples/Azure.ResourceManager.Storage/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageSubscriptionResource.cs similarity index 72% rename from samples/Azure.ResourceManager.Storage/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageSubscriptionResource.cs index 9ea12adda55..de2b2379cca 100644 --- a/samples/Azure.ResourceManager.Storage/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/samples/Azure.ResourceManager.Storage/Generated/Extensions/MockableStorageSubscriptionResource.cs @@ -5,18 +5,21 @@ #nullable disable +using System; using System.Threading; +using System.Threading.Tasks; using Autorest.CSharp.Core; using Azure; using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using Azure.ResourceManager.Storage; using Azure.ResourceManager.Storage.Models; -namespace Azure.ResourceManager.Storage +namespace Azure.ResourceManager.Storage.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableStorageSubscriptionResource : ArmResource { private ClientDiagnostics _skusClientDiagnostics; private SkusRestOperations _skusRestClient; @@ -25,15 +28,15 @@ internal partial class SubscriptionResourceExtensionClient : ArmResource private ClientDiagnostics _usagesClientDiagnostics; private UsagesRestOperations _usagesRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableStorageSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableStorageSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -54,7 +57,55 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of DeletedAccountResources and their operations over a DeletedAccountResource. public virtual DeletedAccountCollection GetDeletedAccounts() { - return GetCachedClient(Client => new DeletedAccountCollection(Client, Id)); + return GetCachedClient(client => new DeletedAccountCollection(client, Id)); + } + + /// + /// Get properties of specified deleted account resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName} + /// + /// + /// Operation Id + /// DeletedAccounts_Get + /// + /// + /// + /// The location of the deleted storage account. + /// Name of the deleted storage account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeletedAccountAsync(AzureLocation location, string deletedAccountName, CancellationToken cancellationToken = default) + { + return await GetDeletedAccounts().GetAsync(location, deletedAccountName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get properties of specified deleted account resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName} + /// + /// + /// Operation Id + /// DeletedAccounts_Get + /// + /// + /// + /// The location of the deleted storage account. + /// Name of the deleted storage account. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeletedAccount(AzureLocation location, string deletedAccountName, CancellationToken cancellationToken = default) + { + return GetDeletedAccounts().Get(location, deletedAccountName, cancellationToken); } /// @@ -75,7 +126,7 @@ public virtual DeletedAccountCollection GetDeletedAccounts() public virtual AsyncPageable GetSkusAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => SkusRestClient.CreateListRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, StorageSkuInformation.DeserializeStorageSkuInformation, SkusClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetSkus", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, StorageSkuInformation.DeserializeStorageSkuInformation, SkusClientDiagnostics, Pipeline, "MockableStorageSubscriptionResource.GetSkus", "value", null, cancellationToken); } /// @@ -96,7 +147,7 @@ public virtual AsyncPageable GetSkusAsync(CancellationTok public virtual Pageable GetSkus(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => SkusRestClient.CreateListRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, StorageSkuInformation.DeserializeStorageSkuInformation, SkusClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetSkus", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, StorageSkuInformation.DeserializeStorageSkuInformation, SkusClientDiagnostics, Pipeline, "MockableStorageSubscriptionResource.GetSkus", "value", null, cancellationToken); } /// @@ -118,7 +169,7 @@ public virtual AsyncPageable GetStorageAccountsAsync(Can { HttpMessage FirstPageRequest(int? pageSizeHint) => StorageAccountRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => StorageAccountRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new StorageAccountResource(Client, StorageAccountData.DeserializeStorageAccountData(e)), StorageAccountClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetStorageAccounts", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new StorageAccountResource(Client, StorageAccountData.DeserializeStorageAccountData(e)), StorageAccountClientDiagnostics, Pipeline, "MockableStorageSubscriptionResource.GetStorageAccounts", "value", "nextLink", cancellationToken); } /// @@ -140,7 +191,7 @@ public virtual Pageable GetStorageAccounts(CancellationT { HttpMessage FirstPageRequest(int? pageSizeHint) => StorageAccountRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => StorageAccountRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new StorageAccountResource(Client, StorageAccountData.DeserializeStorageAccountData(e)), StorageAccountClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetStorageAccounts", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new StorageAccountResource(Client, StorageAccountData.DeserializeStorageAccountData(e)), StorageAccountClientDiagnostics, Pipeline, "MockableStorageSubscriptionResource.GetStorageAccounts", "value", "nextLink", cancellationToken); } /// @@ -162,7 +213,7 @@ public virtual Pageable GetStorageAccounts(CancellationT public virtual AsyncPageable GetUsagesByLocationAsync(AzureLocation location, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => UsagesRestClient.CreateListByLocationRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, StorageUsage.DeserializeStorageUsage, UsagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetUsagesByLocation", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, StorageUsage.DeserializeStorageUsage, UsagesClientDiagnostics, Pipeline, "MockableStorageSubscriptionResource.GetUsagesByLocation", "value", null, cancellationToken); } /// @@ -184,7 +235,7 @@ public virtual AsyncPageable GetUsagesByLocationAsync(AzureLocatio public virtual Pageable GetUsagesByLocation(AzureLocation location, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => UsagesRestClient.CreateListByLocationRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, StorageUsage.DeserializeStorageUsage, UsagesClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetUsagesByLocation", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, StorageUsage.DeserializeStorageUsage, UsagesClientDiagnostics, Pipeline, "MockableStorageSubscriptionResource.GetUsagesByLocation", "value", null, cancellationToken); } } } diff --git a/samples/Azure.ResourceManager.Storage/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/samples/Azure.ResourceManager.Storage/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 5283e341415..00000000000 --- a/samples/Azure.ResourceManager.Storage/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace Azure.ResourceManager.Storage -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of StorageAccountResources in the ResourceGroupResource. - /// An object representing collection of StorageAccountResources and their operations over a StorageAccountResource. - public virtual StorageAccountCollection GetStorageAccounts() - { - return GetCachedClient(Client => new StorageAccountCollection(Client, Id)); - } - } -} diff --git a/samples/Azure.ResourceManager.Storage/Generated/Extensions/StorageExtensions.cs b/samples/Azure.ResourceManager.Storage/Generated/Extensions/StorageExtensions.cs index 455c578a0e4..7e710da0f03 100644 --- a/samples/Azure.ResourceManager.Storage/Generated/Extensions/StorageExtensions.cs +++ b/samples/Azure.ResourceManager.Storage/Generated/Extensions/StorageExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Storage.Mocking; using Azure.ResourceManager.Storage.Models; namespace Azure.ResourceManager.Storage @@ -19,271 +20,225 @@ namespace Azure.ResourceManager.Storage /// A class to add extension methods to Azure.ResourceManager.Storage. public static partial class StorageExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableStorageArmClient GetMockableStorageArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableStorageArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableStorageResourceGroupResource GetMockableStorageResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableStorageResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableStorageSubscriptionResource GetMockableStorageSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableStorageSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region BlobServiceResource /// /// 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. /// Returns a object. public static BlobServiceResource GetBlobServiceResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BlobServiceResource.ValidateResourceId(id); - return new BlobServiceResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetBlobServiceResource(id); } - #endregion - #region BlobContainerResource /// /// 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. /// Returns a object. public static BlobContainerResource GetBlobContainerResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BlobContainerResource.ValidateResourceId(id); - return new BlobContainerResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetBlobContainerResource(id); } - #endregion - #region ImmutabilityPolicyResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static ImmutabilityPolicyResource GetImmutabilityPolicyResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ImmutabilityPolicyResource.ValidateResourceId(id); - return new ImmutabilityPolicyResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetImmutabilityPolicyResource(id); } - #endregion - #region FileServiceResource /// /// 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. /// Returns a object. public static FileServiceResource GetFileServiceResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FileServiceResource.ValidateResourceId(id); - return new FileServiceResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetFileServiceResource(id); } - #endregion - #region FileShareResource /// /// 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. /// Returns a object. public static FileShareResource GetFileShareResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FileShareResource.ValidateResourceId(id); - return new FileShareResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetFileShareResource(id); } - #endregion - #region StorageAccountResource /// /// 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. /// Returns a object. public static StorageAccountResource GetStorageAccountResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - StorageAccountResource.ValidateResourceId(id); - return new StorageAccountResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetStorageAccountResource(id); } - #endregion - #region DeletedAccountResource /// /// 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. /// Returns a object. public static DeletedAccountResource GetDeletedAccountResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DeletedAccountResource.ValidateResourceId(id); - return new DeletedAccountResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetDeletedAccountResource(id); } - #endregion - #region ManagementPolicyResource /// /// 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. /// Returns a object. public static ManagementPolicyResource GetManagementPolicyResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ManagementPolicyResource.ValidateResourceId(id); - return new ManagementPolicyResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetManagementPolicyResource(id); } - #endregion - #region BlobInventoryPolicyResource /// /// 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. /// Returns a object. public static BlobInventoryPolicyResource GetBlobInventoryPolicyResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BlobInventoryPolicyResource.ValidateResourceId(id); - return new BlobInventoryPolicyResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetBlobInventoryPolicyResource(id); } - #endregion - #region StoragePrivateEndpointConnectionResource /// /// 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. /// Returns a object. public static StoragePrivateEndpointConnectionResource GetStoragePrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - StoragePrivateEndpointConnectionResource.ValidateResourceId(id); - return new StoragePrivateEndpointConnectionResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetStoragePrivateEndpointConnectionResource(id); } - #endregion - #region ObjectReplicationPolicyResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static ObjectReplicationPolicyResource GetObjectReplicationPolicyResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ObjectReplicationPolicyResource.ValidateResourceId(id); - return new ObjectReplicationPolicyResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetObjectReplicationPolicyResource(id); } - #endregion - #region EncryptionScopeResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static EncryptionScopeResource GetEncryptionScopeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - EncryptionScopeResource.ValidateResourceId(id); - return new EncryptionScopeResource(client, id); - } - ); + return GetMockableStorageArmClient(client).GetEncryptionScopeResource(id); } - #endregion - /// Gets a collection of StorageAccountResources in the ResourceGroupResource. + /// + /// Gets a collection of StorageAccountResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of StorageAccountResources and their operations over a StorageAccountResource. public static StorageAccountCollection GetStorageAccounts(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetStorageAccounts(); + return GetMockableStorageResourceGroupResource(resourceGroupResource).GetStorageAccounts(); } /// @@ -298,17 +253,21 @@ public static StorageAccountCollection GetStorageAccounts(this ResourceGroupReso /// StorageAccounts_GetProperties /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. /// May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats and blobRestoreStatus. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetStorageAccountAsync(this ResourceGroupResource resourceGroupResource, string accountName, StorageAccountExpand? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetStorageAccounts().GetAsync(accountName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableStorageResourceGroupResource(resourceGroupResource).GetStorageAccountAsync(accountName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -323,25 +282,35 @@ public static async Task> GetStorageAccountAsyn /// StorageAccounts_GetProperties /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. /// May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats and blobRestoreStatus. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetStorageAccount(this ResourceGroupResource resourceGroupResource, string accountName, StorageAccountExpand? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetStorageAccounts().Get(accountName, expand, cancellationToken); + return GetMockableStorageResourceGroupResource(resourceGroupResource).GetStorageAccount(accountName, expand, cancellationToken); } - /// Gets a collection of DeletedAccountResources in the SubscriptionResource. + /// + /// Gets a collection of DeletedAccountResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeletedAccountResources and their operations over a DeletedAccountResource. public static DeletedAccountCollection GetDeletedAccounts(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedAccounts(); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetDeletedAccounts(); } /// @@ -356,17 +325,21 @@ public static DeletedAccountCollection GetDeletedAccounts(this SubscriptionResou /// DeletedAccounts_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the deleted storage account. /// Name of the deleted storage account. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeletedAccountAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string deletedAccountName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetDeletedAccounts().GetAsync(location, deletedAccountName, cancellationToken).ConfigureAwait(false); + return await GetMockableStorageSubscriptionResource(subscriptionResource).GetDeletedAccountAsync(location, deletedAccountName, cancellationToken).ConfigureAwait(false); } /// @@ -381,17 +354,21 @@ public static async Task> GetDeletedAccountAsyn /// DeletedAccounts_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the deleted storage account. /// Name of the deleted storage account. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeletedAccount(this SubscriptionResource subscriptionResource, AzureLocation location, string deletedAccountName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetDeletedAccounts().Get(location, deletedAccountName, cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetDeletedAccount(location, deletedAccountName, cancellationToken); } /// @@ -406,13 +383,17 @@ public static Response GetDeletedAccount(this Subscripti /// Skus_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetSkusAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSkusAsync(cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetSkusAsync(cancellationToken); } /// @@ -427,13 +408,17 @@ public static AsyncPageable GetSkusAsync(this Subscriptio /// Skus_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetSkus(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSkus(cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetSkus(cancellationToken); } /// @@ -448,13 +433,17 @@ public static Pageable GetSkus(this SubscriptionResource /// StorageAccounts_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetStorageAccountsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetStorageAccountsAsync(cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetStorageAccountsAsync(cancellationToken); } /// @@ -469,13 +458,17 @@ public static AsyncPageable GetStorageAccountsAsync(this /// StorageAccounts_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetStorageAccounts(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetStorageAccounts(cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetStorageAccounts(cancellationToken); } /// @@ -490,6 +483,10 @@ public static Pageable GetStorageAccounts(this Subscript /// Usages_ListByLocation /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the Azure Storage resource. @@ -497,7 +494,7 @@ public static Pageable GetStorageAccounts(this Subscript /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetUsagesByLocationAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetUsagesByLocationAsync(location, cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetUsagesByLocationAsync(location, cancellationToken); } /// @@ -512,6 +509,10 @@ public static AsyncPageable GetUsagesByLocationAsync(this Subscrip /// Usages_ListByLocation /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the Azure Storage resource. @@ -519,7 +520,7 @@ public static AsyncPageable GetUsagesByLocationAsync(this Subscrip /// A collection of that may take multiple service requests to iterate over. public static Pageable GetUsagesByLocation(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetUsagesByLocation(location, cancellationToken); + return GetMockableStorageSubscriptionResource(subscriptionResource).GetUsagesByLocation(location, cancellationToken); } } } diff --git a/samples/Azure.ResourceManager.Storage/Generated/FileServiceResource.cs b/samples/Azure.ResourceManager.Storage/Generated/FileServiceResource.cs index 19da03b329c..43b229dca5e 100644 --- a/samples/Azure.ResourceManager.Storage/Generated/FileServiceResource.cs +++ b/samples/Azure.ResourceManager.Storage/Generated/FileServiceResource.cs @@ -93,7 +93,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of FileShareResources and their operations over a FileShareResource. public virtual FileShareCollection GetFileShares() { - return GetCachedClient(Client => new FileShareCollection(Client, Id)); + return GetCachedClient(client => new FileShareCollection(client, Id)); } /// @@ -113,8 +113,8 @@ public virtual FileShareCollection GetFileShares() /// Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. /// Optional, used to retrieve properties of a snapshot. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFileShareAsync(string shareName, string expand = null, string xMsSnapshot = null, CancellationToken cancellationToken = default) { @@ -138,8 +138,8 @@ public virtual async Task> GetFileShareAsync(string /// Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. /// Optional, used to retrieve properties of a snapshot. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFileShare(string shareName, string expand = null, string xMsSnapshot = null, CancellationToken cancellationToken = default) { diff --git a/samples/Azure.ResourceManager.Storage/Generated/StorageAccountResource.cs b/samples/Azure.ResourceManager.Storage/Generated/StorageAccountResource.cs index 18f332e26d2..492967c4f96 100644 --- a/samples/Azure.ResourceManager.Storage/Generated/StorageAccountResource.cs +++ b/samples/Azure.ResourceManager.Storage/Generated/StorageAccountResource.cs @@ -122,7 +122,7 @@ public virtual ManagementPolicyResource GetManagementPolicy() /// An object representing collection of BlobInventoryPolicyResources and their operations over a BlobInventoryPolicyResource. public virtual BlobInventoryPolicyCollection GetBlobInventoryPolicies() { - return GetCachedClient(Client => new BlobInventoryPolicyCollection(Client, Id)); + return GetCachedClient(client => new BlobInventoryPolicyCollection(client, Id)); } /// @@ -171,7 +171,7 @@ public virtual Response GetBlobInventoryPolicy(Blob /// An object representing collection of StoragePrivateEndpointConnectionResources and their operations over a StoragePrivateEndpointConnectionResource. public virtual StoragePrivateEndpointConnectionCollection GetStoragePrivateEndpointConnections() { - return GetCachedClient(Client => new StoragePrivateEndpointConnectionCollection(Client, Id)); + return GetCachedClient(client => new StoragePrivateEndpointConnectionCollection(client, Id)); } /// @@ -189,8 +189,8 @@ public virtual StoragePrivateEndpointConnectionCollection GetStoragePrivateEndpo /// /// The name of the private endpoint connection associated with the Azure resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetStoragePrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) { @@ -212,8 +212,8 @@ public virtual async Task> Ge /// /// The name of the private endpoint connection associated with the Azure resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetStoragePrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) { @@ -224,7 +224,7 @@ public virtual Response GetStoragePriv /// An object representing collection of ObjectReplicationPolicyResources and their operations over a ObjectReplicationPolicyResource. public virtual ObjectReplicationPolicyCollection GetObjectReplicationPolicies() { - return GetCachedClient(Client => new ObjectReplicationPolicyCollection(Client, Id)); + return GetCachedClient(client => new ObjectReplicationPolicyCollection(client, Id)); } /// @@ -242,8 +242,8 @@ public virtual ObjectReplicationPolicyCollection GetObjectReplicationPolicies() /// /// For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetObjectReplicationPolicyAsync(string objectReplicationPolicyId, CancellationToken cancellationToken = default) { @@ -265,8 +265,8 @@ public virtual async Task> GetObjectRe /// /// For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the destination account. The policy is downloaded as a JSON file. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetObjectReplicationPolicy(string objectReplicationPolicyId, CancellationToken cancellationToken = default) { @@ -277,7 +277,7 @@ public virtual Response GetObjectReplicationPol /// An object representing collection of EncryptionScopeResources and their operations over a EncryptionScopeResource. public virtual EncryptionScopeCollection GetEncryptionScopes() { - return GetCachedClient(Client => new EncryptionScopeCollection(Client, Id)); + return GetCachedClient(client => new EncryptionScopeCollection(client, Id)); } /// @@ -295,8 +295,8 @@ public virtual EncryptionScopeCollection GetEncryptionScopes() /// /// The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetEncryptionScopeAsync(string encryptionScopeName, CancellationToken cancellationToken = default) { @@ -318,8 +318,8 @@ public virtual async Task> GetEncryptionScopeA /// /// The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetEncryptionScope(string encryptionScopeName, CancellationToken cancellationToken = default) { diff --git a/src/AutoRest.CSharp/Common/Generation/Writers/CodeWriterExtensions.cs b/src/AutoRest.CSharp/Common/Generation/Writers/CodeWriterExtensions.cs index a08ddbfbbbf..9b985fa4dc3 100644 --- a/src/AutoRest.CSharp/Common/Generation/Writers/CodeWriterExtensions.cs +++ b/src/AutoRest.CSharp/Common/Generation/Writers/CodeWriterExtensions.cs @@ -628,10 +628,10 @@ public static IDisposable WriteCommonMethodWithoutValidation(this CodeWriter wri return writer.WriteMethodDeclaration(signature.WithAsync(isAsync)); } - public static IDisposable WriteCommonMethod(this CodeWriter writer, MethodSignature signature, FormattableString? returnDescription, bool isAsync, bool isPublicType) + public static IDisposable WriteCommonMethod(this CodeWriter writer, MethodSignature signature, FormattableString? returnDescription, bool isAsync, bool isPublicType, bool skipValidation = false) { var scope = WriteCommonMethodWithoutValidation(writer, signature, returnDescription, isAsync, isPublicType); - if (isPublicType) + if (isPublicType && !skipValidation) writer.WriteParametersValidation(signature.Parameters); return scope; diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/BoolExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/BoolExpression.cs index b667c35e89d..e9cc9c1dc8f 100644 --- a/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/BoolExpression.cs +++ b/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/BoolExpression.cs @@ -7,5 +7,10 @@ namespace AutoRest.CSharp.Common.Output.Expressions.KnownValueExpressions { internal sealed record BoolExpression(ValueExpression Untyped) : TypedValueExpression(Untyped) { + public BoolExpression Not() => new(new UnaryOperatorExpression("!", this, false)); + + public BoolExpression Or(ValueExpression other) => new(new BinaryOperatorExpression(" || ", this, other)); + + public BoolExpression And(ValueExpression other) => new(new BinaryOperatorExpression(" && ", this, other)); } } diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/InvokeInstanceMethodExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/InvokeInstanceMethodExpression.cs index 1a2d54b6d3d..b5e7d88ab89 100644 --- a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/InvokeInstanceMethodExpression.cs +++ b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/InvokeInstanceMethodExpression.cs @@ -2,10 +2,17 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Linq; using AutoRest.CSharp.Generation.Types; +using AutoRest.CSharp.Output.Models; namespace AutoRest.CSharp.Common.Output.Expressions.ValueExpressions { // [TODO]: AddConfigureAwaitFalse is needed only in docs. Consider removing. - internal record InvokeInstanceMethodExpression(ValueExpression? InstanceReference, string MethodName, IReadOnlyList Arguments, IReadOnlyList? TypeArguments, bool CallAsAsync, bool AddConfigureAwaitFalse = true) : ValueExpression; + internal record InvokeInstanceMethodExpression(ValueExpression? InstanceReference, string MethodName, IReadOnlyList Arguments, IReadOnlyList? TypeArguments, bool CallAsAsync, bool AddConfigureAwaitFalse = true) : ValueExpression + { + public InvokeInstanceMethodExpression(ValueExpression? instanceReference, MethodSignature signature, IReadOnlyList arguments, bool addConfigureAwaitFalse = true) : this(instanceReference, signature.Name, arguments, signature.GenericArguments, signature.Modifiers.HasFlag(MethodSignatureModifiers.Async), addConfigureAwaitFalse) { } + + public InvokeInstanceMethodExpression(ValueExpression? instanceReference, MethodSignature signature, bool addConfigureAwaitFalse = true) : this(instanceReference, signature, signature.Parameters.Select(p => (ValueExpression)p).ToArray(), addConfigureAwaitFalse) { } + } } diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/ValueExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/ValueExpression.cs index 410aace5651..7e2e913242f 100644 --- a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/ValueExpression.cs +++ b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/ValueExpression.cs @@ -24,6 +24,8 @@ internal record ValueExpression public ValueExpression NullableStructValue(CSharpType candidateType) => this is not ConstantExpression && candidateType is { IsNullable: true, IsValueType: true } ? new MemberExpression(this, nameof(Nullable.Value)) : this; public StringExpression InvokeToString() => new(Invoke(nameof(ToString))); + public BoolExpression InvokeEquals(ValueExpression other) => new(Invoke(nameof(Equals), other)); + public virtual ValueExpression Property(string propertyName) => new MemberExpression(this, propertyName); diff --git a/src/AutoRest.CSharp/Common/Output/Models/MethodSignature.cs b/src/AutoRest.CSharp/Common/Output/Models/MethodSignature.cs index 880b3ff9257..358226e1d60 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/MethodSignature.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/MethodSignature.cs @@ -4,10 +4,9 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Threading.Tasks; using AutoRest.CSharp.Generation.Types; -using AutoRest.CSharp.Generation.Writers; -using AutoRest.CSharp.Output.Models.Requests; using AutoRest.CSharp.Output.Models.Shared; using Azure; using static AutoRest.CSharp.Output.Models.MethodSignatureModifiers; @@ -96,5 +95,15 @@ private MethodSignature MakeSync() : null }; } + + public string ToStringForDocs() + { + var builder = new StringBuilder(Name); + builder.Append("("); + var paramList = Parameters.Select(p => p.Type.ToStringForDocs()); + builder.Append(string.Join(",", paramList)); + builder.Append(")"); + return builder.ToString(); + } } } diff --git a/src/AutoRest.CSharp/LowLevel/Generation/DpgClientWriter.cs b/src/AutoRest.CSharp/LowLevel/Generation/DpgClientWriter.cs index 1c253a0cf99..4fa8de55c05 100644 --- a/src/AutoRest.CSharp/LowLevel/Generation/DpgClientWriter.cs +++ b/src/AutoRest.CSharp/LowLevel/Generation/DpgClientWriter.cs @@ -615,23 +615,13 @@ private void WriteSampleRefsIfNecessary(MethodSignature methodSignature, bool is if (!samples.Any()) return; - var docRef = GetMethodSignatureString(methodSignature); + var docRef = methodSignature.ToStringForDocs(); _writer.Line($"/// "); _xmlDocWriter.AddMember(docRef); _xmlDocWriter.AddExamples(samples); } - private static string GetMethodSignatureString(MethodSignature signature) - { - var builder = new StringBuilder(signature.Name); - builder.Append("("); - var paramList = signature.Parameters.Select(p => p.Type.ToStringForDocs()); - builder.Append(string.Join(",", paramList)); - builder.Append(")"); - return builder.ToString(); - } - private static void WriteProtocolMethodDocumentation(CodeWriter writer, LowLevelClientMethod clientMethod, bool isAsync) { var methodSignature = clientMethod.ProtocolMethodSignature.WithAsync(isAsync); @@ -685,7 +675,7 @@ private static FormattableString BuildProtocolMethodSummary(MethodSignature meth // we only append the relative convenience method information when the convenience method is public if (clientMethod.ShouldGenerateConvenienceMethodRef()) { - var convenienceDocRef = GetMethodSignatureString(clientMethod.ConvenienceMethod!.Signature.WithAsync(async)); + var convenienceDocRef = clientMethod.ConvenienceMethod!.Signature.WithAsync(async).ToStringForDocs(); builder.AppendLine($"{Environment.NewLine}{Environment.NewLine}Please try the simpler convenience overload with strongly typed models first.{Environment.NewLine}{Environment.NewLine}"); } builder.AppendLine($""); diff --git a/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtOutputLibrary.cs b/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtOutputLibrary.cs index d142035d762..990c4d8692c 100644 --- a/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtOutputLibrary.cs +++ b/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtOutputLibrary.cs @@ -19,9 +19,6 @@ using AutoRest.CSharp.Output.Models.Requests; using AutoRest.CSharp.Output.Models.Types; using AutoRest.CSharp.Utilities; -using Azure.ResourceManager; -using Azure.ResourceManager.ManagementGroups; -using Azure.ResourceManager.Resources; using Humanizer.Inflections; using static AutoRest.CSharp.Mgmt.Decorator.Transformer.PartialResourceResolver; @@ -431,7 +428,7 @@ private bool ShouldGenerateChildrenForType(Type armCoreType) => !Configuration.MgmtConfiguration.IsArmCore || armCoreType.Namespace != MgmtContext.Context.DefaultNamespace; public IEnumerable Extensions => ExtensionBuilder.Extensions; - public IEnumerable ExtensionClients => ExtensionBuilder.ExtensionClients; + public IEnumerable MockableExtensions => ExtensionBuilder.MockableExtensions; public MgmtExtensionWrapper ExtensionWrapper => ExtensionBuilder.ExtensionWrapper; public MgmtExtension GetExtension(Type armCoreType) => ExtensionBuilder.GetExtension(armCoreType); diff --git a/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtTarget.cs b/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtTarget.cs index 8974ceb4262..5f78ee6bab2 100644 --- a/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtTarget.cs +++ b/src/AutoRest.CSharp/Mgmt/AutoRest/MgmtTarget.cs @@ -188,7 +188,7 @@ public static async Task ExecuteAsync(GeneratedCodeWorkspace project, CodeModel } // write extension class - WriteExtensions(project, isArmCore, MgmtContext.Library.ExtensionWrapper, MgmtContext.Library.Extensions, MgmtContext.Library.ExtensionClients); + WriteExtensions(project, isArmCore, MgmtContext.Library.ExtensionWrapper, MgmtContext.Library.Extensions, MgmtContext.Library.MockableExtensions); var lroWriter = new MgmtLongRunningOperationWriter(true); lroWriter.Write(); @@ -232,7 +232,7 @@ public static async Task ExecuteAsync(GeneratedCodeWorkspace project, CodeModel await project.PostProcessAsync(new MgmtPostProcessor(modelsToKeep, modelFactoryProvider?.FullName)); } - private static void WriteExtensions(GeneratedCodeWorkspace project, bool isArmCore, MgmtExtensionWrapper extensionWrapper, IEnumerable extensions, IEnumerable extensionClients) + private static void WriteExtensions(GeneratedCodeWorkspace project, bool isArmCore, MgmtExtensionWrapper extensionWrapper, IEnumerable extensions, IEnumerable mockableExtensions) { if (isArmCore) { @@ -253,12 +253,12 @@ private static void WriteExtensions(GeneratedCodeWorkspace project, bool isArmCo WriteExtensionFile(project, new MgmtExtensionWrapperWriter(extensionWrapper)); // and we write ExtensionClients - foreach (var extensionClient in extensionClients) + foreach (var mockableExtension in mockableExtensions) { - if (!extensionClient.IsEmpty) + if (!mockableExtension.IsEmpty) { - MgmtReport.Instance.ExtensionSection.Add(extensionClient.ResourceName, new ExtensionItem(extensionClient, MgmtReport.Instance.TransformSection)); - WriteExtensionFile(project, new MgmtExtensionClientWriter(extensionClient)); + MgmtReport.Instance.ExtensionSection.Add(mockableExtension.ResourceName, new ExtensionItem(mockableExtension, MgmtReport.Instance.TransformSection)); + WriteExtensionFile(project, MgmtMockableExtensionResourceWriter.GetWriter(mockableExtension)); } } } diff --git a/src/AutoRest.CSharp/Mgmt/Decorator/ParameterMappingBuilder.cs b/src/AutoRest.CSharp/Mgmt/Decorator/ParameterMappingBuilder.cs index 07190b1a56a..1d5c3c6de60 100644 --- a/src/AutoRest.CSharp/Mgmt/Decorator/ParameterMappingBuilder.cs +++ b/src/AutoRest.CSharp/Mgmt/Decorator/ParameterMappingBuilder.cs @@ -29,17 +29,16 @@ internal static class ParameterMappingBuilder /// method using their "value expression"s /// /// The contextual path, which is usually the path creating a resource - /// The /// The variable name of the Id variable /// - public static IEnumerable BuildContextualParameters(this RequestPath requestPath, string idVariableName) + public static IEnumerable BuildContextualParameters(this RequestPath requestPath, FormattableString idVariableName) { var stack = new Stack(); BuildContextualParameterMappingHierarchy(requestPath, stack, idVariableName); return stack; } - private static void BuildContextualParameterMappingHierarchy(RequestPath current, Stack parameterMappingStack, string idVariableName = "Id", string invocationSuffix = "") + private static void BuildContextualParameterMappingHierarchy(RequestPath current, Stack parameterMappingStack, FormattableString idVariableName, string invocationSuffix = "") { // Check if the current path is a scope parameter if (current.IsRawParameterizedScope()) diff --git a/src/AutoRest.CSharp/Mgmt/Decorator/ParentDetection.cs b/src/AutoRest.CSharp/Mgmt/Decorator/ParentDetection.cs index ed5988e0943..3728e5b737d 100644 --- a/src/AutoRest.CSharp/Mgmt/Decorator/ParentDetection.cs +++ b/src/AutoRest.CSharp/Mgmt/Decorator/ParentDetection.cs @@ -28,7 +28,6 @@ internal static class ParentDetection /// This is not initialized while the TypeProviders are constructing and can only be used in the writers. /// /// - /// /// public static IEnumerable GetParents(this Resource resource) { diff --git a/src/AutoRest.CSharp/Mgmt/Decorator/ResourceTypeBuilder.cs b/src/AutoRest.CSharp/Mgmt/Decorator/ResourceTypeBuilder.cs index 1a07ad744e2..8ec807eb986 100644 --- a/src/AutoRest.CSharp/Mgmt/Decorator/ResourceTypeBuilder.cs +++ b/src/AutoRest.CSharp/Mgmt/Decorator/ResourceTypeBuilder.cs @@ -45,19 +45,12 @@ private static ResourceTypeSegment CalculateResourceType(RequestPath requestPath return ResourceTypeSegment.ParseRequestPath(requestPath); } - public static ResourceTypeSegment GetResourceType(this IEnumerable requestPaths) + public static ICollection? GetScopeTypeStrings(IEnumerable? scopeTypes) { - var resourceTypes = requestPaths.Select(path => path.GetResourceType()).Distinct(); + if (scopeTypes == null || !scopeTypes.Any() || scopeTypes.Contains(ResourceTypeSegment.Any)) + return null; - if (resourceTypes.Count() > 1) - throw new InvalidOperationException($"Request path(s) {string.Join(", ", requestPaths)} contain multiple resource types in it ({string.Join(", ", resourceTypes)}), please double check and override it in `request-path-to-resource-type` section."); - - var resourceType = resourceTypes.First(); - - if (resourceType == ResourceTypeSegment.Scope) - throw new InvalidOperationException($"Request path(s) {string.Join(", ", requestPaths)} is a 'ById' resource, we cannot derive a resource type from its request path, please double check and override it in `request-path-to-resource-type` section."); - - return resourceType; + return scopeTypes.Select(type => (FormattableString)$"{type}").ToArray(); } } } diff --git a/src/AutoRest.CSharp/Mgmt/Generation/ArmClientExtensionWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/ArmClientExtensionWriter.cs index a5cc8fdf032..cc88f2e3a43 100644 --- a/src/AutoRest.CSharp/Mgmt/Generation/ArmClientExtensionWriter.cs +++ b/src/AutoRest.CSharp/Mgmt/Generation/ArmClientExtensionWriter.cs @@ -6,15 +6,15 @@ using AutoRest.CSharp.Generation.Writers; using AutoRest.CSharp.Mgmt.AutoRest; using AutoRest.CSharp.Mgmt.Decorator; +using AutoRest.CSharp.Mgmt.Models; using AutoRest.CSharp.Mgmt.Output; -using AutoRest.CSharp.Utilities; using Azure.Core; namespace AutoRest.CSharp.Mgmt.Generation { internal sealed class ArmClientExtensionWriter : MgmtExtensionWriter { - private MgmtExtension This { get; } + private ArmClientExtension This { get; } public ArmClientExtensionWriter(ArmClientExtension extension) : this(new CodeWriter(), extension) { @@ -27,13 +27,22 @@ public ArmClientExtensionWriter(CodeWriter writer, ArmClientExtension extension) protected internal override void WriteImplementations() { - foreach (var resource in MgmtContext.Library.ArmResources) + base.WriteImplementations(); + + foreach (var method in This.ArmResourceMethods) + { + _writer.WriteMethodDocumentation(method.Signature); + _writer.WriteMethod(method); + } + } + + protected override void WriteMethod(MgmtClientOperation clientOperation, bool isAsync) + { + using (_writer.WriteCommonMethod(clientOperation.MethodSignature, null, isAsync, This.Accessibility == "public", SkipParameterValidation)) { - _writer.Line($"#region {resource.Type.Name}"); - WriteGetResourceFromIdMethod(resource); - _writer.LineRaw("#endregion"); - _writer.Line(); + WriteMethodBodyWrapper(clientOperation.MethodSignature, isAsync, clientOperation.IsPagingOperation); } + _writer.Line(); } private void WriteGetResourceFromIdMethod(Resource resource) @@ -51,15 +60,12 @@ private void WriteGetResourceFromIdMethod(Resource resource) _writer.WriteXmlDocumentationReturns($"Returns a object."); var modifier = IsArmCore ? "virtual" : "static"; var instanceParameter = IsArmCore ? string.Empty : $"this {This.ExtensionParameter.Type.Name} {This.ExtensionParameter.Name}, "; - using (_writer.Scope($"public {modifier} {resource.Type} Get{resource.Type.Name}({instanceParameter}{typeof(Azure.Core.ResourceIdentifier)} id)")) + using (_writer.Scope($"public {modifier} {resource.Type} Get{resource.Type.Name}({instanceParameter}{typeof(ResourceIdentifier)} id)")) { if (!IsArmCore) { - using (_writer.Scope($"return {This.ExtensionParameter.Name}.GetResourceClient<{resource.Type}>(() =>")) - { - WriteGetter(resource, $"{ArmClientReference.ToVariableName()}"); - } - _writer.Line($");"); + _writer.AppendRaw("return ") + .Append($"{This.MockableExtension.FactoryMethodName}({This.ExtensionParameter.Name}).Get{resource.Type.Name}(id);"); } else { diff --git a/src/AutoRest.CSharp/Mgmt/Generation/ArmClientMockingExtensionWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/ArmClientMockingExtensionWriter.cs new file mode 100644 index 00000000000..02753fcdb69 --- /dev/null +++ b/src/AutoRest.CSharp/Mgmt/Generation/ArmClientMockingExtensionWriter.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License + +using System; +using System.Collections.Generic; +using System.Linq; +using AutoRest.CSharp.Generation.Writers; +using AutoRest.CSharp.Mgmt.AutoRest; +using AutoRest.CSharp.Mgmt.Decorator; +using AutoRest.CSharp.Mgmt.Models; +using AutoRest.CSharp.Mgmt.Output; +using AutoRest.CSharp.Output.Models.Shared; +using Azure.Core; + +namespace AutoRest.CSharp.Mgmt.Generation +{ + internal sealed class ArmClientMockingExtensionWriter : MgmtMockableExtensionResourceWriter + { + private readonly Parameter _scopeParameter; + private MgmtMockableArmClient This { get; } + + public ArmClientMockingExtensionWriter(MgmtMockableArmClient extensionClient) : base(extensionClient) + { + This = extensionClient; + _scopeParameter = new Parameter( + Name: "scope", + Description: $"The scope that the resource will apply against.", + Type: typeof(ResourceIdentifier), + DefaultValue: null, + Validation: ValidationType.None, + Initializer: null); + } + + protected override void WriteCtors() + { + base.WriteCtors(); + + if (This.ArmClientCtor is { } armClientCtor) + { + // for ArmClientExtensionClient, we write an extra ctor that only takes ArmClient as parameter + var ctor = armClientCtor with + { + Parameters = new[] { MgmtTypeProvider.ArmClientParameter }, + Initializer = new(false, new FormattableString[] { $"{MgmtTypeProvider.ArmClientParameter.Name:I}", $"{typeof(ResourceIdentifier)}.{nameof(ResourceIdentifier.Root)}" }) + }; + + using (_writer.WriteMethodDeclaration(ctor)) + { + // it does not need a body + } + } + } + + protected internal override void WriteImplementations() + { + base.WriteImplementations(); + + foreach (var method in This.ArmResourceMethods) + { + _writer.WriteMethodDocumentation(method.Signature); + _writer.WriteMethod(method); + } + } + + protected override IDisposable WriteCommonMethod(MgmtClientOperation clientOperation, bool isAsync) + { + var originalSignature = clientOperation.MethodSignature; + var signature = originalSignature with + { + Parameters = originalSignature.Parameters.Prepend(MgmtTypeProvider.ScopeParameter).ToArray() + }; + _writer.Line(); + var returnDescription = clientOperation.ReturnsDescription?.Invoke(isAsync); + return _writer.WriteCommonMethod(signature, returnDescription, isAsync, This.Accessibility == "public", SkipParameterValidation); + } + + protected override WriteMethodDelegate GetMethodDelegate(bool isLongRunning, bool isPaging) + { + var writeBody = base.GetMethodDelegate(isLongRunning, isPaging); + return (clientOperation, diagnostic, isAsync) => + { + var requestPaths = clientOperation.Select(restOperation => restOperation.RequestPath); + var scopeResourceTypes = requestPaths.Select(requestPath => requestPath.GetParameterizedScopeResourceTypes() ?? Enumerable.Empty()).SelectMany(types => types).Distinct(); + var scopeTypes = ResourceTypeBuilder.GetScopeTypeStrings(scopeResourceTypes); + + WriteScopeResourceTypesValidation(_scopeParameter.Name, scopeTypes); + + writeBody(clientOperation, diagnostic, isAsync); + }; + } + + private void WriteScopeResourceTypesValidation(string parameterName, ICollection? types) + { + if (types == null) + return; + // validate the scope types + var typeAssertions = types.Select(type => (FormattableString)$"!{parameterName:I}.ResourceType.Equals(\"{type}\")").ToArray(); + var assertion = typeAssertions.Join(" || "); + using (_writer.Scope($"if ({assertion})")) + { + _writer.Line($"throw new {typeof(ArgumentException)}({typeof(string)}.{nameof(string.Format)}(\"Invalid resource type {{0}} expected {types.Join(", ", " or ")}\", {parameterName:I}.ResourceType));"); + } + } + + private void WriteGetResourceFromIdMethod(Resource resource) + { + List lines = new List(); + string an = resource.Type.Name.StartsWithVowel() ? "an" : "a"; + lines.Add($"Gets an object representing {an} along with the instance operations that can be performed on it but with no data."); + lines.Add($"You can use to create {an} from its components."); + _writer.WriteXmlDocumentationSummary(FormattableStringHelpers.Join(lines, "\r\n")); + _writer.WriteXmlDocumentationParameter("id", $"The resource ID of the resource to get."); + _writer.WriteXmlDocumentationReturns($"Returns a object."); + using (_writer.Scope($"public virtual {resource.Type} Get{resource.Type.Name}({typeof(Azure.Core.ResourceIdentifier)} id)")) + { + WriteGetter(resource, "Client"); + } + } + + private void WriteGetter(Resource resource, string armVariable) + { + _writer.Line($"{resource.Type.Name}.ValidateResourceId(id);"); + _writer.Line($"return new {resource.Type.Name}({armVariable}, id);"); + } + } +} diff --git a/src/AutoRest.CSharp/Mgmt/Generation/ArmResourceExtensionWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/ArmResourceExtensionWriter.cs deleted file mode 100644 index 444b62c1e0f..00000000000 --- a/src/AutoRest.CSharp/Mgmt/Generation/ArmResourceExtensionWriter.cs +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using AutoRest.CSharp.Common.Input; -using AutoRest.CSharp.Generation.Writers; -using AutoRest.CSharp.Input; -using AutoRest.CSharp.Mgmt.Decorator; -using AutoRest.CSharp.Mgmt.Models; -using AutoRest.CSharp.Mgmt.Output; -using AutoRest.CSharp.Output.Models; -using AutoRest.CSharp.Output.Models.Shared; -using AutoRest.CSharp.Utilities; -using Azure.Core; -using Azure.ResourceManager; - -namespace AutoRest.CSharp.Mgmt.Generation -{ - /// - /// The is writing the extension methods differently from - /// The extension methods in ArmResourceExtension will have two versions: - /// public static Response Foo(this ArmClient client, ResourceIdentifier scope) - /// and - /// public static Response Foo(this ArmResource armResource) - /// The extending version is depending if we have the configuration set. - /// Since the generated methods are different from regular extension classes, we have this writer to handle those methods. - /// Because in Azure.ResourceManager (ArmCore) we will never generate extension method, instead we just generate instance method in partial classes, this class should be never used when IsArmCore is true - /// - internal sealed class ArmResourceExtensionWriter : MgmtExtensionWriter - { - private ArmResourceExtension This { get; } - - private readonly Parameter _armClientParameter; - private readonly Parameter _scopeParameter; - - public ArmResourceExtensionWriter(CodeWriter writer, ArmResourceExtension extension) - : base(writer, extension) - { - // we never use this class in ArmCore, see the description on this class for details - Debug.Assert(!Configuration.MgmtConfiguration.IsArmCore); - - This = extension; - _armClientParameter = This.ExtensionParameter with - { - Name = "client", - Description = $"The instance the method will execute against.", - Type = typeof(ArmClient), - }; - _scopeParameter = new Parameter( - Name: "scope", - Description: $"The scope that the resource will apply against.", - Type: typeof(ResourceIdentifier), - DefaultValue: null, - Validation: ValidationType.None, - Initializer: null); - } - - private static bool ShouldGenerateArmResourceExtensionMethod(IEnumerable requestPaths) - => requestPaths.Any(ShouldGenerateArmResourceExtensionMethod); - - private static bool ShouldGenerateArmResourceExtensionMethod(RequestPath requestPath) - => Configuration.MgmtConfiguration.GenerateArmResourceExtensions.Contains(requestPath); - - protected override void WriteMethod(MgmtClientOperation clientOperation, bool isAsync) - { - var requestPaths = clientOperation.Select(restOperation => restOperation.RequestPath); - if (ShouldGenerateArmResourceExtensionMethod(requestPaths)) - { - base.WriteMethod(clientOperation, isAsync); - _writer.Line(); - } - - var scopeResourceTypes = requestPaths.Select(requestPath => requestPath.GetParameterizedScopeResourceTypes() ?? Enumerable.Empty()).SelectMany(types => types).Distinct(); - var scopeTypes = GetScopeTypeStrings(scopeResourceTypes); - var originalSignature = clientOperation.MethodSignature; - var signature = new MethodSignature( - originalSignature.Name, - originalSignature.Summary, - originalSignature.Description, - originalSignature.Modifiers, - originalSignature.ReturnType, - originalSignature.ReturnDescription, - GetScopeVersionMethodParameters(originalSignature.Parameters.Skip(1), scopeTypes), - originalSignature.Attributes); - using (_writer.WriteCommonMethod(signature, null, isAsync, This.Accessibility == "public")) - { - WriteMethodBodyWrapper(signature, isAsync, clientOperation.IsPagingOperation, scopeTypes); - } - _writer.Line(); - } - - protected override void WriteSingletonResourceGetMethod(Resource resource) - { - if (ShouldGenerateArmResourceExtensionMethod(resource.RequestPath)) - { - base.WriteSingletonResourceGetMethod(resource); - _writer.Line(); - } - - var scopeTypes = GetScopeTypeStrings(resource.RequestPath.GetParameterizedScopeResourceTypes()); - var signature = new MethodSignature( - $"Get{resource.ResourceName}", - null, - $"Gets an object representing a {resource.Type.Name} along with the instance operations that can be performed on it in the {This.ResourceName}.", - GetMethodModifiers(), - resource.Type, - $"Returns a object.", - GetParametersForSingletonEntry(scopeTypes)); - using (_writer.WriteCommonMethod(signature, null, false, This.Accessibility == "public")) - { - WriteMethodBodyWrapper(signature, false, false, scopeTypes); - } - } - - protected override void WriteResourceCollectionGetMethod(Resource resource) - { - if (ShouldGenerateArmResourceExtensionMethod(resource.RequestPath)) - { - base.WriteResourceCollectionGetMethod(resource); - _writer.Line(); - } - - var scopeTypes = GetScopeTypeStrings(resource.RequestPath.GetParameterizedScopeResourceTypes()); - var resourceCollection = resource.ResourceCollection!; - var signature = new MethodSignature( - $"{GetResourceCollectionMethodName(resourceCollection)}", - null, - $"Gets a collection of {resource.Type.Name.LastWordToPlural()} in the {This.ResourceName}.", - GetMethodModifiers(), - resourceCollection.Type, - $"An object representing collection of {resource.Type.Name.LastWordToPlural()} and their operations over a {resource.Type.Name}.", - GetParametersForCollectionEntry(resourceCollection, scopeTypes)); - using (_writer.WriteCommonMethod(signature, null, false, This.Accessibility == "public")) - { - WriteMethodBodyWrapper(signature, false, false, scopeTypes); - } - } - - protected override void WriteChildResourceGetMethod(ResourceCollection resourceCollection, bool isAsync) - { - if (ShouldGenerateArmResourceExtensionMethod(resourceCollection.Resource.RequestPath)) - { - base.WriteChildResourceGetMethod(resourceCollection, isAsync); - _writer.Line(); - } - - var scopeTypes = GetScopeTypeStrings(resourceCollection.RequestPath.GetParameterizedScopeResourceTypes()); - var getOperation = resourceCollection.GetOperation; - // Copy the original method signature with changes in name and modifier (e.g. when adding into extension class, the modifier should be static) - var methodSignature = getOperation.MethodSignature with - { - // name after `Get{ResourceName}` - Name = $"{getOperation.MethodSignature.Name}{resourceCollection.Resource.ResourceName}", - Modifiers = GetMethodModifiers(), - // There could be parameters to get resource collection - Parameters = GetParametersForCollectionEntry(resourceCollection, scopeTypes).Concat(GetParametersForResourceEntry(resourceCollection)).ToArray(), - Attributes = new[] { new CSharpAttribute(typeof(ForwardsClientCallsAttribute)) } - }; - - _writer.Line(); - using (_writer.WriteCommonMethodWithoutValidation(methodSignature, getOperation.ReturnsDescription != null ? getOperation.ReturnsDescription(isAsync) : null, isAsync, This.Accessibility == "public")) - { - WriteResourceEntry(resourceCollection, isAsync, scopeTypes); - } - } - - private void WriteResourceEntry(ResourceCollection resourceCollection, bool isAsync, ICollection? types) - { - WriteScopeResourceTypesValidation(_scopeParameter.Name, types); - var operation = resourceCollection.GetOperation; - string configureAwait = isAsync & !operation.IsPagingOperation ? ".ConfigureAwait(false)" : string.Empty; - - _writer.AppendRaw("return ") - .AppendRawIf("await ", isAsync && !operation.IsPagingOperation) - .Append($"{GetResourceCollectionMethodName(resourceCollection)}("); - foreach (var parameter in GetParametersForCollectionEntry(resourceCollection, types)) - { - _writer.Append($"{parameter.Name:I},"); - } - _writer.RemoveTrailingComma(); - _writer.Append($").{operation.MethodSignature.WithAsync(isAsync).Name}("); - foreach (var parameter in operation.MethodSignature.Parameters) - { - _writer.Append($"{parameter.Name},"); - } - - _writer.RemoveTrailingComma(); - _writer.AppendRaw(")") - .AppendRawIf(".ConfigureAwait(false)", isAsync && !operation.IsPagingOperation) - .LineRaw(";"); - } - - private void WriteMethodBodyWrapper(MethodSignature signature, bool isAsync, bool isPaging, ICollection? scopeTypes) - { - WriteScopeResourceTypesValidation(_scopeParameter.Name, scopeTypes); - - var extensionClient = This.GetExtensionClient(null); - - _writer.AppendRaw("return ") - .AppendRawIf("await ", isAsync && !isPaging) - .Append($"{extensionClient.FactoryMethodName}({_armClientParameter.Name}, {_scopeParameter.Name}).{CreateMethodName(signature.Name, isAsync)}("); - - foreach (var parameter in signature.Parameters.Skip(2)) - { - _writer.Append($"{parameter.Name},"); - } - - _writer.RemoveTrailingComma(); - _writer.AppendRaw(")") - .AppendRawIf(".ConfigureAwait(false)", isAsync && !isPaging) - .LineRaw(";"); - } - - private ICollection? GetScopeTypeStrings(IEnumerable? scopeTypes) - { - if (scopeTypes == null || scopeTypes.Contains(ResourceTypeSegment.Any)) - return null; - - return scopeTypes.Select(type => (FormattableString)$"{type}").ToArray(); - } - - private void WriteScopeResourceTypesValidation(string parameterName, ICollection? types) - { - if (types == null) - return; - // validate the scope types - var typeAssertions = types.Select(type => (FormattableString)$"!{parameterName:I}.ResourceType.Equals(\"{type}\")").ToArray(); - var assertion = typeAssertions.Join(" || "); - using (_writer.Scope($"if ({assertion})")) - { - _writer.Line($"throw new {typeof(ArgumentException)}({typeof(string)}.{nameof(string.Format)}(\"Invalid resource type {{0}} expected {types.Join(", ", " or ")}\", {parameterName:I}.ResourceType));"); - } - } - - /// - /// Returns the parameters by the specific scope - /// - /// - /// - private Parameter[] GetScopeVersionMethodParameters(IEnumerable parameters, ICollection? types) - { - var scopeParameter = GetScopeParameter(types); - return parameters.Prepend(scopeParameter).Prepend(_armClientParameter).ToArray(); - } - - private Parameter[] GetParametersForSingletonEntry(ICollection? types) => GetScopeVersionMethodParameters(Enumerable.Empty(), types); - - private Parameter[] GetParametersForCollectionEntry(ResourceCollection resourceCollection, ICollection? types) => GetScopeVersionMethodParameters(resourceCollection.ExtraConstructorParameters, types); - - private Parameter GetScopeParameter(ICollection? types) - { - if (types == null) - return _scopeParameter; - - return _scopeParameter with - { - Description = $"{_scopeParameter.Description} Expected resource type includes the following: {types.Join(", ", " or ")}" - }; - } - } -} diff --git a/src/AutoRest.CSharp/Mgmt/Generation/MgmtClientBaseWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/MgmtClientBaseWriter.cs index 3e1005c7dd9..beb62fc7d9d 100644 --- a/src/AutoRest.CSharp/Mgmt/Generation/MgmtClientBaseWriter.cs +++ b/src/AutoRest.CSharp/Mgmt/Generation/MgmtClientBaseWriter.cs @@ -15,7 +15,6 @@ using AutoRest.CSharp.Mgmt.Models; using AutoRest.CSharp.Mgmt.Output; using AutoRest.CSharp.Mgmt.Output.Models; -using AutoRest.CSharp.Output.Models; using AutoRest.CSharp.Output.Models.Requests; using AutoRest.CSharp.Output.Models.Shared; using AutoRest.CSharp.Utilities; @@ -24,7 +23,6 @@ using Azure.ResourceManager.ManagementGroups; using Azure.ResourceManager.Resources; using static AutoRest.CSharp.Mgmt.Decorator.ParameterMappingBuilder; -using static AutoRest.CSharp.Output.Models.MethodSignatureModifiers; namespace AutoRest.CSharp.Mgmt.Generation { @@ -43,6 +41,8 @@ internal abstract class MgmtClientBaseWriter : ClientWriter protected virtual bool UseField => true; + protected virtual bool SkipParameterValidation => false; + public string FileName { get; } protected MgmtClientBaseWriter(CodeWriter writer, MgmtTypeProvider provider) @@ -78,7 +78,12 @@ protected internal virtual void WriteImplementations() WritePrivateHelpers(); - WriteChildResourceEntries(); + _writer.Line(); // TODO -- add this here to minimize the amount of code changes, this could be removed after future refactor + foreach (var method in This.ChildResourceEntryMethods) + { + _writer.WriteMethodDocumentation(method.Signature); + _writer.WriteMethod(method); + } WriteOperations(); @@ -244,144 +249,6 @@ private void WriteRestClientConstructorPair(MgmtRestClient restClient, Resource? return null; } - protected virtual void WriteChildResourceEntries() - { - foreach (var resource in This.ChildResources) - { - _writer.Line(); - if (resource.IsSingleton) - { - WriteSingletonResourceGetMethod(resource); - } - else if (resource.ResourceCollection is not null) - { - WriteResourceCollectionGetMethod(resource); - - if (This.HasChildResourceGetMethods) - { - WriteChildResourceGetMethod(resource.ResourceCollection, true); - WriteChildResourceGetMethod(resource.ResourceCollection, false); - } - } - } - _writer.Line(); - } - - protected virtual void WriteSingletonResourceGetMethod(Resource resource) - { - var signature = new MethodSignature( - $"Get{resource.ResourceName}", - null, - $"Gets an object representing a {resource.Type.Name} along with the instance operations that can be performed on it in the {This.ResourceName}.", - GetMethodModifiers(), - resource.Type, - $"Returns a object.", - GetParametersForSingletonEntry()); - using (_writer.WriteCommonMethod(signature, null, false, This.Accessibility == "public")) - { - WriteSingletonResourceEntry(resource, resource.SingletonResourceIdSuffix!, signature); - } - } - - protected virtual void WriteResourceCollectionGetMethod(Resource resource) - { - var resourceCollection = resource.ResourceCollection!; - var signature = new MethodSignature( - $"{GetResourceCollectionMethodName(resourceCollection)}", - null, - $"Gets a collection of {resource.Type.Name.LastWordToPlural()} in the {This.ResourceName}.", - GetMethodModifiers(), - resourceCollection.Type, - $"An object representing collection of {resource.Type.Name.LastWordToPlural()} and their operations over a {resource.Type.Name}.", - GetParametersForCollectionEntry(resourceCollection)); - using (_writer.WriteCommonMethod(signature, null, false, This.Accessibility == "public")) - { - WriteResourceCollectionEntry(resourceCollection, signature); - } - } - - protected virtual void WriteChildResourceGetMethod(ResourceCollection resourceCollection, bool isAsync) - { - var getOperation = resourceCollection.GetOperation; - // Copy the original method signature with changes in name and modifier (e.g. when adding into extension class, the modifier should be static) - var methodSignature = getOperation.MethodSignature with - { - // name after `Get{ResourceName}` - Name = $"{getOperation.MethodSignature.Name}{resourceCollection.Resource.ResourceName}", - Modifiers = GetMethodModifiers(), - // There could be parameters to get resource collection - Parameters = GetParametersForCollectionEntry(resourceCollection).Concat(GetParametersForResourceEntry(resourceCollection)).Distinct().ToArray(), - Attributes = new[] { new CSharpAttribute(typeof(ForwardsClientCallsAttribute)) } - }; - - _writer.Line(); - using (_writer.WriteCommonMethodWithoutValidation(methodSignature, getOperation.ReturnsDescription?.Invoke(isAsync), isAsync, This.Accessibility == "public")) - { - WriteResourceEntry(resourceCollection, isAsync); - } - } - - protected virtual void WriteResourceEntry(ResourceCollection resourceCollection, bool isAsync) - { - var operation = resourceCollection.GetOperation; - string awaitText = isAsync & !operation.IsPagingOperation ? " await" : string.Empty; - string configureAwait = isAsync & !operation.IsPagingOperation ? ".ConfigureAwait(false)" : string.Empty; - var arguments = string.Join(", ", operation.MethodSignature.Parameters.Select(p => p.Name)); - _writer.Line($"return{awaitText} {GetResourceCollectionMethodName(resourceCollection)}({GetResourceCollectionMethodArgumentList(resourceCollection)}).{operation.MethodSignature.WithAsync(isAsync).Name}({arguments}){configureAwait};"); - } - - protected string GetResourceCollectionMethodName(ResourceCollection resourceCollection) - { - return $"Get{resourceCollection.Resource.ResourceName.ResourceNameToPlural()}"; - } - - protected string GetResourceCollectionMethodArgumentList(ResourceCollection resourceCollection) - { - return string.Join(", ", GetParametersForCollectionEntry(resourceCollection).Select(p => p.Name)); - } - - protected virtual void WriteSingletonResourceEntry(Resource resource, SingletonResourceSuffix singletonResourceIdSuffix, MethodSignature signature) - { - // we cannot guarantee that the singleResourceSuffix can only have two segments (it has many different cases), - // therefore instead of using the extension method of ResourceIdentifier, we are just concatting this as a string - _writer.UseNamespace(typeof(ResourceIdentifier).Namespace!); - _writer.Line($"return new {resource.Type.Name}({ArmClientReference}, {singletonResourceIdSuffix.BuildResourceIdentifier($"Id")});"); - } - - protected virtual MethodSignatureModifiers GetMethodModifiers() => Public | Virtual; - - protected virtual Parameter[] GetParametersForSingletonEntry() => Array.Empty(); - - protected virtual Parameter[] GetParametersForCollectionEntry(ResourceCollection resourceCollection) - { - return resourceCollection.ExtraConstructorParameters.ToArray(); - } - - protected Parameter[] GetParametersForResourceEntry(ResourceCollection resourceCollection) - { - return resourceCollection.GetOperation.MethodSignature.Parameters.ToArray(); - } - - protected virtual void WriteResourceCollectionEntry(ResourceCollection resourceCollection, MethodSignature signature) - { - // TODO: can we cache collection with extra constructor parameters - if (resourceCollection.ExtraConstructorParameters.Any()) - { - _writer.Append($"return new {resourceCollection.Type.Name}({ArmClientReference}, Id, "); - foreach (var parameter in resourceCollection.ExtraConstructorParameters) - { - _writer.Append($"{parameter.Name}, "); - } - _writer.RemoveTrailingComma(); - _writer.Line($");"); - } - else - { - // for collections without extra constructor parameter, we can return a cached instance - _writer.Line($"return GetCachedClient({ArmClientReference} => new {resourceCollection.Type.Name}({ArmClientReference}, Id));"); - } - } - protected void WriteStaticValidate(FormattableString validResourceType) { using (_writer.Scope($"internal static void ValidateResourceId({typeof(Azure.Core.ResourceIdentifier)} id)")) @@ -417,7 +284,7 @@ protected FormattableString GetProviderNamespaceFromReturnType(FormattableString protected FormattableString ConstructClientDiagnostic(CodeWriter writer, FormattableString providerNamespace, string diagnosticsOptionsVariable) { - return $"new {Configuration.ApiTypes.ClientDiagnosticsType}(\"{This.Type.Namespace}\", {providerNamespace}, {diagnosticsOptionsVariable})"; + return $"new {Configuration.ApiTypes.ClientDiagnosticsType}(\"{This.DiagnosticNamespace}\", {providerNamespace}, {diagnosticsOptionsVariable})"; } protected FormattableString GetRestConstructorString(MgmtRestClient restClient, FormattableString? apiVersionExpression) @@ -538,11 +405,11 @@ private void WritePagingLROMethodBody(MgmtClientOperation clientOperation, Diagn throw new NotImplementedException($"Pageable LRO is not implemented yet, please use `remove-operation` directive to remove the following operationIds: {string.Join(", ", clientOperation.Select(o => o.OperationId))}"); } - protected IDisposable WriteCommonMethod(MgmtClientOperation clientOperation, bool isAsync) + protected virtual IDisposable WriteCommonMethod(MgmtClientOperation clientOperation, bool isAsync) { _writer.Line(); var returnDescription = clientOperation.ReturnsDescription?.Invoke(isAsync); - return _writer.WriteCommonMethod(clientOperation.MethodSignature, returnDescription, isAsync, This.Accessibility == "public"); + return _writer.WriteCommonMethod(clientOperation.MethodSignature, returnDescription, isAsync, This.Accessibility == "public", SkipParameterValidation); } #region PagingMethod diff --git a/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWrapperWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWrapperWriter.cs index 710d339e7cb..f299f804c40 100644 --- a/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWrapperWriter.cs +++ b/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWrapperWriter.cs @@ -1,12 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -using System; -using System.Collections.Generic; -using System.Text; using AutoRest.CSharp.Generation.Writers; using AutoRest.CSharp.Mgmt.Output; -using Azure.ResourceManager; namespace AutoRest.CSharp.Mgmt.Generation { @@ -21,20 +17,14 @@ public MgmtExtensionWrapperWriter(MgmtExtensionWrapper extensionWrapper) : base( protected override void WritePrivateHelpers() { - foreach (var extensionClient in This.ExtensionClients) + foreach (var extension in This.Extensions) { - if (extensionClient.IsEmpty) + if (extension.IsEmpty) continue; - foreach (var method in extensionClient.FactoryMethods) - { - _writer.Line(); + _writer.Line(); - using (_writer.WriteMethodDeclaration(method.Signature)) - { - method.MethodBodyImplementation(_writer); - } - } + _writer.WriteMethod(extension.MockingExtensionFactoryMethod); } base.WritePrivateHelpers(); diff --git a/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWriter.cs index 36960c1d314..69adc3a1547 100644 --- a/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWriter.cs +++ b/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionWriter.cs @@ -21,16 +21,15 @@ internal class MgmtExtensionWriter : MgmtClientBaseWriter public static MgmtExtensionWriter GetWriter(CodeWriter writer, MgmtExtension extension) => extension switch { ArmClientExtension armClientExtension => new ArmClientExtensionWriter(writer, armClientExtension), - // the class ArmResourceExtensionWriter is created to handle scope resources, but in ArmCore we do not have that problem, therefore for ArmCore we just let the regular MgmtExtension class handle that - ArmResourceExtension armResourceExtension when !Configuration.MgmtConfiguration.IsArmCore => new ArmResourceExtensionWriter(writer, armResourceExtension), _ => new MgmtExtensionWriter(writer, extension) }; + protected override bool SkipParameterValidation => true; + private MgmtExtension This { get; } protected delegate void WriteResourceGetBody(MethodSignature signature, bool isAsync, bool isPaging); - public MgmtExtensionWriter(MgmtExtension extensions) - : this(new CodeWriter(), extensions) + public MgmtExtensionWriter(MgmtExtension extensions) : this(new CodeWriter(), extensions) { This = extensions; } @@ -46,13 +45,11 @@ protected override WriteMethodDelegate GetMethodDelegate(bool isLongRunning, boo private void GetMethodWrapperImpl(MgmtClientOperation clientOperation, Diagnostic diagnostic, bool isAsync) => WriteMethodBodyWrapper(clientOperation.MethodSignature, isAsync, clientOperation.IsPagingOperation); - private void WriteMethodBodyWrapper(MethodSignature signature, bool isAsync, bool isPaging) + protected void WriteMethodBodyWrapper(MethodSignature signature, bool isAsync, bool isPaging) { - var extensionClient = This.GetExtensionClient(null); - _writer.AppendRaw("return ") .AppendRawIf("await ", isAsync && !isPaging) - .Append($"{extensionClient.FactoryMethodName}({This.ExtensionParameter.Name}).{CreateMethodName(signature.Name, isAsync)}("); + .Append($"{This.MockableExtension.FactoryMethodName}({This.ExtensionParameter.Name}).{CreateMethodName(signature.Name, isAsync)}("); foreach (var parameter in signature.Parameters.Skip(1)) { @@ -64,60 +61,5 @@ private void WriteMethodBodyWrapper(MethodSignature signature, bool isAsync, boo .AppendRawIf(".ConfigureAwait(false)", isAsync && !isPaging) .LineRaw(";"); } - - protected override void WriteResourceCollectionEntry(ResourceCollection resourceCollection, MethodSignature signature) - { - if (IsArmCore) - { - base.WriteResourceCollectionEntry(resourceCollection, signature); - } - else - { - WriteMethodBodyWrapper(signature, false, false); - } - } - - protected override void WriteSingletonResourceEntry(Resource resource, SingletonResourceSuffix singletonResourceSuffix, MethodSignature signature) - { - _writer.UseNamespace(typeof(ResourceIdentifier).Namespace!); - if (IsArmCore) - { - base.WriteSingletonResourceEntry(resource, singletonResourceSuffix, signature); - } - else - { - WriteMethodBodyWrapper(signature, false, false); - } - } - - protected override void WriteResourceEntry(ResourceCollection resourceCollection, bool isAsync) - { - if (IsArmCore) - { - base.WriteResourceEntry(resourceCollection, isAsync); - } - else - { - var operation = resourceCollection.GetOperation; - string awaitText = isAsync & !operation.IsPagingOperation ? " await" : string.Empty; - string configureAwait = isAsync & !operation.IsPagingOperation ? ".ConfigureAwait(false)" : string.Empty; - _writer.Append($"return{awaitText} {GetResourceCollectionMethodName(resourceCollection)}({GetResourceCollectionMethodArgumentList(resourceCollection)}).{operation.MethodSignature.WithAsync(isAsync).Name}("); - - foreach (var parameter in operation.MethodSignature.Parameters) - { - _writer.Append($"{parameter.Name},"); - } - - _writer.RemoveTrailingComma(); - _writer.Line($"){configureAwait};"); - } - } - - protected override MethodSignatureModifiers GetMethodModifiers() => IsArmCore ? base.GetMethodModifiers() : Public | Static | Extension; - - protected override Parameter[] GetParametersForSingletonEntry() => IsArmCore ? base.GetParametersForSingletonEntry() : new[] { This.ExtensionParameter }; - - protected override Parameter[] GetParametersForCollectionEntry(ResourceCollection resourceCollection) - => IsArmCore ? base.GetParametersForCollectionEntry(resourceCollection) : resourceCollection.ExtraConstructorParameters.Prepend(This.ExtensionParameter).ToArray(); } } diff --git a/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionClientWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/MgmtMockableExtensionResourceWriter.cs similarity index 76% rename from src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionClientWriter.cs rename to src/AutoRest.CSharp/Mgmt/Generation/MgmtMockableExtensionResourceWriter.cs index 0e7d3967710..49bc70ef7ba 100644 --- a/src/AutoRest.CSharp/Mgmt/Generation/MgmtExtensionClientWriter.cs +++ b/src/AutoRest.CSharp/Mgmt/Generation/MgmtMockableExtensionResourceWriter.cs @@ -9,14 +9,19 @@ namespace AutoRest.CSharp.Mgmt.Generation { - internal sealed class MgmtExtensionClientWriter : MgmtClientBaseWriter + internal class MgmtMockableExtensionResourceWriter : MgmtClientBaseWriter { + public static MgmtMockableExtensionResourceWriter GetWriter(MgmtMockableExtension extensionClient) => extensionClient switch + { + MgmtMockableArmClient armClientExtensionClient => new ArmClientMockingExtensionWriter(armClientExtensionClient), + _ => new MgmtMockableExtensionResourceWriter(extensionClient) + }; + protected override bool UseField => false; - private MgmtExtensionClient This { get; } + private MgmtMockableExtension This { get; } - public MgmtExtensionClientWriter(MgmtExtensionClient extensions) - : base(new CodeWriter(), extensions) + public MgmtMockableExtensionResourceWriter(MgmtMockableExtension extensions) : base(new CodeWriter(), extensions) { This = extensions; } diff --git a/src/AutoRest.CSharp/Mgmt/Models/MgmtClientOperation.cs b/src/AutoRest.CSharp/Mgmt/Models/MgmtClientOperation.cs index ce1f44b85ce..052d970ddce 100644 --- a/src/AutoRest.CSharp/Mgmt/Models/MgmtClientOperation.cs +++ b/src/AutoRest.CSharp/Mgmt/Models/MgmtClientOperation.cs @@ -5,8 +5,10 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Text; using AutoRest.CSharp.Generation.Types; using AutoRest.CSharp.Generation.Writers; +using AutoRest.CSharp.Mgmt.AutoRest; using AutoRest.CSharp.Mgmt.Decorator; using AutoRest.CSharp.Mgmt.Output; using AutoRest.CSharp.Output.Models; @@ -27,18 +29,29 @@ namespace AutoRest.CSharp.Mgmt.Models internal class MgmtClientOperation : IReadOnlyList { private const int PropertyBagThreshold = 5; - private const string IdVariableName = "Id"; private readonly Parameter? _extensionParameter; - public static MgmtClientOperation? FromOperations(IReadOnlyList operations) + public static MgmtClientOperation? FromOperations(IReadOnlyList operations, FormattableString idVariableName, Parameter? extensionParameter = null, bool isConvenientOperation = false) { if (operations.Count > 0) { - return new MgmtClientOperation(operations.OrderBy(operation => operation.Name).ToArray(), null); + return new MgmtClientOperation(operations.OrderBy(operation => operation.Name).ToArray(), idVariableName, extensionParameter, isConvenientOperation); } return null; } + public static MgmtClientOperation FromOperation(MgmtRestOperation operation, FormattableString idVariableName, Parameter? extensionParameter = null, bool isConvenientOperation = false) + { + return new MgmtClientOperation(new List { operation }, idVariableName, extensionParameter, isConvenientOperation); + } + + public static MgmtClientOperation FromClientOperation(MgmtClientOperation other, FormattableString idVariableName, Parameter? extensionParameter = null, bool isConvenientOperation = false, IReadOnlyList? parameterOverride = null) + { + return new MgmtClientOperation(other._operations, idVariableName, extensionParameter, isConvenientOperation, parameterOverride); + } + + internal FormattableString IdVariableName { get; } + public Func? ReturnsDescription => _operations.First().ReturnsDescription; private IReadOnlyDictionary? _operationMappings; @@ -51,20 +64,22 @@ internal class MgmtClientOperation : IReadOnlyList public IReadOnlyList MethodParameters => _methodParameters ??= EnsureMethodParameters(); public IReadOnlyList PropertyBagUnderlyingParameters => IsPropertyBagOperation ? _passThroughParams : Array.Empty(); - public static MgmtClientOperation FromOperation(MgmtRestOperation operation, Parameter? extensionParameter = null, bool isConvenientOperation = false) - { - return new MgmtClientOperation(new List { operation }, extensionParameter, isConvenientOperation); - } private readonly IReadOnlyList _operations; - private MgmtClientOperation(IReadOnlyList operations, Parameter? extensionParameter, bool isConvenientOperation = false) + private MgmtClientOperation(IReadOnlyList operations, FormattableString idVariableName, Parameter? extensionParameter, bool isConvenientOperation = false) { _operations = operations; _extensionParameter = extensionParameter; + IdVariableName = idVariableName; IsConvenientOperation = isConvenientOperation; } + private MgmtClientOperation(IReadOnlyList operations, FormattableString idVariableName, Parameter? extensionParameter, bool isConvenientOperation = false, IReadOnlyList? parameterOverride = null) : this(operations, idVariableName, extensionParameter, isConvenientOperation) + { + _methodParameters = parameterOverride; + } + public bool IsConvenientOperation { get; } public MgmtRestOperation this[int index] => _operations[index]; @@ -104,10 +119,35 @@ private FormattableString BuildDescription() pathInformation = $@" {pathInformation} "; + FormattableString? mockingInformation; + if (_extensionParameter == null) + { + mockingInformation = null; + } + else + { + // find the corresponding extension of this method + var extendType = _extensionParameter.Type; + var mockingExtensionTypeName = MgmtMockableExtension.GetMockableExtensionDefaultName(extendType.Name); + // construct the cref name + var builder = new StringBuilder(Name); + builder.Append("("); + var paramList = MethodParameters.Skip(1).Select(p => p.Type.ToStringForDocs()); + builder.Append(string.Join(",", paramList)); + builder.Append(")"); + var methodRef = builder.ToString(); + + mockingInformation = $@" +Mocking +To mock this method, please mock instead. +"; + } + + FormattableString extraInformation = mockingInformation != null ? $"{pathInformation}{Environment.NewLine}{mockingInformation}" : pathInformation; var descriptionOfOperation = _operations.First().Description; if (descriptionOfOperation != null) - return $"{descriptionOfOperation}\n{pathInformation}"; - return pathInformation; + return $"{descriptionOfOperation}{Environment.NewLine}{extraInformation}"; + return extraInformation; } // TODO -- we need a better way to get this diff --git a/src/AutoRest.CSharp/Mgmt/Models/SingletonResourceSuffix.cs b/src/AutoRest.CSharp/Mgmt/Models/SingletonResourceSuffix.cs index 130fd3d540e..6353ca891e2 100644 --- a/src/AutoRest.CSharp/Mgmt/Models/SingletonResourceSuffix.cs +++ b/src/AutoRest.CSharp/Mgmt/Models/SingletonResourceSuffix.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; using System.Linq; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; using AutoRest.CSharp.Generation.Writers; using Azure.Core; +using static AutoRest.CSharp.Common.Output.Models.Snippets; namespace AutoRest.CSharp.Mgmt.Models { @@ -30,29 +32,36 @@ private SingletonResourceSuffix(IReadOnlyList<(string Key, string Value)> pairs) _pairs = pairs; } - public FormattableString BuildResourceIdentifier(FormattableString originalId) + public ValueExpression BuildResourceIdentifier(ValueExpression originalId) { - var list = new List() { originalId }; + var result = originalId; for (int i = 0; i < _pairs.Count; i++) { - var key = _pairs[i].Key; - var value = _pairs[i].Value; + var (key, value) = _pairs[i]; if (key == Segment.Providers) { - // when we have a providers, we must have a next pair + // when we have a providers segment, we must have a next pair i++; - var nextKey = _pairs[i].Key; - var nextValue = _pairs[i].Value; - list.Add($"{nameof(ResourceIdentifier.AppendProviderResource)}({value:L}, {nextKey:L}, {nextValue:L})"); + var (nextKey, nextValue) = _pairs[i]; + // build expression: => .AppendProviderResource(value, nextKey, nextValue) + result = new InvokeStaticMethodExpression( + typeof(ResourceIdentifier), + nameof(ResourceIdentifier.AppendProviderResource), + new[] { result, Literal(value), Literal(nextKey), Literal(nextValue) }, + CallAsExtension: true); } else { // if not, we just call the method to append this pair - list.Add($"{nameof(ResourceIdentifier.AppendChildResource)}({key:L}, {value:L})"); + result = new InvokeStaticMethodExpression( + typeof(ResourceIdentifier), + nameof(ResourceIdentifier.AppendChildResource), + new[] { result, Literal(key), Literal(value) }, + CallAsExtension: true); } } - return list.Join("."); + return result; } public override string ToString() diff --git a/src/AutoRest.CSharp/Mgmt/Output/ArmClientExtension.cs b/src/AutoRest.CSharp/Mgmt/Output/ArmClientExtension.cs index c5bba11c845..ce36d9950b4 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/ArmClientExtension.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/ArmClientExtension.cs @@ -1,25 +1,229 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License +using System; using System.Collections.Generic; using System.Linq; +using AutoRest.CSharp.Common.Output.Expressions.Statements; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; +using AutoRest.CSharp.Common.Output.Models; +using AutoRest.CSharp.Generation.Writers; using AutoRest.CSharp.Common.Input; using AutoRest.CSharp.Input; using AutoRest.CSharp.Mgmt.AutoRest; +using AutoRest.CSharp.Mgmt.Decorator; using AutoRest.CSharp.Mgmt.Models; +using AutoRest.CSharp.Output.Models; +using AutoRest.CSharp.Output.Models.Shared; +using Azure.Core; using Azure.ResourceManager; namespace AutoRest.CSharp.Mgmt.Output { internal class ArmClientExtension : MgmtExtension { - public ArmClientExtension(IEnumerable allOperations) - : base(allOperations, Enumerable.Empty(), typeof(ArmClient), RequestPath.Tenant) + private readonly List _extensions; + private readonly ArmResourceExtension _armResourceExtensionForChildResources; + public ArmClientExtension(IReadOnlyDictionary> armResourceExtensionOperations, IEnumerable extensionClients, ArmResourceExtension armResourceExtensionForChildResources) + : base(Enumerable.Empty(), extensionClients, typeof(ArmClient), RequestPath.Tenant) { + _armResourceExtensionForChildResources = armResourceExtensionForChildResources; + _extensions = new(); + foreach (var (parentRequestPath, operations) in armResourceExtensionOperations) + { + _extensions.Add(new(operations, extensionClients, typeof(ArmResource), parentRequestPath)); + } } - public override bool IsEmpty => !MgmtContext.Library.ArmResources.Any(); + public override bool IsEmpty => !MgmtContext.Library.ArmResources.Any() && base.IsEmpty; protected override string VariableName => Configuration.MgmtConfiguration.IsArmCore ? "this" : "client"; + + public override FormattableString IdVariableName => $"scope"; + public override FormattableString BranchIdVariableName => $"scope"; + + protected override IEnumerable EnsureClientOperations() + { + var extensionParamToUse = Configuration.MgmtConfiguration.IsArmCore ? null : ExtensionParameter; + foreach (var extension in _extensions) + { + foreach (var clientOperation in extension.ClientOperations) + { + var requestPaths = clientOperation.Select(restOperation => restOperation.RequestPath); + var scopeResourceTypes = requestPaths.Select(requestPath => requestPath.GetParameterizedScopeResourceTypes() ?? Enumerable.Empty()).SelectMany(types => types).Distinct(); + var scopeTypes = ResourceTypeBuilder.GetScopeTypeStrings(scopeResourceTypes); + var parameterOverride = clientOperation.MethodParameters.Skip(1).Prepend(GetScopeParameter(scopeTypes)).Prepend(ExtensionParameter).ToArray(); + var newOp = MgmtClientOperation.FromClientOperation(clientOperation, IdVariableName, extensionParameter: extensionParamToUse, parameterOverride: parameterOverride); + yield return newOp; + } + } + } + + // only when in usual packages other than arm core, we need to generate the ArmClient, scope pattern for those scope resources + public override IEnumerable ChildResources => Configuration.MgmtConfiguration.IsArmCore ? Enumerable.Empty() : _armResourceExtensionForChildResources.AllChildResources; + + private readonly Parameter _scopeParameter = new Parameter( + Name: "scope", + Description: $"The scope that the resource will apply against.", + Type: typeof(ResourceIdentifier), + DefaultValue: null, + Validation: ValidationType.None, + Initializer: null); + + private Parameter GetScopeParameter(ICollection? types) + { + if (types == null) + return _scopeParameter; + + return _scopeParameter with + { + Description = $"{_scopeParameter.Description} Expected resource type includes the following: {types.Join(", ", " or ")}" + }; + } + + protected override Method BuildMockableExtensionFactoryMethod() + { + var signature = new MethodSignature( + MockableExtension.FactoryMethodName, + null, + null, + MethodSignatureModifiers.Private | MethodSignatureModifiers.Static, + MockableExtension.Type, + null, + new[] { ArmClientParameter }); + + var extensionVariable = (ValueExpression)ArmClientParameter; + var clientVariable = new VariableReference(typeof(ArmClient), "client"); + var body = Snippets.Return( + extensionVariable.Invoke(nameof(ArmClient.GetCachedClient), + new FuncExpression(new[] { clientVariable.Declaration }, Snippets.New.Instance(MockableExtension.Type, clientVariable)) + )); + return new(signature, body); + } + + protected override Method BuildGetSingletonResourceMethod(Resource resource) + { + var originalMethod = base.BuildGetSingletonResourceMethod(resource); + if (IsArmCore) + return originalMethod; + + // we need to add a scope parameter inside the method signature + var originalSignature = (MethodSignature)originalMethod.Signature; + var scopeTypes = ResourceTypeBuilder.GetScopeTypeStrings(resource.RequestPath.GetParameterizedScopeResourceTypes()); + var parameters = new List() + { + // add the first parameter, which is the extension parameter + originalSignature.Parameters[0], + // then we add the scope parameter + GetScopeParameter(scopeTypes) + }; + parameters.AddRange(originalSignature.Parameters.Skip(1)); // add all remaining parameters + var signatureOnMockingExtension = originalSignature with + { + Modifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual, + Parameters = parameters.Skip(1).ToArray() + }; + var signature = originalSignature with + { + Description = $"{BuildDescriptionForSingletonResource(resource)}{Environment.NewLine}{BuildMockingExtraDescription(signatureOnMockingExtension)}", + Parameters = parameters + }; + + return BuildRedirectCallToMockingExtension(signature, signatureOnMockingExtension); + } + + protected override Method BuildGetChildCollectionMethod(ResourceCollection collection) + { + var originalMethod = base.BuildGetChildCollectionMethod(collection); + if (IsArmCore) + return originalMethod; + + // we need to add a scope parameter inside the method signature + var originalSignature = (MethodSignature)originalMethod.Signature; + var scopeTypes = ResourceTypeBuilder.GetScopeTypeStrings(collection.RequestPath.GetParameterizedScopeResourceTypes()); + var parameters = new List() + { + // add the first parameter, which is the extension parameter + originalSignature.Parameters[0], + // then we add the scope parameter + GetScopeParameter(scopeTypes) + }; + parameters.AddRange(originalSignature.Parameters.Skip(1)); // add all remaining parameters + var signatureOnMockingExtension = originalSignature with + { + Modifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual, + Parameters = parameters.Skip(1).ToArray() + }; + var signature = originalSignature with + { + Description = $"{BuildDescriptionForChildCollection(collection)}{Environment.NewLine}{BuildMockingExtraDescription(signatureOnMockingExtension)}", + Parameters = parameters + }; + + return BuildRedirectCallToMockingExtension(signature, signatureOnMockingExtension); + } + + private IEnumerable? _armResourceMethods; + public IEnumerable ArmResourceMethods => _armResourceMethods ??= BuildArmResourceMethods(); + + private IEnumerable BuildArmResourceMethods() + { + foreach (var resource in MgmtContext.Library.ArmResources) + { + yield return BuildArmResourceMethod(resource); + } + } + + private Method BuildArmResourceMethod(Resource resource) + { + var lines = new List(); + string an = resource.Type.Name.StartsWithVowel() ? "an" : "a"; + lines.Add($"Gets an object representing {an} along with the instance operations that can be performed on it but with no data."); + lines.Add($"You can use to create {an} from its components."); + var description = FormattableStringHelpers.Join(lines, Environment.NewLine); + + var parameters = new List + { + _resourceIdParameter + }; + + var signatureOnMockingExtension = new MethodSignature( + $"Get{resource.Type.Name}", + null, + description, + MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual, + resource.Type, + $"Returns a object.", + parameters); + + if (IsArmCore) + { + var methodBody = new MethodBodyStatement[]{ + new InvokeStaticMethodStatement(resource.Type, "ValidateResourceId", _resourceIdParameter), + Snippets.Return(Snippets.New.Instance(resource.Type, Snippets.This, _resourceIdParameter)) + }; + + return new(signatureOnMockingExtension, methodBody); + } + else + { + var signature = signatureOnMockingExtension with + { + Description = $"{description}{Environment.NewLine}{BuildMockingExtraDescription(signatureOnMockingExtension)}", + Modifiers = MethodModifiers, + Parameters = parameters.Prepend(ExtensionParameter).ToArray() + }; + + return BuildRedirectCallToMockingExtension(signature, signatureOnMockingExtension); + } + } + + private readonly Parameter _resourceIdParameter = new( + Name: "id", + Description: $"The resource ID of the resource to get.", + Type: typeof(ResourceIdentifier), + DefaultValue: null, + Validation: ValidationType.None, + Initializer: null); } } diff --git a/src/AutoRest.CSharp/Mgmt/Output/ArmResourceExtension.cs b/src/AutoRest.CSharp/Mgmt/Output/ArmResourceExtension.cs index b56147ec75e..4640f2fa359 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/ArmResourceExtension.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/ArmResourceExtension.cs @@ -4,8 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using AutoRest.CSharp.Common.Input; using AutoRest.CSharp.Input; using AutoRest.CSharp.Mgmt.Models; using Azure.ResourceManager; @@ -15,7 +14,7 @@ namespace AutoRest.CSharp.Mgmt.Output internal class ArmResourceExtension : MgmtExtension { private readonly List _extensions; - public ArmResourceExtension(IReadOnlyDictionary> armResourceExtensionOperations, IEnumerable extensionClients) : base(Enumerable.Empty(), extensionClients, typeof(ArmResource), RequestPath.Any) + public ArmResourceExtension(IReadOnlyDictionary> armResourceExtensionOperations, IEnumerable extensionClients) : base(Enumerable.Empty(), extensionClients, typeof(ArmResource), RequestPath.Any) { _extensions = new(); foreach (var (parentRequestPath, operations) in armResourceExtensionOperations) @@ -28,8 +27,42 @@ protected override IEnumerable EnsureClientOperations() { foreach (var extension in _extensions) { - foreach (var operation in extension.ClientOperations) - yield return operation; + foreach (var clientOperation in extension.ClientOperations) + { + var requestPaths = clientOperation.Select(restOperation => restOperation.RequestPath); + if (ShouldGenerateArmResourceExtensionMethod(requestPaths)) + yield return clientOperation; + } + } + } + + private static bool ShouldGenerateArmResourceExtensionMethod(IEnumerable requestPaths) + => requestPaths.Any(ShouldGenerateArmResourceExtensionMethod); + + private static bool ShouldGenerateArmResourceExtensionMethod(RequestPath requestPath) + => Configuration.MgmtConfiguration.GenerateArmResourceExtensions.Contains(requestPath); + + /// + /// This tracks all resources with a parent of ArmResource + /// We need this to keep the original data of all possible child resources of ArmResource and we will use it again in ArmClientExtension + /// + internal IEnumerable AllChildResources => base.ChildResources; + + private IEnumerable? _filteredArmResourceChildResource; + /// + /// We need to filter out some resources here + /// because in the design of generated code for ArmResourceExtension, we usually do not generate an extension method that extends ArmResource type + /// instead we generate an extension method of ArmClient with a scope instead to avoid that the extension method shows up on every resource + /// because in real life it is not quite possible. + /// + public override IEnumerable ChildResources => _filteredArmResourceChildResource ??= EnsureArmResourceExtensionChildResources(); + + private IEnumerable EnsureArmResourceExtensionChildResources() + { + foreach (var resource in AllChildResources) + { + if (ShouldGenerateArmResourceExtensionMethod(resource.RequestPath)) + yield return resource; } } } diff --git a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtension.cs b/src/AutoRest.CSharp/Mgmt/Output/MgmtExtension.cs index e70b9b9682d..97fa791b86d 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtension.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/MgmtExtension.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Linq; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; +using AutoRest.CSharp.Common.Output.Models; using AutoRest.CSharp.Common.Input; using AutoRest.CSharp.Generation.Types; using AutoRest.CSharp.Input; @@ -13,6 +15,8 @@ using AutoRest.CSharp.Output.Models; using AutoRest.CSharp.Output.Models.Shared; using AutoRest.CSharp.Utilities; +using Azure.ResourceManager; +using Humanizer.Localisation; namespace AutoRest.CSharp.Mgmt.Output { @@ -22,11 +26,11 @@ internal class MgmtExtension : MgmtTypeProvider private readonly IEnumerable _allRawOperations; - public MgmtExtension(IEnumerable allRawOperations, IEnumerable extensionClients, Type armCoreType, RequestPath? contextualPath = null) + public MgmtExtension(IEnumerable allRawOperations, IEnumerable mockingExtensions, Type armCoreType, RequestPath? contextualPath = null) : base(armCoreType.Name) { _allRawOperations = allRawOperations; - _extensionClients = extensionClients; // this property is populated later + _mockingExtensions = mockingExtensions; // this property is populated later ArmCoreType = armCoreType; DefaultName = Configuration.MgmtConfiguration.IsArmCore ? ResourceName : $"{ResourceName}Extensions"; DefaultNamespace = Configuration.MgmtConfiguration.IsArmCore ? ArmCoreType.Namespace! : base.DefaultNamespace; @@ -34,6 +38,17 @@ public MgmtExtension(IEnumerable allRawOperations, IEnumerable(); + ExtensionParameter = new Parameter( + VariableName, + $"The instance the method will execute against.", + ArmCoreType, + null, + ValidationType.None, + null); + + MethodModifiers = IsArmCore ? + MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual : + MethodSignatureModifiers.Public | MethodSignatureModifiers.Static | MethodSignatureModifiers.Extension; } protected override ConstructorSignature? EnsureMockingCtor() @@ -41,20 +56,9 @@ public MgmtExtension(IEnumerable allRawOperations, IEnumerable $"{ExtensionParameter.Name}.Id"; + public override FormattableString BranchIdVariableName => $"{ExtensionParameter.Name}.Id"; - private Parameter? _extensionParameter; - public Parameter ExtensionParameter => _extensionParameter ??= EnsureExtensionParameter(); - private Parameter EnsureExtensionParameter() - { - return new Parameter( - VariableName, - $"The instance the method will execute against.", - ArmCoreType, - null, - ValidationType.None, - null); - } + public Parameter ExtensionParameter { get; } protected virtual string VariableName => Configuration.MgmtConfiguration.IsArmCore ? "this" : ArmCoreType.Name.ToVariableName(); @@ -99,6 +103,7 @@ protected override IEnumerable EnsureClientOperations() ContextualPath, operationName, propertyBagName: ResourceName), + BranchIdVariableName, extensionParamToUse); }); } @@ -158,19 +163,138 @@ private IEnumerable GetExtraLayers(RequestPath requestPath, Resource re return null; } - public MgmtExtensionClient GetExtensionClient(CSharpType? resourceType) + + private Method? _mockingExtensionFactoryMethod; + public Method MockingExtensionFactoryMethod => _mockingExtensionFactoryMethod ??= BuildMockableExtensionFactoryMethod(); + + protected virtual Method BuildMockableExtensionFactoryMethod() { - if (resourceType != null && Cache.TryGetValue(resourceType, out var extensionClient)) - return extensionClient; + var signature = new MethodSignature( + MockableExtension.FactoryMethodName, + null, + null, + MethodSignatureModifiers.Private | MethodSignatureModifiers.Static, + MockableExtension.Type, + null, + new[] { _generalExtensionParameter }); + + var extensionVariable = (ValueExpression)_generalExtensionParameter; + var clientVariable = new VariableReference(typeof(ArmClient), "client"); + var body = Snippets.Return( + extensionVariable.Invoke( + nameof(ArmResource.GetCachedClient), + new FuncExpression(new[] { clientVariable.Declaration }, Snippets.New.Instance(MockableExtension.Type, clientVariable, extensionVariable.Property(nameof(ArmResource.Id)))) + )); - return Cache[ArmCoreType]; + return new(signature, body); } - private readonly IEnumerable _extensionClients; + private readonly Parameter _generalExtensionParameter = new Parameter( + "resource", + $"The resource parameters to use in these operations.", + typeof(ArmResource), + null, + ValidationType.None, + null); - private Dictionary? _cache; - private Dictionary Cache => _cache ??= _extensionClients.ToDictionary( + public MgmtMockableExtension MockableExtension => Cache[ArmCoreType]; + + private readonly IEnumerable _mockingExtensions; + + private Dictionary? _cache; + private Dictionary Cache => _cache ??= _mockingExtensions.ToDictionary( extensionClient => extensionClient.ExtendedResourceType, extensionClient => extensionClient); + + /// + /// Build the implementation of methods in the extension. + /// It calls the factory method of the mocking extension first, and then calls the method wtih the same name and parameter list on the mocking extension + /// + /// + /// + /// + /// + protected Method BuildRedirectCallToMockingExtension(MethodSignature signature, MethodSignature signatureOnMockingExtension) + { + var callFactoryMethod = new InvokeInstanceMethodExpression(null, (MethodSignature)MockingExtensionFactoryMethod.Signature, new[] { (ValueExpression)signature.Parameters[0] }, false); + + var callMethodOnMockingExtension = callFactoryMethod.Invoke(signatureOnMockingExtension); + + var methodBody = Snippets.Return(callMethodOnMockingExtension); + + return new(signature, methodBody); + } + + protected FormattableString BuildMockingExtraDescription(MethodSignature signatureOnMockingExtension) + { + var methodRef = signatureOnMockingExtension.ToStringForDocs(); + return $@" +Mocking +To mock this method, please mock instead. +"; + } + + protected override Method BuildGetSingletonResourceMethod(Resource resource) + { + var originalMethod = base.BuildGetSingletonResourceMethod(resource); + if (IsArmCore) + return originalMethod; + + // if it not arm core, we should generate these methods in a static extension way + var originalSignature = (MethodSignature)originalMethod.Signature; + var signatureOnMockingExtension = originalSignature with + { + Modifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual + }; + var signature = originalSignature with + { + Description = $"{BuildDescriptionForSingletonResource(resource)}{Environment.NewLine}{BuildMockingExtraDescription(signatureOnMockingExtension)}", + Parameters = originalSignature.Parameters.Prepend(ExtensionParameter).ToArray() + }; + + return BuildRedirectCallToMockingExtension(signature, signatureOnMockingExtension); + } + + protected override Method BuildGetChildCollectionMethod(ResourceCollection collection) + { + var originalMethod = base.BuildGetChildCollectionMethod(collection); + if (IsArmCore) + return originalMethod; + + // if it not arm core, we should generate these methods in a static extension way + var originalSignature = (MethodSignature)originalMethod.Signature; + var signatureOnMockingExtension = originalSignature with + { + Modifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual + }; + var signature = originalSignature with + { + Description = $"{BuildDescriptionForChildCollection(collection)}{Environment.NewLine}{BuildMockingExtraDescription(signatureOnMockingExtension)}", + Parameters = originalSignature.Parameters.Prepend(ExtensionParameter).ToArray() + }; + + return BuildRedirectCallToMockingExtension(signature, signatureOnMockingExtension); + } + + protected override Method BuildGetChildResourceMethod(ResourceCollection collection, MethodSignatureBase getCollectionMethodSignature, bool isAsync) + { + var originalMethod = base.BuildGetChildResourceMethod(collection, getCollectionMethodSignature, isAsync); + if (IsArmCore) + return originalMethod; + + var originalSignature = (MethodSignature)originalMethod.Signature; + var signatureOnMockingExtension = (originalSignature.WithAsync(false) with + { + Modifiers = MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual, + Parameters = originalSignature.Parameters.Skip(1).ToArray() + }).WithAsync(isAsync); + var signature = originalSignature with + { + Description = $"{BuildDescriptionForChildResource(collection)}{Environment.NewLine}{BuildMockingExtraDescription(signatureOnMockingExtension)}" + }; + + // if it not arm core, we should generate these methods in a static extension way + return BuildRedirectCallToMockingExtension(signature, signatureOnMockingExtension); + } } } diff --git a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionBuilder.cs b/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionBuilder.cs index acee0b6e955..dcef4668013 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionBuilder.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionBuilder.cs @@ -8,19 +8,18 @@ using AutoRest.CSharp.Mgmt.Models; using AutoRest.CSharp.Utilities; using Azure.ResourceManager; -using Azure.ResourceManager.Resources; namespace AutoRest.CSharp.Mgmt.Output { internal class MgmtExtensionBuilder { - private record MgmtExtensionInfo(IReadOnlyDictionary ExtensionDict, IEnumerable ExtensionClients) + private record MgmtExtensionInfo(IReadOnlyDictionary ExtensionDict, IEnumerable MockableExtensions) { private IEnumerable? _extensions; public IEnumerable Extensions => _extensions ??= ExtensionDict.Values; private MgmtExtensionWrapper? _extensionWrapper; - public MgmtExtensionWrapper ExtensionWrapper => _extensionWrapper ??= new MgmtExtensionWrapper(Extensions, ExtensionClients); + public MgmtExtensionWrapper ExtensionWrapper => _extensionWrapper ??= new MgmtExtensionWrapper(Extensions, MockableExtensions); } private readonly IReadOnlyDictionary> _extensionOperations; @@ -36,7 +35,7 @@ public MgmtExtensionBuilder(Dictionary> extensionOp public IEnumerable Extensions => ExtensionInfo.Extensions; - public IEnumerable ExtensionClients => ExtensionInfo.ExtensionClients; + public IEnumerable MockableExtensions => ExtensionInfo.MockableExtensions; public MgmtExtension GetExtension(Type armCoreType) { @@ -50,26 +49,25 @@ private MgmtExtensionInfo EnsureMgmtExtensionInfo() { // we use a SortedDictionary or SortedSet here to make sure the order of extensions or extension clients is deterministic var extensionDict = new SortedDictionary(new CSharpTypeNameComparer()); - var extensionClients = new SortedSet(new MgmtExtensionClientComparer()); + var mockingExtensions = new SortedSet(new MgmtExtensionClientComparer()); // create the extensions foreach (var (type, operations) in _extensionOperations) { - var extension = new MgmtExtension(operations, extensionClients, type); + var extension = new MgmtExtension(operations, mockingExtensions, type); extensionDict.Add(type, extension); } // add ArmResourceExtension methods - extensionDict.Add(typeof(ArmResource), new ArmResourceExtension(_armResourceExtensionOperations, extensionClients)); - // add the ArmClientExtension - extensionDict.Add(typeof(ArmClient), new ArmClientExtension(_extensionOperations[typeof(TenantResource)])); + var armResourceExtension = new ArmResourceExtension(_armResourceExtensionOperations, mockingExtensions); + // add ArmClientExtension methods (which is also the TenantResource extension methods) + var armClientExtension = new ArmClientExtension(_armResourceExtensionOperations, mockingExtensions, armResourceExtension); + extensionDict.Add(typeof(ArmResource), armResourceExtension); + extensionDict.Add(typeof(ArmClient), armClientExtension); // construct all possible extension clients // first we collection all possible combinations of the resource on operations var resourceToOperationsDict = new Dictionary>(); foreach (var (type, extension) in extensionDict) { - // explicitly skip ArmClient because it should not have an extension client - if (type.Equals(typeof(ArmClient))) - continue; // we add an empty list for the type to ensure that the corresponding extension client will always be constructed, even empty resourceToOperationsDict.Add(type, new()); foreach (var operation in extension.AllOperations) @@ -82,10 +80,13 @@ private MgmtExtensionInfo EnsureMgmtExtensionInfo() { // find the extension if the resource type here is a framework type (when it is ResourceGroupResource, SubscriptionResource, etc) to ensure the ExtensionClient could property have the child resources extensionDict.TryGetValue(resourceType, out var extensionForChildResources); - extensionClients.Add(new MgmtExtensionClient(resourceType, operations, extensionForChildResources)); + var extensionClient = resourceType.Equals(typeof(ArmClient)) ? + new MgmtMockableArmClient(resourceType, operations, extensionForChildResources) : + new MgmtMockableExtension(resourceType, operations, extensionForChildResources); + mockingExtensions.Add(extensionClient); } - return new(extensionDict, extensionClients); + return new(extensionDict, mockingExtensions); } private struct CSharpTypeNameComparer : IComparer @@ -96,9 +97,9 @@ public int Compare(CSharpType? x, CSharpType? y) } } - private struct MgmtExtensionClientComparer : IComparer + private struct MgmtExtensionClientComparer : IComparer { - public int Compare(MgmtExtensionClient? x, MgmtExtensionClient? y) + public int Compare(MgmtMockableExtension? x, MgmtMockableExtension? y) { return string.Compare(x?.Declaration.Name, y?.Declaration.Name); } diff --git a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionWrapper.cs b/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionWrapper.cs index f7c5ab556fb..cc1cd4253c4 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionWrapper.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionWrapper.cs @@ -20,18 +20,18 @@ internal class MgmtExtensionWrapper : MgmtTypeProvider { public IEnumerable Extensions { get; } - public IEnumerable ExtensionClients { get; } + public IEnumerable MockingExtensions { get; } public override bool IsStatic => true; public bool IsEmpty => Extensions.All(extension => extension.IsEmpty); - public MgmtExtensionWrapper(IEnumerable extensions, IEnumerable extensionClients) : base(MgmtContext.RPName) + public MgmtExtensionWrapper(IEnumerable extensions, IEnumerable mockingExtensions) : base(MgmtContext.RPName) { DefaultName = $"{ResourceName}Extensions"; Description = Configuration.MgmtConfiguration.IsArmCore ? (FormattableString)$"" : $"A class to add extension methods to {MgmtContext.Context.DefaultNamespace}."; Extensions = extensions; - ExtensionClients = extensionClients; + MockingExtensions = mockingExtensions; } public override CSharpType? BaseType => null; diff --git a/src/AutoRest.CSharp/Mgmt/Output/MgmtMockableArmClient.cs b/src/AutoRest.CSharp/Mgmt/Output/MgmtMockableArmClient.cs new file mode 100644 index 00000000000..5f1c652e332 --- /dev/null +++ b/src/AutoRest.CSharp/Mgmt/Output/MgmtMockableArmClient.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License + +using System; +using System.Collections.Generic; +using System.Linq; +using AutoRest.CSharp.Common.Output.Expressions.KnownValueExpressions; +using AutoRest.CSharp.Common.Output.Expressions.Statements; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; +using AutoRest.CSharp.Common.Output.Models; +using AutoRest.CSharp.Generation.Types; +using AutoRest.CSharp.Generation.Writers; +using AutoRest.CSharp.Mgmt.AutoRest; +using AutoRest.CSharp.Mgmt.Decorator; +using AutoRest.CSharp.Mgmt.Models; +using AutoRest.CSharp.Output.Models; +using AutoRest.CSharp.Output.Models.Shared; +using Azure.Core; + +namespace AutoRest.CSharp.Mgmt.Output +{ + internal class MgmtMockableArmClient : MgmtMockableExtension + { + public MgmtMockableArmClient(CSharpType resourceType, IEnumerable operations, MgmtExtension? extensionForChildResources) : base(resourceType, operations, extensionForChildResources) + { + } + + public override FormattableString IdVariableName => $"scope"; + + public override FormattableString BranchIdVariableName => $"scope"; + + public override bool IsEmpty => !ClientOperations.Any() && !MgmtContext.Library.ArmResources.Any(); + + protected override Method BuildGetSingletonResourceMethod(Resource resource) + { + var originalMethod = base.BuildGetSingletonResourceMethod(resource); + if (IsArmCore) + return originalMethod; + + // we need to add a scope parameter inside the method signature + var originalSignature = (MethodSignature)originalMethod.Signature; + var signature = originalSignature with + { + Parameters = originalSignature.Parameters.Prepend(_scopeParameter).ToArray() + }; + + var scopeTypes = resource.RequestPath.GetParameterizedScopeResourceTypes(); + var methodBody = new MethodBodyStatement[] + { + BuildScopeResourceTypeValidations(scopeTypes), + Snippets.Return( + Snippets.New.Instance(resource.Type, ArmClientProperty, resource.SingletonResourceIdSuffix!.BuildResourceIdentifier(_scopeParameter))) + }; + + return new(signature, methodBody); + } + + protected override Method BuildGetChildCollectionMethod(ResourceCollection collection) + { + var originalMethod = base.BuildGetChildCollectionMethod(collection); + if (IsArmCore) + return originalMethod; + + // we need to add a scope parameter inside the method signature + var originalSignature = (MethodSignature)originalMethod.Signature; + var signature = originalSignature with + { + Parameters = originalSignature.Parameters.Prepend(_scopeParameter).ToArray() + }; + + var scopeTypes = collection.RequestPath.GetParameterizedScopeResourceTypes(); + var ctorArguments = new List + { + ArmClientProperty, + _scopeParameter + }; + ctorArguments.AddRange(originalSignature.Parameters.Select(p => (ValueExpression)p)); + var methodBody = new MethodBodyStatement[] + { + BuildScopeResourceTypeValidations(scopeTypes), + Snippets.Return( + Snippets.New.Instance(collection.Type, ctorArguments.ToArray())) + }; + + return new(signature, methodBody); + } + + private MethodBodyStatement BuildScopeResourceTypeValidations(ResourceTypeSegment[]? scopeTypes) + { + if (scopeTypes is null || !scopeTypes.Any() || scopeTypes.Contains(ResourceTypeSegment.Any)) + return MethodBodyStatement.Empty; + + var scopeVariable = (ValueExpression)_scopeParameter; + var resourceTypeVariable = new ResourceIdentifierExpression(_scopeParameter).ResourceType; + var conditions = new List(); + var resourceTypeStrings = new List(); + foreach (var type in scopeTypes) + { + // here we have an expression of `!scope.ResourceType.Equals("")` + conditions.Add( + resourceTypeVariable.InvokeEquals(Snippets.Literal(type.ToString())).Not() + ); + resourceTypeStrings.Add($"{type}"); + } + + // here we aggregate them together using or operator || and get: scope.ResourceType.Equals("") || scope.ResourceType.Equals("") + var condition = conditions.Aggregate((a, b) => a.Or(b)); + var errorMessageFormat = $"Invalid resource type {{0}}, expected {resourceTypeStrings.Join(", ", " or ")}"; + return new IfStatement(condition) + { + Snippets.Throw( + Snippets.New.Instance( + typeof(ArgumentException), + new InvokeStaticMethodExpression( + typeof(string), + nameof(string.Format), + new ValueExpression[] { Snippets.Literal(errorMessageFormat), resourceTypeVariable }) + )) + }; + } + + private IEnumerable? _armResourceMethods; + public IEnumerable ArmResourceMethods => _armResourceMethods ??= BuildArmResourceMethods(); + + private IEnumerable BuildArmResourceMethods() + { + foreach (var resource in MgmtContext.Library.ArmResources) + { + yield return BuildArmResourceMethod(resource); + } + } + + private Method BuildArmResourceMethod(Resource resource) + { + var lines = new List(); + string an = resource.Type.Name.StartsWithVowel() ? "an" : "a"; + lines.Add($"Gets an object representing {an} along with the instance operations that can be performed on it but with no data."); + lines.Add($"You can use to create {an} from its components."); + var description = FormattableStringHelpers.Join(lines, Environment.NewLine); + + var parameters = new List + { + _resourceIdParameter + }; + + var signature = new MethodSignature( + $"Get{resource.Type.Name}", + null, + description, + MethodModifiers, + resource.Type, + $"Returns a object.", + parameters); + + var methodBody = new MethodBodyStatement[]{ + new InvokeStaticMethodStatement(resource.Type, "ValidateResourceId", _resourceIdParameter), + Snippets.Return(Snippets.New.Instance(resource.Type, ArmClientProperty, _resourceIdParameter)) + }; + + return new(signature, methodBody); + } + + private readonly Parameter _resourceIdParameter = new( + Name: "id", + Description: $"The resource ID of the resource to get.", + Type: typeof(ResourceIdentifier), + DefaultValue: null, + Validation: ValidationType.None, + Initializer: null); + + private readonly Parameter _scopeParameter = new Parameter( + Name: "scope", + Description: $"The scope that the resource will apply against.", + Type: typeof(ResourceIdentifier), + DefaultValue: null, + Validation: ValidationType.None, + Initializer: null); + } +} diff --git a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionClient.cs b/src/AutoRest.CSharp/Mgmt/Output/MgmtMockableExtension.cs similarity index 56% rename from src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionClient.cs rename to src/AutoRest.CSharp/Mgmt/Output/MgmtMockableExtension.cs index 662d9dd039a..70f26d9c64f 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/MgmtExtensionClient.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/MgmtMockableExtension.cs @@ -6,35 +6,35 @@ using System.Linq; using System.Text; using AutoRest.CSharp.Generation.Types; -using AutoRest.CSharp.Generation.Writers; +using AutoRest.CSharp.Mgmt.AutoRest; using AutoRest.CSharp.Mgmt.Decorator; using AutoRest.CSharp.Mgmt.Models; using AutoRest.CSharp.Output.Models; -using AutoRest.CSharp.Output.Models.Shared; using AutoRest.CSharp.Utilities; -using Azure.Core; using Azure.ResourceManager; using static AutoRest.CSharp.Output.Models.MethodSignatureModifiers; namespace AutoRest.CSharp.Mgmt.Output { - internal class MgmtExtensionClient : MgmtTypeProvider + internal class MgmtMockableExtension : MgmtTypeProvider { private readonly IEnumerable _operations; private readonly MgmtExtension? _extensionForChildResources; - public MgmtExtensionClient(CSharpType resourceType, IEnumerable operations, MgmtExtension? extensionForChildResources) + public MgmtMockableExtension(CSharpType resourceType, IEnumerable operations, MgmtExtension? extensionForChildResources) : base(resourceType.Name) { _operations = operations; _extensionForChildResources = extensionForChildResources; ExtendedResourceType = resourceType; - DefaultName = $"{ResourceName}ExtensionClient"; + // name of this class is like "MockableComputeResourceGroupResource" + DefaultName = GetMockableExtensionDefaultName(resourceType.Name); } - public override bool IsInitializedByProperties => true; + internal static string GetMockableExtensionDefaultName(string resourceName) + => $"Mockable{MgmtContext.RPName}{resourceName}"; - public override bool HasChildResourceGetMethods => false; + public override bool IsInitializedByProperties => true; protected override ConstructorSignature? EnsureArmClientCtor() { @@ -52,64 +52,6 @@ public MgmtExtensionClient(CSharpType resourceType, IEnumerable _factoryMethodName ??= $"Get{Declaration.Name}"; - private IEnumerable? _factoryMethods; - public IEnumerable FactoryMethods => _factoryMethods ??= EnsureFactoryMethods(); - - private IEnumerable EnsureFactoryMethods() - { - var resourceExtensionMethod = new MethodSignature( - FactoryMethodName, - null, - null, - Private | Static, - Type, - null, - new[] { _generalExtensionParameter }); - Action resourceExtensionMethodBody = writer => - { - using (writer.Scope($"return {_generalExtensionParameter.Name}.GetCachedClient(client =>", newLine: false)) - { - writer.Line($"return new {Type}(client, {_generalExtensionParameter.Name}.Id);"); - } - writer.LineRaw(");"); - }; - yield return new(resourceExtensionMethod, resourceExtensionMethodBody); - - var scopeExtensionMethod = new MethodSignature( - FactoryMethodName, - null, - null, - Private | Static, - Type, - null, - new[] { ArmClientParameter, _scopeParameter }); - Action scopeExtensionMethodBody = writer => - { - using (writer.Scope($"return {ArmClientParameter.Name}.GetResourceClient(() => ", newLine: false)) - { - writer.Line($"return new {Type}({ArmClientParameter.Name}, {_scopeParameter.Name});"); - } - writer.LineRaw(");"); - }; - yield return new(scopeExtensionMethod, scopeExtensionMethodBody); - } - - private Parameter _generalExtensionParameter = new Parameter( - "resource", - $"The resource parameters to use in these operations.", - typeof(ArmResource), - null, - ValidationType.None, - null); - - private Parameter _scopeParameter = new Parameter( - "scope", - $"The scope to use in these operations", - typeof(ResourceIdentifier), - null, - ValidationType.None, - null); - protected override IEnumerable EnsureClientOperations() { // here we have to capsulate the MgmtClientOperation again to remove the extra "extension parameter" we added when constructing them in MgmtExtension.EnsureClientOperations @@ -122,7 +64,7 @@ protected override IEnumerable EnsureClientOperations() foreach (var (_, operations) in operationDict) { - yield return MgmtClientOperation.FromOperations(operations.SelectMany(clientOperation => clientOperation).ToList())!; + yield return MgmtClientOperation.FromOperations(operations.SelectMany(clientOperation => clientOperation).ToList(), IdVariableName)!; } } @@ -136,19 +78,22 @@ public override ResourceTypeSegment GetBranchResourceType(RequestPath branch) public override CSharpType? BaseType => typeof(ArmResource); protected override string DefaultName { get; } + protected override string DefaultNamespace => $"{base.DefaultNamespace}.Mocking"; + + public override string DiagnosticNamespace => base.DefaultNamespace; - public bool IsEmpty => !ClientOperations.Any() && !ChildResources.Any(); + public virtual bool IsEmpty => !ClientOperations.Any() && !ChildResources.Any(); public override IEnumerable ChildResources => _extensionForChildResources?.ChildResources ?? Enumerable.Empty(); private FormattableString? _description; public override FormattableString Description => _description ??= $"A class to add extension methods to {ResourceName}."; - protected override string DefaultAccessibility => "internal"; + protected override string DefaultAccessibility => "public"; /// /// Construct a key for overload of this method signature. - /// The format of this key is like "MethodName(TypeOfParamter1,TypeOfParamter2,...,TypeOfLastParameter)" + /// The format of this key is like "MethodName(TypeOfParameter1,TypeOfParameter2,...,TypeOfLastParameter)" /// /// /// @@ -162,7 +107,5 @@ private static string GetMgmtClientOperationKey(MethodSignature methodSignature) return builder.ToString(); } - - internal record MgmtExtensionClientFactoryMethod(MethodSignature Signature, Action MethodBodyImplementation); } } diff --git a/src/AutoRest.CSharp/Mgmt/Output/MgmtTypeProvider.cs b/src/AutoRest.CSharp/Mgmt/Output/MgmtTypeProvider.cs index cc42cf10c40..50aa9e63874 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/MgmtTypeProvider.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/MgmtTypeProvider.cs @@ -4,6 +4,9 @@ using System; using System.Collections.Generic; using System.Linq; +using AutoRest.CSharp.Common.Output.Expressions.Statements; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; +using AutoRest.CSharp.Common.Output.Models; using AutoRest.CSharp.Common.Input; using AutoRest.CSharp.Generation.Types; using AutoRest.CSharp.Input; @@ -17,13 +20,14 @@ using AutoRest.CSharp.Utilities; using Azure.Core; using Azure.ResourceManager; +using Humanizer.Localisation; using static AutoRest.CSharp.Output.Models.MethodSignatureModifiers; namespace AutoRest.CSharp.Mgmt.Output { /// /// MgmtTypeProvider represents the information that corresponds to the generated class in the SDK that contains operations in it. - /// This includes , , , , and + /// This includes , , , , and /// internal abstract class MgmtTypeProvider : TypeProvider { @@ -34,12 +38,29 @@ protected MgmtTypeProvider(string resourceName) : base(MgmtContext.Context) ResourceName = resourceName; IsArmCore = Configuration.MgmtConfiguration.IsArmCore; IsStatic = !IsArmCore && BaseType is null; + ArmClientProperty = new MemberExpression(null, "Client"); // this refers to ArmResource.Client which is protected internal therefore we have to hardcode in plain string here instead of using nameof + IdProperty = new MemberExpression(null, nameof(ArmResource.Id)); + MethodModifiers = Public | Virtual; } + protected ValueExpression ArmClientProperty { get; init; } + + protected ValueExpression IdProperty { get; init; } + + protected MethodSignatureModifiers MethodModifiers { get; init; } + protected virtual FormattableString IdParamDescription => $"The identifier of the resource that is the target of operations."; public Parameter ResourceIdentifierParameter => new(Name: "id", Description: IdParamDescription, Type: typeof(ResourceIdentifier), DefaultValue: null, ValidationType.None, null); public static Parameter ArmClientParameter => new(Name: "client", Description: $"The client parameters to use in these operations.", Type: typeof(ArmClient), DefaultValue: null, ValidationType.None, null); + public static Parameter ScopeParameter => new( + Name: "scope", + Description: $"The scope to use", + Type: typeof(ResourceIdentifier), + DefaultValue: null, + Validation: ValidationType.None, + Initializer: null); + public string Accessibility => DefaultAccessibility; protected override string DefaultAccessibility => "public"; @@ -53,9 +74,14 @@ protected MgmtTypeProvider(string resourceName) : base(MgmtContext.Context) public virtual bool HasChildResourceGetMethods => true; - public virtual string BranchIdVariableName => "Id"; + public virtual FormattableString IdVariableName => $"Id"; + + public virtual FormattableString BranchIdVariableName => $"Id"; public string Namespace => DefaultNamespace; + + public virtual string DiagnosticNamespace => Namespace; + public abstract CSharpType? BaseType { get; } protected internal virtual CSharpType TypeAsResource => Type; @@ -278,5 +304,127 @@ private HashSet EnsureUniqueSets() } return uniqueSets; } + + private IEnumerable? _childResourceEntryMethods; + public IEnumerable ChildResourceEntryMethods => _childResourceEntryMethods ??= BuildChildResourceEntries(); + + protected virtual IEnumerable BuildChildResourceEntries() + { + foreach (var resource in ChildResources) + { + if (resource.IsSingleton) + yield return BuildGetSingletonResourceMethod(resource); + else if (resource.ResourceCollection is { } collection) + { + var getCollectionMethod = BuildGetChildCollectionMethod(collection); + yield return getCollectionMethod; + + if (HasChildResourceGetMethods) + { + yield return BuildGetChildResourceMethod(collection, getCollectionMethod.Signature, true); + yield return BuildGetChildResourceMethod(collection, getCollectionMethod.Signature, false); + } + } + } + } + + protected FormattableString BuildDescriptionForSingletonResource(Resource resource) + => $"Gets an object representing a {resource.Type.Name} along with the instance operations that can be performed on it in the {ResourceName}."; + + protected virtual Method BuildGetSingletonResourceMethod(Resource resource) + { + var signature = new MethodSignature( + $"Get{resource.ResourceName}", + null, + BuildDescriptionForSingletonResource(resource), + MethodModifiers, + resource.Type, + $"Returns a object.", + Array.Empty()); + var methodBody = Snippets.Return( + Snippets.New.Instance( + resource.Type, + ArmClientProperty, + resource.SingletonResourceIdSuffix!.BuildResourceIdentifier(IdProperty))); + return new(signature, methodBody); + } + + protected FormattableString BuildDescriptionForChildCollection(ResourceCollection collection) + => $"Gets a collection of {collection.Resource.Type.Name.LastWordToPlural()} in the {ResourceName}."; + + protected virtual Method BuildGetChildCollectionMethod(ResourceCollection collection) + { + var resource = collection.Resource; + var signature = new MethodSignature( + $"Get{resource.ResourceName.ResourceNameToPlural()}", + null, + BuildDescriptionForChildCollection(collection), + MethodModifiers, + collection.Type, + $"An object representing collection of {resource.Type.Name.LastWordToPlural()} and their operations over a {resource.Type.Name}.", + collection.ExtraConstructorParameters.ToArray()); + var methodBody = BuildGetResourceCollectionMethodBody(collection); + return new(signature, methodBody); + } + private MethodBodyStatement BuildGetResourceCollectionMethodBody(ResourceCollection collection) + { + // when there are extra ctor parameters, we cannot use the GetCachedClient method to cache the collection instance + if (collection.ExtraConstructorParameters.Any()) + { + var parameters = new List + { + ArmClientProperty, + IdProperty + }; + parameters.AddRange(collection.ExtraConstructorParameters.Select(p => (ValueExpression)p)); + return Snippets.Return( + Snippets.New.Instance( + collection.Type, + parameters.ToArray())); + } + else + { + var clientArgument = new VariableReference(typeof(ArmClient), "client"); + return Snippets.Return( + new InvokeInstanceMethodExpression( + null, + nameof(ArmResource.GetCachedClient), + new[] { + new FuncExpression(new[] { clientArgument.Declaration }, Snippets.New.Instance(collection.Type, clientArgument, IdProperty)) + }, + null, + false)); + } + } + + protected FormattableString BuildDescriptionForChildResource(ResourceCollection collection) + => collection.GetOperation.Description; + + protected virtual Method BuildGetChildResourceMethod(ResourceCollection collection, MethodSignatureBase getCollectionMethodSignature, bool isAsync) + { + var getOperation = collection.GetOperation; + // construct the method signature + var signature = getOperation.MethodSignature with + { + // name after `Get{ResourceName}` + Name = $"Get{collection.Resource.ResourceName}", + Description = BuildDescriptionForChildResource(collection), + Modifiers = MethodModifiers, + // the parameter of this method should be the parameters on the collection's ctor + parameters on the Get method + // also the validations of parameters will be skipped + Parameters = getCollectionMethodSignature.Parameters.Concat(getOperation.MethodSignature.Parameters).ToArray(), + Attributes = new[] { new CSharpAttribute(typeof(ForwardsClientCallsAttribute)) } + }; + var callGetCollection = new InvokeInstanceMethodExpression( + null, + getCollectionMethodSignature.Name, + getCollectionMethodSignature.Parameters.Select(p => (ValueExpression)p).ToArray(), + null, + getCollectionMethodSignature.Modifiers.HasFlag(Async)); + var callGetOperation = callGetCollection.Invoke(getOperation.MethodSignature.WithAsync(isAsync)); + var methodBody = Snippets.Return(callGetOperation); + + return new(signature.WithAsync(isAsync), methodBody); + } } } diff --git a/src/AutoRest.CSharp/Mgmt/Output/Resource.cs b/src/AutoRest.CSharp/Mgmt/Output/Resource.cs index 16399b46f58..ab31dd97184 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/Resource.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/Resource.cs @@ -165,7 +165,7 @@ private static IEnumerable GetClientOperations(OperationSet operation result.Add(restOperation); } - return MgmtClientOperation.FromOperations(result); + return MgmtClientOperation.FromOperations(result, IdVariableName); } public virtual Resource GetResource() => this; @@ -276,7 +276,8 @@ private bool DoesUpdateSchemaHaveTags(CSharpType bodyParamType) "Update", createOrUpdateOperation.MgmtReturnType, createOrUpdateOperation.Description ?? $"Update this {ResourceName}.", - createOrUpdateOperation.RequestPath)); + createOrUpdateOperation.RequestPath), + IdVariableName); } return null; @@ -317,7 +318,9 @@ protected override IEnumerable EnsureAllOperations() getOperation.MgmtReturnType, "Add a tag to the current resource.", TagKeyParameter, - TagValueParameter), isConvenientOperation: true)); + TagValueParameter), + IdVariableName, + isConvenientOperation: true)); result.Add(MgmtClientOperation.FromOperation( new MgmtRestOperation( @@ -325,7 +328,9 @@ protected override IEnumerable EnsureAllOperations() "SetTags", getOperation.MgmtReturnType, "Replace the tags on the resource with the given set.", - TagSetParameter), isConvenientOperation: true)); + TagSetParameter), + IdVariableName, + isConvenientOperation: true)); result.Add(MgmtClientOperation.FromOperation( new MgmtRestOperation( @@ -333,12 +338,14 @@ protected override IEnumerable EnsureAllOperations() "RemoveTag", getOperation.MgmtReturnType, "Removes a tag by key from the resource.", - TagKeyParameter), isConvenientOperation: true)); + TagKeyParameter), + IdVariableName, + isConvenientOperation: true)); } return result; } - public override string BranchIdVariableName => "Id.Parent"; + public override FormattableString BranchIdVariableName => $"Id.Parent"; public override ResourceTypeSegment GetBranchResourceType(RequestPath branch) { @@ -402,7 +409,7 @@ private IDictionary EnsureClientOperationMap() // TODO -- what if the response type is not the same? Also we need to verify they have the same parameters before we could union those together _clientOperationMap = result.Where(pair => pair.Value.Count > 0).ToDictionary( pair => pair.Key, - pair => MgmtClientOperation.FromOperations(pair.Value)!); // We first filtered the ones with at least one operation, therefore this will never be null + pair => MgmtClientOperation.FromOperations(pair.Value, IdVariableName)!); // We first filtered the ones with at least one operation, therefore this will never be null return _clientOperationMap; } diff --git a/src/AutoRest.CSharp/Mgmt/Output/ResourceCollection.cs b/src/AutoRest.CSharp/Mgmt/Output/ResourceCollection.cs index 1cbeabd97f5..e428fcd0c12 100644 --- a/src/AutoRest.CSharp/Mgmt/Output/ResourceCollection.cs +++ b/src/AutoRest.CSharp/Mgmt/Output/ResourceCollection.cs @@ -51,7 +51,7 @@ protected override IReadOnlyList EnsureGetInterfaces() public override bool CanValidateResourceType => ResourceTypes.SelectMany(p => p.Value).Distinct().Count() == 1; - public override string BranchIdVariableName => "Id"; + public override FormattableString BranchIdVariableName => $"Id"; private MgmtClientOperation? _getAllOperation; public MgmtClientOperation? GetAllOperation => _getAllOperation ??= EnsureGetAllOperation(); @@ -246,13 +246,15 @@ protected override IEnumerable EnsureAllOperations() getMgmtRestOperation, "Exists", typeof(bool), - $"Checks to see if the resource exists in azure."))); + $"Checks to see if the resource exists in azure."), + IdVariableName)); result.Add(MgmtClientOperation.FromOperation( new MgmtRestOperation( getMgmtRestOperation, "GetIfExists", getMgmtRestOperation.MgmtReturnType, - $"Tries to get details for this resource from the service."))); + $"Tries to get details for this resource from the service."), + IdVariableName)); } return result; diff --git a/src/AutoRest.CSharp/Mgmt/Report/ExtensionItem.cs b/src/AutoRest.CSharp/Mgmt/Report/ExtensionItem.cs index 925f9952318..e0970d341c6 100644 --- a/src/AutoRest.CSharp/Mgmt/Report/ExtensionItem.cs +++ b/src/AutoRest.CSharp/Mgmt/Report/ExtensionItem.cs @@ -25,12 +25,12 @@ public ExtensionItem(MgmtExtension extension, TransformSection transformSection) g => g.SelectMany(op => op.Select(mrop => new OperationItem(mrop, transformSection))).Distinct().ToList()); } - public ExtensionItem(MgmtExtensionClient extensionClient, TransformSection transformSection) + public ExtensionItem(MgmtMockableExtension mockableExtension, TransformSection transformSection) { - this.Name = extensionClient.ResourceName; + this.Name = mockableExtension.ResourceName; this.ContextPaths = - extensionClient.AllOperations.SelectMany(cop => cop.Select(rop => rop.ContextualPath.ToString())).Distinct().ToList(); - this.Operations = extensionClient.AllOperations + mockableExtension.AllOperations.SelectMany(cop => cop.Select(rop => rop.ContextualPath.ToString())).Distinct().ToList(); + this.Operations = mockableExtension.AllOperations .GroupBy(op => op.MethodSignature.Name) .ToDictionary( g => g.Key, diff --git a/test/AutoRest.TestServer.Tests/Mgmt/TestProjects/MgmtExtensionCommonRestOperationTests.cs b/test/AutoRest.TestServer.Tests/Mgmt/TestProjects/MgmtExtensionCommonRestOperationTests.cs index aca43821c26..c55e1977b09 100644 --- a/test/AutoRest.TestServer.Tests/Mgmt/TestProjects/MgmtExtensionCommonRestOperationTests.cs +++ b/test/AutoRest.TestServer.Tests/Mgmt/TestProjects/MgmtExtensionCommonRestOperationTests.cs @@ -6,6 +6,7 @@ using System.Reflection; using Azure.Core.Pipeline; using MgmtExtensionCommonRestOperation; +using MgmtExtensionCommonRestOperation.Mocking; using NUnit.Framework; namespace AutoRest.TestServer.Tests.Mgmt.TestProjects @@ -38,7 +39,7 @@ private static void ValidateFields(Type type, string name) [Test] public void ValidateBothFieldsInExtension() { - var extensionClient = typeof(SubscriptionResourceExtensionClient); + var extensionClient = typeof(MockableMgmtExtensionCommonRestOperationSubscriptionResource); var fields = extensionClient.GetFields(BindingFlags.Instance | BindingFlags.NonPublic); var field = fields.FirstOrDefault(f => f.Name.Contains("_typeOneCommonRestClient", StringComparison.OrdinalIgnoreCase)); Assert.NotNull(field); diff --git a/test/AutoRest.TestServer.Tests/Mgmt/Unit/SingletonResourceSuffixTests.cs b/test/AutoRest.TestServer.Tests/Mgmt/Unit/SingletonResourceSuffixTests.cs index 1ad191876c5..a413cab8004 100644 --- a/test/AutoRest.TestServer.Tests/Mgmt/Unit/SingletonResourceSuffixTests.cs +++ b/test/AutoRest.TestServer.Tests/Mgmt/Unit/SingletonResourceSuffixTests.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License using System; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; using AutoRest.CSharp.Generation.Writers; using AutoRest.CSharp.Mgmt.Models; using NUnit.Framework; @@ -18,9 +19,10 @@ public void ValidateBuildResourceIdentifier(string suffixString, string expected { var segments = suffixString.Split('/', StringSplitOptions.RemoveEmptyEntries); var suffix = SingletonResourceSuffix.Parse(segments); - var result = suffix.BuildResourceIdentifier($"Id"); + var result = suffix.BuildResourceIdentifier(new FormattableStringToExpression($"Id")); var writer = new CodeWriter(); - Assert.AreEqual(expected, writer.Append(result).ToString(false).Trim()); + writer.WriteValueExpression(result); + Assert.AreEqual(expected, writer.ToString(false).Trim()); } } } diff --git a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MgmtAcronymMappingExtensions.cs b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MgmtAcronymMappingExtensions.cs index c130d8bd141..4b05db69a6a 100644 --- a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MgmtAcronymMappingExtensions.cs +++ b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MgmtAcronymMappingExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtAcronymMapping.Mocking; using MgmtAcronymMapping.Models; namespace MgmtAcronymMapping @@ -19,157 +20,129 @@ namespace MgmtAcronymMapping /// A class to add extension methods to MgmtAcronymMapping. public static partial class MgmtAcronymMappingExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtAcronymMappingArmClient GetMockableMgmtAcronymMappingArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtAcronymMappingArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtAcronymMappingResourceGroupResource GetMockableMgmtAcronymMappingResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtAcronymMappingResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtAcronymMappingSubscriptionResource GetMockableMgmtAcronymMappingSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtAcronymMappingSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region VirtualMachineResource /// /// 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. /// Returns a object. public static VirtualMachineResource GetVirtualMachineResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineResource.ValidateResourceId(id); - return new VirtualMachineResource(client, id); - } - ); + return GetMockableMgmtAcronymMappingArmClient(client).GetVirtualMachineResource(id); } - #endregion - #region ImageResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static ImageResource GetImageResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ImageResource.ValidateResourceId(id); - return new ImageResource(client, id); - } - ); + return GetMockableMgmtAcronymMappingArmClient(client).GetImageResource(id); } - #endregion - #region VirtualMachineScaleSetResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetResource GetVirtualMachineScaleSetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetResource.ValidateResourceId(id); - return new VirtualMachineScaleSetResource(client, id); - } - ); + return GetMockableMgmtAcronymMappingArmClient(client).GetVirtualMachineScaleSetResource(id); } - #endregion - #region VirtualMachineScaleSetExtensionResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetExtensionResource GetVirtualMachineScaleSetExtensionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetExtensionResource.ValidateResourceId(id); - return new VirtualMachineScaleSetExtensionResource(client, id); - } - ); + return GetMockableMgmtAcronymMappingArmClient(client).GetVirtualMachineScaleSetExtensionResource(id); } - #endregion - #region VirtualMachineScaleSetRollingUpgradeResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetRollingUpgradeResource GetVirtualMachineScaleSetRollingUpgradeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetRollingUpgradeResource.ValidateResourceId(id); - return new VirtualMachineScaleSetRollingUpgradeResource(client, id); - } - ); + return GetMockableMgmtAcronymMappingArmClient(client).GetVirtualMachineScaleSetRollingUpgradeResource(id); } - #endregion - #region VirtualMachineScaleSetVmResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetVmResource GetVirtualMachineScaleSetVmResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetVmResource.ValidateResourceId(id); - return new VirtualMachineScaleSetVmResource(client, id); - } - ); + return GetMockableMgmtAcronymMappingArmClient(client).GetVirtualMachineScaleSetVmResource(id); } - #endregion - /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// + /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. public static VirtualMachineCollection GetVirtualMachines(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVirtualMachines(); + return GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetVirtualMachines(); } /// @@ -184,17 +157,21 @@ public static VirtualMachineCollection GetVirtualMachines(this ResourceGroupReso /// VirtualMachines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineAsync(this ResourceGroupResource resourceGroupResource, string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVirtualMachines().GetAsync(vmName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetVirtualMachineAsync(vmName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -209,25 +186,35 @@ public static async Task> GetVirtualMachineAsyn /// VirtualMachines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachine(this ResourceGroupResource resourceGroupResource, string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVirtualMachines().Get(vmName, expand, cancellationToken); + return GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetVirtualMachine(vmName, expand, cancellationToken); } - /// Gets a collection of ImageResources in the ResourceGroupResource. + /// + /// Gets a collection of ImageResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ImageResources and their operations over a ImageResource. public static ImageCollection GetImages(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetImages(); + return GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetImages(); } /// @@ -242,17 +229,21 @@ public static ImageCollection GetImages(this ResourceGroupResource resourceGroup /// Images_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the image. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetImageAsync(this ResourceGroupResource resourceGroupResource, string imageName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetImages().GetAsync(imageName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetImageAsync(imageName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -267,25 +258,35 @@ public static async Task> GetImageAsync(this ResourceGro /// Images_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the image. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetImage(this ResourceGroupResource resourceGroupResource, string imageName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetImages().Get(imageName, expand, cancellationToken); + return GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetImage(imageName, expand, cancellationToken); } - /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// + /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. public static VirtualMachineScaleSetCollection GetVirtualMachineScaleSets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVirtualMachineScaleSets(); + return GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSets(); } /// @@ -300,16 +301,20 @@ public static VirtualMachineScaleSetCollection GetVirtualMachineScaleSets(this R /// VirtualMachineScaleSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineScaleSetAsync(this ResourceGroupResource resourceGroupResource, string vmScaleSetName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVirtualMachineScaleSets().GetAsync(vmScaleSetName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSetAsync(vmScaleSetName, cancellationToken).ConfigureAwait(false); } /// @@ -324,16 +329,20 @@ public static async Task> GetVirtualMac /// VirtualMachineScaleSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineScaleSet(this ResourceGroupResource resourceGroupResource, string vmScaleSetName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVirtualMachineScaleSets().Get(vmScaleSetName, cancellationToken); + return GetMockableMgmtAcronymMappingResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSet(vmScaleSetName, cancellationToken); } /// @@ -348,6 +357,10 @@ public static Response GetVirtualMachineScaleSet /// VirtualMachines_ListByLocation /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -355,7 +368,7 @@ public static Response GetVirtualMachineScaleSet /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachinesByLocationAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachinesByLocationAsync(location, cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetVirtualMachinesByLocationAsync(location, cancellationToken); } /// @@ -370,6 +383,10 @@ public static AsyncPageable GetVirtualMachinesByLocation /// VirtualMachines_ListByLocation /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -377,7 +394,7 @@ public static AsyncPageable GetVirtualMachinesByLocation /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachinesByLocation(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachinesByLocation(location, cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetVirtualMachinesByLocation(location, cancellationToken); } /// @@ -392,6 +409,10 @@ public static Pageable GetVirtualMachinesByLocation(this /// VirtualMachines_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. @@ -399,7 +420,7 @@ public static Pageable GetVirtualMachinesByLocation(this /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachinesAsync(this SubscriptionResource subscriptionResource, string statusOnly = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachinesAsync(statusOnly, cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetVirtualMachinesAsync(statusOnly, cancellationToken); } /// @@ -414,6 +435,10 @@ public static AsyncPageable GetVirtualMachinesAsync(this /// VirtualMachines_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. @@ -421,7 +446,7 @@ public static AsyncPageable GetVirtualMachinesAsync(this /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachines(this SubscriptionResource subscriptionResource, string statusOnly = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachines(statusOnly, cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetVirtualMachines(statusOnly, cancellationToken); } /// @@ -436,13 +461,17 @@ public static Pageable GetVirtualMachines(this Subscript /// Images_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetImagesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetImagesAsync(cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetImagesAsync(cancellationToken); } /// @@ -457,13 +486,17 @@ public static AsyncPageable GetImagesAsync(this SubscriptionResou /// Images_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetImages(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetImages(cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetImages(cancellationToken); } /// @@ -478,13 +511,17 @@ public static Pageable GetImages(this SubscriptionResource subscr /// VirtualMachineScaleSets_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVirtualMachineScaleSetsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineScaleSetsAsync(cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetVirtualMachineScaleSetsAsync(cancellationToken); } /// @@ -499,13 +536,17 @@ public static AsyncPageable GetVirtualMachineSca /// VirtualMachineScaleSets_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVirtualMachineScaleSets(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineScaleSets(cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).GetVirtualMachineScaleSets(cancellationToken); } /// @@ -520,6 +561,10 @@ public static Pageable GetVirtualMachineScaleSet /// LogAnalytics_ExportRequestRateByInterval /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -529,9 +574,7 @@ public static Pageable GetVirtualMachineScaleSet /// is null. public static async Task> ExportRequestRateByIntervalLogAnalyticAsync(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).ExportRequestRateByIntervalLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).ExportRequestRateByIntervalLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); } /// @@ -546,6 +589,10 @@ public static async Task> ExportRequestRateByInterval /// LogAnalytics_ExportRequestRateByInterval /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -555,9 +602,7 @@ public static async Task> ExportRequestRateByInterval /// is null. public static ArmOperation ExportRequestRateByIntervalLogAnalytic(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).ExportRequestRateByIntervalLogAnalytic(waitUntil, location, content, cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).ExportRequestRateByIntervalLogAnalytic(waitUntil, location, content, cancellationToken); } /// @@ -572,6 +617,10 @@ public static ArmOperation ExportRequestRateByIntervalLogAnalytic( /// LogAnalytics_ExportThrottledRequests /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -581,9 +630,7 @@ public static ArmOperation ExportRequestRateByIntervalLogAnalytic( /// is null. public static async Task> ExportThrottledRequestsLogAnalyticAsync(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).ExportThrottledRequestsLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).ExportThrottledRequestsLogAnalyticAsync(waitUntil, location, content, cancellationToken).ConfigureAwait(false); } /// @@ -598,6 +645,10 @@ public static async Task> ExportThrottledRequestsLogA /// LogAnalytics_ExportThrottledRequests /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -607,9 +658,7 @@ public static async Task> ExportThrottledRequestsLogA /// is null. public static ArmOperation ExportThrottledRequestsLogAnalytic(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).ExportThrottledRequestsLogAnalytic(waitUntil, location, content, cancellationToken); + return GetMockableMgmtAcronymMappingSubscriptionResource(subscriptionResource).ExportThrottledRequestsLogAnalytic(waitUntil, location, content, cancellationToken); } } } diff --git a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingArmClient.cs b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingArmClient.cs new file mode 100644 index 00000000000..6803fdfbfce --- /dev/null +++ b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingArmClient.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtAcronymMapping; + +namespace MgmtAcronymMapping.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtAcronymMappingArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtAcronymMappingArmClient() + { + } + + /// 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 MockableMgmtAcronymMappingArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtAcronymMappingArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 VirtualMachineResource GetVirtualMachineResource(ResourceIdentifier id) + { + VirtualMachineResource.ValidateResourceId(id); + return new VirtualMachineResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ImageResource GetImageResource(ResourceIdentifier id) + { + ImageResource.ValidateResourceId(id); + return new ImageResource(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 VirtualMachineScaleSetResource GetVirtualMachineScaleSetResource(ResourceIdentifier id) + { + VirtualMachineScaleSetResource.ValidateResourceId(id); + return new VirtualMachineScaleSetResource(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 VirtualMachineScaleSetExtensionResource GetVirtualMachineScaleSetExtensionResource(ResourceIdentifier id) + { + VirtualMachineScaleSetExtensionResource.ValidateResourceId(id); + return new VirtualMachineScaleSetExtensionResource(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 VirtualMachineScaleSetRollingUpgradeResource GetVirtualMachineScaleSetRollingUpgradeResource(ResourceIdentifier id) + { + VirtualMachineScaleSetRollingUpgradeResource.ValidateResourceId(id); + return new VirtualMachineScaleSetRollingUpgradeResource(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 VirtualMachineScaleSetVmResource GetVirtualMachineScaleSetVmResource(ResourceIdentifier id) + { + VirtualMachineScaleSetVmResource.ValidateResourceId(id); + return new VirtualMachineScaleSetVmResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingResourceGroupResource.cs b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingResourceGroupResource.cs new file mode 100644 index 00000000000..7d0f7f18688 --- /dev/null +++ b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingResourceGroupResource.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtAcronymMapping; +using MgmtAcronymMapping.Models; + +namespace MgmtAcronymMapping.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtAcronymMappingResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtAcronymMappingResourceGroupResource() + { + } + + /// 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 MockableMgmtAcronymMappingResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. + public virtual VirtualMachineCollection GetVirtualMachines() + { + return GetCachedClient(client => new VirtualMachineCollection(client, Id)); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName} + /// + /// + /// Operation Id + /// VirtualMachines_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineAsync(string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return await GetVirtualMachines().GetAsync(vmName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName} + /// + /// + /// Operation Id + /// VirtualMachines_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachine(string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return GetVirtualMachines().Get(vmName, expand, cancellationToken); + } + + /// Gets a collection of ImageResources in the ResourceGroupResource. + /// An object representing collection of ImageResources and their operations over a ImageResource. + public virtual ImageCollection GetImages() + { + return GetCachedClient(client => new ImageCollection(client, Id)); + } + + /// + /// Gets an image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// The name of the image. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetImageAsync(string imageName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetImages().GetAsync(imageName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// The name of the image. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetImage(string imageName, string expand = null, CancellationToken cancellationToken = default) + { + return GetImages().Get(imageName, expand, cancellationToken); + } + + /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. + public virtual VirtualMachineScaleSetCollection GetVirtualMachineScaleSets() + { + return GetCachedClient(client => new VirtualMachineScaleSetCollection(client, Id)); + } + + /// + /// Display information about a virtual machine scale set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSets_Get + /// + /// + /// + /// The name of the VM scale set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineScaleSetAsync(string vmScaleSetName, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineScaleSets().GetAsync(vmScaleSetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Display information about a virtual machine scale set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSets_Get + /// + /// + /// + /// The name of the VM scale set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineScaleSet(string vmScaleSetName, CancellationToken cancellationToken = default) + { + return GetVirtualMachineScaleSets().Get(vmScaleSetName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingSubscriptionResource.cs similarity index 90% rename from test/TestProjects/MgmtAcronymMapping/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingSubscriptionResource.cs index 5a1e6dfcf31..10f27779b38 100644 --- a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/MockableMgmtAcronymMappingSubscriptionResource.cs @@ -13,12 +13,13 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtAcronymMapping; using MgmtAcronymMapping.Models; -namespace MgmtAcronymMapping +namespace MgmtAcronymMapping.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtAcronymMappingSubscriptionResource : ArmResource { private ClientDiagnostics _virtualMachineClientDiagnostics; private VirtualMachinesRestOperations _virtualMachineRestClient; @@ -29,15 +30,15 @@ internal partial class SubscriptionResourceExtensionClient : ArmResource private ClientDiagnostics _logAnalyticsClientDiagnostics; private LogAnalyticsRestOperations _logAnalyticsRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtAcronymMappingSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtAcronymMappingSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -76,7 +77,7 @@ public virtual AsyncPageable GetVirtualMachinesByLocatio { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListByLocationRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListByLocationNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); } /// @@ -99,7 +100,7 @@ public virtual Pageable GetVirtualMachinesByLocation(Azu { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListByLocationRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListByLocationNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetVirtualMachinesByLocation", "value", "nextLink", cancellationToken); } /// @@ -122,7 +123,7 @@ public virtual AsyncPageable GetVirtualMachinesAsync(str { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListAllRequest(Id.SubscriptionId, statusOnly); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, statusOnly); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachines", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetVirtualMachines", "value", "nextLink", cancellationToken); } /// @@ -145,7 +146,7 @@ public virtual Pageable GetVirtualMachines(string status { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineRestClient.CreateListAllRequest(Id.SubscriptionId, statusOnly); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, statusOnly); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachines", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineResource(Client, VirtualMachineData.DeserializeVirtualMachineData(e)), VirtualMachineClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetVirtualMachines", "value", "nextLink", cancellationToken); } /// @@ -167,7 +168,7 @@ public virtual AsyncPageable GetImagesAsync(CancellationToken can { HttpMessage FirstPageRequest(int? pageSizeHint) => ImageRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ImageRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetImages", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetImages", "value", "nextLink", cancellationToken); } /// @@ -189,7 +190,7 @@ public virtual Pageable GetImages(CancellationToken cancellationT { HttpMessage FirstPageRequest(int? pageSizeHint) => ImageRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ImageRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetImages", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), ImageClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetImages", "value", "nextLink", cancellationToken); } /// @@ -211,7 +212,7 @@ public virtual AsyncPageable GetVirtualMachineSc { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineScaleSetRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineScaleSetRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); } /// @@ -233,7 +234,7 @@ public virtual Pageable GetVirtualMachineScaleSe { HttpMessage FirstPageRequest(int? pageSizeHint) => VirtualMachineScaleSetRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VirtualMachineScaleSetRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VirtualMachineScaleSetResource(Client, VirtualMachineScaleSetData.DeserializeVirtualMachineScaleSetData(e)), VirtualMachineScaleSetClientDiagnostics, Pipeline, "MockableMgmtAcronymMappingSubscriptionResource.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); } /// @@ -253,9 +254,12 @@ public virtual Pageable GetVirtualMachineScaleSe /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getRequestRateByInterval Api. /// The cancellation token to use. + /// is null. public virtual async Task> ExportRequestRateByIntervalLogAnalyticAsync(WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportRequestRateByIntervalLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableMgmtAcronymMappingSubscriptionResource.ExportRequestRateByIntervalLogAnalytic"); scope.Start(); try { @@ -289,9 +293,12 @@ public virtual async Task> ExportRequestRateByInterva /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getRequestRateByInterval Api. /// The cancellation token to use. + /// is null. public virtual ArmOperation ExportRequestRateByIntervalLogAnalytic(WaitUntil waitUntil, AzureLocation location, RequestRateByIntervalContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportRequestRateByIntervalLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableMgmtAcronymMappingSubscriptionResource.ExportRequestRateByIntervalLogAnalytic"); scope.Start(); try { @@ -325,9 +332,12 @@ public virtual ArmOperation ExportRequestRateByIntervalLogAnalytic /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getThrottledRequests Api. /// The cancellation token to use. + /// is null. public virtual async Task> ExportThrottledRequestsLogAnalyticAsync(WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportThrottledRequestsLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableMgmtAcronymMappingSubscriptionResource.ExportThrottledRequestsLogAnalytic"); scope.Start(); try { @@ -361,9 +371,12 @@ public virtual async Task> ExportThrottledRequestsLog /// The location upon which virtual-machine-sizes is queried. /// Parameters supplied to the LogAnalytics getThrottledRequests Api. /// The cancellation token to use. + /// is null. public virtual ArmOperation ExportThrottledRequestsLogAnalytic(WaitUntil waitUntil, AzureLocation location, ThrottledRequestsContent content, CancellationToken cancellationToken = default) { - using var scope = LogAnalyticsClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ExportThrottledRequestsLogAnalytic"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = LogAnalyticsClientDiagnostics.CreateScope("MockableMgmtAcronymMappingSubscriptionResource.ExportThrottledRequestsLogAnalytic"); scope.Start(); try { diff --git a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 1bd65e06f1d..00000000000 --- a/test/TestProjects/MgmtAcronymMapping/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtAcronymMapping -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. - /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. - public virtual VirtualMachineCollection GetVirtualMachines() - { - return GetCachedClient(Client => new VirtualMachineCollection(Client, Id)); - } - - /// Gets a collection of ImageResources in the ResourceGroupResource. - /// An object representing collection of ImageResources and their operations over a ImageResource. - public virtual ImageCollection GetImages() - { - return GetCachedClient(Client => new ImageCollection(Client, Id)); - } - - /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. - /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. - public virtual VirtualMachineScaleSetCollection GetVirtualMachineScaleSets() - { - return GetCachedClient(Client => new VirtualMachineScaleSetCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtAcronymMapping/Generated/VirtualMachineScaleSetResource.cs b/test/TestProjects/MgmtAcronymMapping/Generated/VirtualMachineScaleSetResource.cs index fae4971aca6..d7652b84c82 100644 --- a/test/TestProjects/MgmtAcronymMapping/Generated/VirtualMachineScaleSetResource.cs +++ b/test/TestProjects/MgmtAcronymMapping/Generated/VirtualMachineScaleSetResource.cs @@ -102,7 +102,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of VirtualMachineScaleSetExtensionResources and their operations over a VirtualMachineScaleSetExtensionResource. public virtual VirtualMachineScaleSetExtensionCollection GetVirtualMachineScaleSetExtensions() { - return GetCachedClient(Client => new VirtualMachineScaleSetExtensionCollection(Client, Id)); + return GetCachedClient(client => new VirtualMachineScaleSetExtensionCollection(client, Id)); } /// @@ -121,8 +121,8 @@ public virtual VirtualMachineScaleSetExtensionCollection GetVirtualMachineScaleS /// The name of the VM scale set extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetVirtualMachineScaleSetExtensionAsync(string vmssExtensionName, string expand = null, CancellationToken cancellationToken = default) { @@ -145,8 +145,8 @@ public virtual async Task> Get /// The name of the VM scale set extension. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetVirtualMachineScaleSetExtension(string vmssExtensionName, string expand = null, CancellationToken cancellationToken = default) { @@ -164,7 +164,7 @@ public virtual VirtualMachineScaleSetRollingUpgradeResource GetVirtualMachineSca /// An object representing collection of VirtualMachineScaleSetVmResources and their operations over a VirtualMachineScaleSetVmResource. public virtual VirtualMachineScaleSetVmCollection GetVirtualMachineScaleSetVms() { - return GetCachedClient(Client => new VirtualMachineScaleSetVmCollection(Client, Id)); + return GetCachedClient(client => new VirtualMachineScaleSetVmCollection(client, Id)); } /// @@ -183,8 +183,8 @@ public virtual VirtualMachineScaleSetVmCollection GetVirtualMachineScaleSetVms() /// The instance ID of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetVirtualMachineScaleSetVmAsync(string instanceId, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { @@ -207,8 +207,8 @@ public virtual async Task> GetVirtual /// The instance ID of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetVirtualMachineScaleSetVm(string instanceId, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MgmtCollectionParentExtensions.cs b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MgmtCollectionParentExtensions.cs index 3bfc7ccfd77..c4c7cb41502 100644 --- a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MgmtCollectionParentExtensions.cs +++ b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MgmtCollectionParentExtensions.cs @@ -12,68 +12,56 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtCollectionParent.Mocking; namespace MgmtCollectionParent { /// A class to add extension methods to MgmtCollectionParent. public static partial class MgmtCollectionParentExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtCollectionParentArmClient GetMockableMgmtCollectionParentArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtCollectionParentArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtCollectionParentResourceGroupResource GetMockableMgmtCollectionParentResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtCollectionParentResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtCollectionParentSubscriptionResource GetMockableMgmtCollectionParentSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtCollectionParentSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region OrderResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static OrderResource GetOrderResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - OrderResource.ValidateResourceId(id); - return new OrderResource(client, id); - } - ); + return GetMockableMgmtCollectionParentArmClient(client).GetOrderResource(id); } - #endregion - /// Gets a collection of OrderResources in the ResourceGroupResource. + /// + /// Gets a collection of OrderResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of OrderResources and their operations over a OrderResource. public static OrderResourceCollection GetOrderResources(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetOrderResources(); + return GetMockableMgmtCollectionParentResourceGroupResource(resourceGroupResource).GetOrderResources(); } /// @@ -88,17 +76,21 @@ public static OrderResourceCollection GetOrderResources(this ResourceGroupResour /// GetOrderByName /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of Azure region. /// The name of the order. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. /// or is null. + /// or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetOrderResourceAsync(this ResourceGroupResource resourceGroupResource, string location, string orderName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetOrderResources().GetAsync(location, orderName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtCollectionParentResourceGroupResource(resourceGroupResource).GetOrderResourceAsync(location, orderName, cancellationToken).ConfigureAwait(false); } /// @@ -113,17 +105,21 @@ public static async Task> GetOrderResourceAsync(this Res /// GetOrderByName /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of Azure region. /// The name of the order. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. /// or is null. + /// or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetOrderResource(this ResourceGroupResource resourceGroupResource, string location, string orderName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetOrderResources().Get(location, orderName, cancellationToken); + return GetMockableMgmtCollectionParentResourceGroupResource(resourceGroupResource).GetOrderResource(location, orderName, cancellationToken); } /// @@ -138,6 +134,10 @@ public static Response GetOrderResource(this ResourceGroupResourc /// ListOrderAtSubscriptionLevel /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// $skipToken is supported on Get list of order, which provides the next page in the list of order. @@ -145,7 +145,7 @@ public static Response GetOrderResource(this ResourceGroupResourc /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetOrderResourcesAsync(this SubscriptionResource subscriptionResource, string skipToken = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetOrderResourcesAsync(skipToken, cancellationToken); + return GetMockableMgmtCollectionParentSubscriptionResource(subscriptionResource).GetOrderResourcesAsync(skipToken, cancellationToken); } /// @@ -160,6 +160,10 @@ public static AsyncPageable GetOrderResourcesAsync(this Subscript /// ListOrderAtSubscriptionLevel /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// $skipToken is supported on Get list of order, which provides the next page in the list of order. @@ -167,7 +171,7 @@ public static AsyncPageable GetOrderResourcesAsync(this Subscript /// A collection of that may take multiple service requests to iterate over. public static Pageable GetOrderResources(this SubscriptionResource subscriptionResource, string skipToken = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetOrderResources(skipToken, cancellationToken); + return GetMockableMgmtCollectionParentSubscriptionResource(subscriptionResource).GetOrderResources(skipToken, cancellationToken); } } } diff --git a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentArmClient.cs b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentArmClient.cs new file mode 100644 index 00000000000..cee01866b44 --- /dev/null +++ b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtCollectionParent; + +namespace MgmtCollectionParent.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtCollectionParentArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtCollectionParentArmClient() + { + } + + /// 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 MockableMgmtCollectionParentArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtCollectionParentArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual OrderResource GetOrderResource(ResourceIdentifier id) + { + OrderResource.ValidateResourceId(id); + return new OrderResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentResourceGroupResource.cs b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentResourceGroupResource.cs new file mode 100644 index 00000000000..da2b3cac38d --- /dev/null +++ b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentResourceGroupResource.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtCollectionParent; + +namespace MgmtCollectionParent.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtCollectionParentResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtCollectionParentResourceGroupResource() + { + } + + /// 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 MockableMgmtCollectionParentResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of OrderResources in the ResourceGroupResource. + /// An object representing collection of OrderResources and their operations over a OrderResource. + public virtual OrderResourceCollection GetOrderResources() + { + return GetCachedClient(client => new OrderResourceCollection(client, Id)); + } + + /// + /// Gets an order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EdgeOrder/locations/{location}/orders/{orderName} + /// + /// + /// Operation Id + /// GetOrderByName + /// + /// + /// + /// The name of Azure region. + /// The name of the order. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetOrderResourceAsync(string location, string orderName, CancellationToken cancellationToken = default) + { + return await GetOrderResources().GetAsync(location, orderName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EdgeOrder/locations/{location}/orders/{orderName} + /// + /// + /// Operation Id + /// GetOrderByName + /// + /// + /// + /// The name of Azure region. + /// The name of the order. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetOrderResource(string location, string orderName, CancellationToken cancellationToken = default) + { + return GetOrderResources().Get(location, orderName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentSubscriptionResource.cs similarity index 85% rename from test/TestProjects/MgmtCollectionParent/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentSubscriptionResource.cs index 9c953ed9cc2..78aea356622 100644 --- a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/MockableMgmtCollectionParentSubscriptionResource.cs @@ -11,24 +11,25 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtCollectionParent; -namespace MgmtCollectionParent +namespace MgmtCollectionParent.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtCollectionParentSubscriptionResource : ArmResource { private ClientDiagnostics _orderResourceClientDiagnostics; private ComputeManagementRestOperations _orderResourceRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtCollectionParentSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtCollectionParentSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -61,7 +62,7 @@ public virtual AsyncPageable GetOrderResourcesAsync(string skipTo { HttpMessage FirstPageRequest(int? pageSizeHint) => OrderResourceRestClient.CreateListOrderAtSubscriptionLevelRequest(Id.SubscriptionId, skipToken); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OrderResourceRestClient.CreateListOrderAtSubscriptionLevelNextPageRequest(nextLink, Id.SubscriptionId, skipToken); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new OrderResource(Client, OrderResourceData.DeserializeOrderResourceData(e)), OrderResourceClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetOrderResources", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new OrderResource(Client, OrderResourceData.DeserializeOrderResourceData(e)), OrderResourceClientDiagnostics, Pipeline, "MockableMgmtCollectionParentSubscriptionResource.GetOrderResources", "value", "nextLink", cancellationToken); } /// @@ -84,7 +85,7 @@ public virtual Pageable GetOrderResources(string skipToken = null { HttpMessage FirstPageRequest(int? pageSizeHint) => OrderResourceRestClient.CreateListOrderAtSubscriptionLevelRequest(Id.SubscriptionId, skipToken); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OrderResourceRestClient.CreateListOrderAtSubscriptionLevelNextPageRequest(nextLink, Id.SubscriptionId, skipToken); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new OrderResource(Client, OrderResourceData.DeserializeOrderResourceData(e)), OrderResourceClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetOrderResources", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new OrderResource(Client, OrderResourceData.DeserializeOrderResourceData(e)), OrderResourceClientDiagnostics, Pipeline, "MockableMgmtCollectionParentSubscriptionResource.GetOrderResources", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtCollectionParent/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 6dcd7032acb..00000000000 --- a/test/TestProjects/MgmtCollectionParent/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtCollectionParent -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of OrderResources in the ResourceGroupResource. - /// An object representing collection of OrderResources and their operations over a OrderResource. - public virtual OrderResourceCollection GetOrderResources() - { - return GetCachedClient(Client => new OrderResourceCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtConstants/Generated/Extensions/MgmtConstantsExtensions.cs b/test/TestProjects/MgmtConstants/Generated/Extensions/MgmtConstantsExtensions.cs index 3859e74a08f..6b800e302bf 100644 --- a/test/TestProjects/MgmtConstants/Generated/Extensions/MgmtConstantsExtensions.cs +++ b/test/TestProjects/MgmtConstants/Generated/Extensions/MgmtConstantsExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtConstants.Mocking; using MgmtConstants.Models; namespace MgmtConstants @@ -19,62 +20,49 @@ namespace MgmtConstants /// A class to add extension methods to MgmtConstants. public static partial class MgmtConstantsExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtConstantsArmClient GetMockableMgmtConstantsArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtConstantsArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtConstantsResourceGroupResource GetMockableMgmtConstantsResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtConstantsResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtConstantsSubscriptionResource GetMockableMgmtConstantsSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtConstantsSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region OptionalMachineResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static OptionalMachineResource GetOptionalMachineResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - OptionalMachineResource.ValidateResourceId(id); - return new OptionalMachineResource(client, id); - } - ); + return GetMockableMgmtConstantsArmClient(client).GetOptionalMachineResource(id); } - #endregion - /// Gets a collection of OptionalMachineResources in the ResourceGroupResource. + /// + /// Gets a collection of OptionalMachineResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of OptionalMachineResources and their operations over a OptionalMachineResource. public static OptionalMachineCollection GetOptionalMachines(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetOptionalMachines(); + return GetMockableMgmtConstantsResourceGroupResource(resourceGroupResource).GetOptionalMachines(); } /// @@ -89,17 +77,21 @@ public static OptionalMachineCollection GetOptionalMachines(this ResourceGroupRe /// Optionals_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetOptionalMachineAsync(this ResourceGroupResource resourceGroupResource, string name, OptionalMachineExpand? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetOptionalMachines().GetAsync(name, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtConstantsResourceGroupResource(resourceGroupResource).GetOptionalMachineAsync(name, expand, cancellationToken).ConfigureAwait(false); } /// @@ -114,17 +106,21 @@ public static async Task> GetOptionalMachineAs /// Optionals_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetOptionalMachine(this ResourceGroupResource resourceGroupResource, string name, OptionalMachineExpand? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetOptionalMachines().Get(name, expand, cancellationToken); + return GetMockableMgmtConstantsResourceGroupResource(resourceGroupResource).GetOptionalMachine(name, expand, cancellationToken); } /// @@ -139,6 +135,10 @@ public static Response GetOptionalMachine(this Resource /// Optionals_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. @@ -146,7 +146,7 @@ public static Response GetOptionalMachine(this Resource /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetOptionalMachinesAsync(this SubscriptionResource subscriptionResource, string statusOnly = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetOptionalMachinesAsync(statusOnly, cancellationToken); + return GetMockableMgmtConstantsSubscriptionResource(subscriptionResource).GetOptionalMachinesAsync(statusOnly, cancellationToken); } /// @@ -161,6 +161,10 @@ public static AsyncPageable GetOptionalMachinesAsync(th /// Optionals_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. @@ -168,7 +172,7 @@ public static AsyncPageable GetOptionalMachinesAsync(th /// A collection of that may take multiple service requests to iterate over. public static Pageable GetOptionalMachines(this SubscriptionResource subscriptionResource, string statusOnly = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetOptionalMachines(statusOnly, cancellationToken); + return GetMockableMgmtConstantsSubscriptionResource(subscriptionResource).GetOptionalMachines(statusOnly, cancellationToken); } } } diff --git a/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsArmClient.cs b/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsArmClient.cs new file mode 100644 index 00000000000..59bea37af8f --- /dev/null +++ b/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtConstants; + +namespace MgmtConstants.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtConstantsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtConstantsArmClient() + { + } + + /// 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 MockableMgmtConstantsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtConstantsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual OptionalMachineResource GetOptionalMachineResource(ResourceIdentifier id) + { + OptionalMachineResource.ValidateResourceId(id); + return new OptionalMachineResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsResourceGroupResource.cs b/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsResourceGroupResource.cs new file mode 100644 index 00000000000..fc3fe5a265e --- /dev/null +++ b/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsResourceGroupResource.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtConstants; +using MgmtConstants.Models; + +namespace MgmtConstants.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtConstantsResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtConstantsResourceGroupResource() + { + } + + /// 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 MockableMgmtConstantsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of OptionalMachineResources in the ResourceGroupResource. + /// An object representing collection of OptionalMachineResources and their operations over a OptionalMachineResource. + public virtual OptionalMachineCollection GetOptionalMachines() + { + return GetCachedClient(client => new OptionalMachineCollection(client, Id)); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Constant/optionalMachines/{name} + /// + /// + /// Operation Id + /// Optionals_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetOptionalMachineAsync(string name, OptionalMachineExpand? expand = null, CancellationToken cancellationToken = default) + { + return await GetOptionalMachines().GetAsync(name, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Constant/optionalMachines/{name} + /// + /// + /// Operation Id + /// Optionals_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetOptionalMachine(string name, OptionalMachineExpand? expand = null, CancellationToken cancellationToken = default) + { + return GetOptionalMachines().Get(name, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtConstants/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsSubscriptionResource.cs similarity index 86% rename from test/TestProjects/MgmtConstants/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsSubscriptionResource.cs index 2370ecc3782..fbc463bb77b 100644 --- a/test/TestProjects/MgmtConstants/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtConstants/Generated/Extensions/MockableMgmtConstantsSubscriptionResource.cs @@ -11,24 +11,25 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtConstants; -namespace MgmtConstants +namespace MgmtConstants.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtConstantsSubscriptionResource : ArmResource { private ClientDiagnostics _optionalMachineOptionalsClientDiagnostics; private OptionalsRestOperations _optionalMachineOptionalsRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtConstantsSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtConstantsSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -61,7 +62,7 @@ public virtual AsyncPageable GetOptionalMachinesAsync(s { HttpMessage FirstPageRequest(int? pageSizeHint) => OptionalMachineOptionalsRestClient.CreateListAllRequest(Id.SubscriptionId, statusOnly); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OptionalMachineOptionalsRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, statusOnly); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new OptionalMachineResource(Client, OptionalMachineData.DeserializeOptionalMachineData(e)), OptionalMachineOptionalsClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetOptionalMachines", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new OptionalMachineResource(Client, OptionalMachineData.DeserializeOptionalMachineData(e)), OptionalMachineOptionalsClientDiagnostics, Pipeline, "MockableMgmtConstantsSubscriptionResource.GetOptionalMachines", "value", "nextLink", cancellationToken); } /// @@ -84,7 +85,7 @@ public virtual Pageable GetOptionalMachines(string stat { HttpMessage FirstPageRequest(int? pageSizeHint) => OptionalMachineOptionalsRestClient.CreateListAllRequest(Id.SubscriptionId, statusOnly); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OptionalMachineOptionalsRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, statusOnly); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new OptionalMachineResource(Client, OptionalMachineData.DeserializeOptionalMachineData(e)), OptionalMachineOptionalsClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetOptionalMachines", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new OptionalMachineResource(Client, OptionalMachineData.DeserializeOptionalMachineData(e)), OptionalMachineOptionalsClientDiagnostics, Pipeline, "MockableMgmtConstantsSubscriptionResource.GetOptionalMachines", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtConstants/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtConstants/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index ac3fff41971..00000000000 --- a/test/TestProjects/MgmtConstants/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtConstants -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of OptionalMachineResources in the ResourceGroupResource. - /// An object representing collection of OptionalMachineResources and their operations over a OptionalMachineResource. - public virtual OptionalMachineCollection GetOptionalMachines() - { - return GetCachedClient(Client => new OptionalMachineCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtCustomizations/Generated/Extensions/MgmtCustomizationsExtensions.cs b/test/TestProjects/MgmtCustomizations/Generated/Extensions/MgmtCustomizationsExtensions.cs index 73c2e2e7a4a..f7e6972396e 100644 --- a/test/TestProjects/MgmtCustomizations/Generated/Extensions/MgmtCustomizationsExtensions.cs +++ b/test/TestProjects/MgmtCustomizations/Generated/Extensions/MgmtCustomizationsExtensions.cs @@ -12,52 +12,51 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtCustomizations.Mocking; namespace MgmtCustomizations { /// A class to add extension methods to MgmtCustomizations. public static partial class MgmtCustomizationsExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtCustomizationsArmClient GetMockableMgmtCustomizationsArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtCustomizationsArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtCustomizationsResourceGroupResource GetMockableMgmtCustomizationsResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtCustomizationsResourceGroupResource(client, resource.Id)); } - #region PetStoreResource + /// /// 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. /// Returns a object. public static PetStoreResource GetPetStoreResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PetStoreResource.ValidateResourceId(id); - return new PetStoreResource(client, id); - } - ); + return GetMockableMgmtCustomizationsArmClient(client).GetPetStoreResource(id); } - #endregion - /// Gets a collection of PetStoreResources in the ResourceGroupResource. + /// + /// Gets a collection of PetStoreResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PetStoreResources and their operations over a PetStoreResource. public static PetStoreCollection GetPetStores(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPetStores(); + return GetMockableMgmtCustomizationsResourceGroupResource(resourceGroupResource).GetPetStores(); } /// @@ -72,16 +71,20 @@ public static PetStoreCollection GetPetStores(this ResourceGroupResource resourc /// PetStores_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name of the endpoint under the profile which is unique globally. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPetStoreAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPetStores().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtCustomizationsResourceGroupResource(resourceGroupResource).GetPetStoreAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -96,16 +99,20 @@ public static async Task> GetPetStoreAsync(this Resou /// PetStores_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name of the endpoint under the profile which is unique globally. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPetStore(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPetStores().Get(name, cancellationToken); + return GetMockableMgmtCustomizationsResourceGroupResource(resourceGroupResource).GetPetStore(name, cancellationToken); } } } diff --git a/test/TestProjects/MgmtCustomizations/Generated/Extensions/MockableMgmtCustomizationsArmClient.cs b/test/TestProjects/MgmtCustomizations/Generated/Extensions/MockableMgmtCustomizationsArmClient.cs new file mode 100644 index 00000000000..d219302ad81 --- /dev/null +++ b/test/TestProjects/MgmtCustomizations/Generated/Extensions/MockableMgmtCustomizationsArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtCustomizations; + +namespace MgmtCustomizations.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtCustomizationsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtCustomizationsArmClient() + { + } + + /// 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 MockableMgmtCustomizationsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtCustomizationsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 PetStoreResource GetPetStoreResource(ResourceIdentifier id) + { + PetStoreResource.ValidateResourceId(id); + return new PetStoreResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtCustomizations/Generated/Extensions/MockableMgmtCustomizationsResourceGroupResource.cs b/test/TestProjects/MgmtCustomizations/Generated/Extensions/MockableMgmtCustomizationsResourceGroupResource.cs new file mode 100644 index 00000000000..7bab762a42b --- /dev/null +++ b/test/TestProjects/MgmtCustomizations/Generated/Extensions/MockableMgmtCustomizationsResourceGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtCustomizations; + +namespace MgmtCustomizations.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtCustomizationsResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtCustomizationsResourceGroupResource() + { + } + + /// 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 MockableMgmtCustomizationsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of PetStoreResources in the ResourceGroupResource. + /// An object representing collection of PetStoreResources and their operations over a PetStoreResource. + public virtual PetStoreCollection GetPetStores() + { + return GetCachedClient(client => new PetStoreCollection(client, Id)); + } + + /// + /// Gets an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group and profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Pets/petStore/{name} + /// + /// + /// Operation Id + /// PetStores_Get + /// + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPetStoreAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPetStores().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group and profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Pets/petStore/{name} + /// + /// + /// Operation Id + /// PetStores_Get + /// + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPetStore(string name, CancellationToken cancellationToken = default) + { + return GetPetStores().Get(name, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtCustomizations/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtCustomizations/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 6d11cb115cd..00000000000 --- a/test/TestProjects/MgmtCustomizations/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtCustomizations -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of PetStoreResources in the ResourceGroupResource. - /// An object representing collection of PetStoreResources and their operations over a PetStoreResource. - public virtual PetStoreCollection GetPetStores() - { - return GetCachedClient(Client => new PetStoreCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MgmtDiscriminatorExtensions.cs b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MgmtDiscriminatorExtensions.cs index 34513c650c1..d842a36b355 100644 --- a/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MgmtDiscriminatorExtensions.cs +++ b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MgmtDiscriminatorExtensions.cs @@ -12,52 +12,51 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtDiscriminator.Mocking; namespace MgmtDiscriminator { /// A class to add extension methods to MgmtDiscriminator. public static partial class MgmtDiscriminatorExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtDiscriminatorArmClient GetMockableMgmtDiscriminatorArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtDiscriminatorArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtDiscriminatorResourceGroupResource GetMockableMgmtDiscriminatorResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtDiscriminatorResourceGroupResource(client, resource.Id)); } - #region DeliveryRuleResource + /// /// 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. /// Returns a object. public static DeliveryRuleResource GetDeliveryRuleResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DeliveryRuleResource.ValidateResourceId(id); - return new DeliveryRuleResource(client, id); - } - ); + return GetMockableMgmtDiscriminatorArmClient(client).GetDeliveryRuleResource(id); } - #endregion - /// Gets a collection of DeliveryRuleResources in the ResourceGroupResource. + /// + /// Gets a collection of DeliveryRuleResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeliveryRuleResources and their operations over a DeliveryRuleResource. public static DeliveryRuleCollection GetDeliveryRules(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDeliveryRules(); + return GetMockableMgmtDiscriminatorResourceGroupResource(resourceGroupResource).GetDeliveryRules(); } /// @@ -72,16 +71,20 @@ public static DeliveryRuleCollection GetDeliveryRules(this ResourceGroupResource /// DeliveryRules_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name of the endpoint under the profile which is unique globally. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeliveryRuleAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDeliveryRules().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtDiscriminatorResourceGroupResource(resourceGroupResource).GetDeliveryRuleAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -96,16 +99,20 @@ public static async Task> GetDeliveryRuleAsync(th /// DeliveryRules_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name of the endpoint under the profile which is unique globally. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeliveryRule(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDeliveryRules().Get(name, cancellationToken); + return GetMockableMgmtDiscriminatorResourceGroupResource(resourceGroupResource).GetDeliveryRule(name, cancellationToken); } } } diff --git a/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MockableMgmtDiscriminatorArmClient.cs b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MockableMgmtDiscriminatorArmClient.cs new file mode 100644 index 00000000000..5bb72f4a549 --- /dev/null +++ b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MockableMgmtDiscriminatorArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtDiscriminator; + +namespace MgmtDiscriminator.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtDiscriminatorArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtDiscriminatorArmClient() + { + } + + /// 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 MockableMgmtDiscriminatorArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtDiscriminatorArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 DeliveryRuleResource GetDeliveryRuleResource(ResourceIdentifier id) + { + DeliveryRuleResource.ValidateResourceId(id); + return new DeliveryRuleResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MockableMgmtDiscriminatorResourceGroupResource.cs b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MockableMgmtDiscriminatorResourceGroupResource.cs new file mode 100644 index 00000000000..5718d28da92 --- /dev/null +++ b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/MockableMgmtDiscriminatorResourceGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtDiscriminator; + +namespace MgmtDiscriminator.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtDiscriminatorResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtDiscriminatorResourceGroupResource() + { + } + + /// 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 MockableMgmtDiscriminatorResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of DeliveryRuleResources in the ResourceGroupResource. + /// An object representing collection of DeliveryRuleResources and their operations over a DeliveryRuleResource. + public virtual DeliveryRuleCollection GetDeliveryRules() + { + return GetCachedClient(client => new DeliveryRuleCollection(client, Id)); + } + + /// + /// Gets an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group and profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/deliveryRules/{name} + /// + /// + /// Operation Id + /// DeliveryRules_Get + /// + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeliveryRuleAsync(string name, CancellationToken cancellationToken = default) + { + return await GetDeliveryRules().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group and profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/deliveryRules/{name} + /// + /// + /// Operation Id + /// DeliveryRules_Get + /// + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeliveryRule(string name, CancellationToken cancellationToken = default) + { + return GetDeliveryRules().Get(name, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtDiscriminator/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtDiscriminator/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 38830f1a71c..00000000000 --- a/test/TestProjects/MgmtDiscriminator/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtDiscriminator -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of DeliveryRuleResources in the ResourceGroupResource. - /// An object representing collection of DeliveryRuleResources and their operations over a DeliveryRuleResource. - public virtual DeliveryRuleCollection GetDeliveryRules() - { - return GetCachedClient(Client => new DeliveryRuleCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MgmtExactMatchFlattenInheritanceExtensions.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MgmtExactMatchFlattenInheritanceExtensions.cs index f51e3f0fca4..a333e8f6f22 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MgmtExactMatchFlattenInheritanceExtensions.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MgmtExactMatchFlattenInheritanceExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtExactMatchFlattenInheritance.Mocking; using MgmtExactMatchFlattenInheritance.Models; namespace MgmtExactMatchFlattenInheritance @@ -19,84 +20,76 @@ namespace MgmtExactMatchFlattenInheritance /// A class to add extension methods to MgmtExactMatchFlattenInheritance. public static partial class MgmtExactMatchFlattenInheritanceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtExactMatchFlattenInheritanceArmClient GetMockableMgmtExactMatchFlattenInheritanceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtExactMatchFlattenInheritanceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtExactMatchFlattenInheritanceResourceGroupResource GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtExactMatchFlattenInheritanceResourceGroupResource(client, resource.Id)); } - #region AzureResourceFlattenModel1Resource + /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AzureResourceFlattenModel1Resource GetAzureResourceFlattenModel1Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AzureResourceFlattenModel1Resource.ValidateResourceId(id); - return new AzureResourceFlattenModel1Resource(client, id); - } - ); + return GetMockableMgmtExactMatchFlattenInheritanceArmClient(client).GetAzureResourceFlattenModel1Resource(id); } - #endregion - #region CustomModel2Resource /// /// 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. /// Returns a object. public static CustomModel2Resource GetCustomModel2Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - CustomModel2Resource.ValidateResourceId(id); - return new CustomModel2Resource(client, id); - } - ); + return GetMockableMgmtExactMatchFlattenInheritanceArmClient(client).GetCustomModel2Resource(id); } - #endregion - #region CustomModel3Resource /// /// 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. /// Returns a object. public static CustomModel3Resource GetCustomModel3Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - CustomModel3Resource.ValidateResourceId(id); - return new CustomModel3Resource(client, id); - } - ); + return GetMockableMgmtExactMatchFlattenInheritanceArmClient(client).GetCustomModel3Resource(id); } - #endregion - /// Gets a collection of AzureResourceFlattenModel1Resources in the ResourceGroupResource. + /// + /// Gets a collection of AzureResourceFlattenModel1Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of AzureResourceFlattenModel1Resources and their operations over a AzureResourceFlattenModel1Resource. public static AzureResourceFlattenModel1Collection GetAzureResourceFlattenModel1s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel1s(); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel1s(); } /// @@ -111,16 +104,20 @@ public static AzureResourceFlattenModel1Collection GetAzureResourceFlattenModel1 /// AzureResourceFlattenModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetAzureResourceFlattenModel1Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetAzureResourceFlattenModel1s().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel1Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -135,24 +132,34 @@ public static async Task> GetAzureR /// AzureResourceFlattenModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetAzureResourceFlattenModel1(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetAzureResourceFlattenModel1s().Get(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel1(name, cancellationToken); } - /// Gets a collection of CustomModel2Resources in the ResourceGroupResource. + /// + /// Gets a collection of CustomModel2Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of CustomModel2Resources and their operations over a CustomModel2Resource. public static CustomModel2Collection GetCustomModel2s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel2s(); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2s(); } /// @@ -167,16 +174,20 @@ public static CustomModel2Collection GetCustomModel2s(this ResourceGroupResource /// CustomModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetCustomModel2Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetCustomModel2s().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -191,24 +202,34 @@ public static async Task> GetCustomModel2Async(th /// CustomModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetCustomModel2(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetCustomModel2s().Get(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2(name, cancellationToken); } - /// Gets a collection of CustomModel3Resources in the ResourceGroupResource. + /// + /// Gets a collection of CustomModel3Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of CustomModel3Resources and their operations over a CustomModel3Resource. public static CustomModel3Collection GetCustomModel3s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel3s(); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel3s(); } /// @@ -223,16 +244,20 @@ public static CustomModel3Collection GetCustomModel3s(this ResourceGroupResource /// CustomModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetCustomModel3Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetCustomModel3s().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel3Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -247,16 +272,20 @@ public static async Task> GetCustomModel3Async(th /// CustomModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetCustomModel3(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetCustomModel3s().Get(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel3(name, cancellationToken); } /// @@ -271,13 +300,17 @@ public static Response GetCustomModel3(this ResourceGroupR /// AzureResourceFlattenModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAzureResourceFlattenModel2sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel2sAsync(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel2sAsync(cancellationToken); } /// @@ -292,13 +325,17 @@ public static AsyncPageable GetAzureResourceFlattenM /// AzureResourceFlattenModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAzureResourceFlattenModel2s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel2s(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel2s(cancellationToken); } /// @@ -313,6 +350,10 @@ public static Pageable GetAzureResourceFlattenModel2 /// AzureResourceFlattenModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -322,10 +363,7 @@ public static Pageable GetAzureResourceFlattenModel2 /// or is null. public static async Task> PutAzureResourceFlattenModel2Async(this ResourceGroupResource resourceGroupResource, string name, AzureResourceFlattenModel2 azureResourceFlattenModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(azureResourceFlattenModel2, nameof(azureResourceFlattenModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel2Async(name, azureResourceFlattenModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel2Async(name, azureResourceFlattenModel2, cancellationToken).ConfigureAwait(false); } /// @@ -340,6 +378,10 @@ public static async Task> PutAzureResourceF /// AzureResourceFlattenModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -349,10 +391,7 @@ public static async Task> PutAzureResourceF /// or is null. public static Response PutAzureResourceFlattenModel2(this ResourceGroupResource resourceGroupResource, string name, AzureResourceFlattenModel2 azureResourceFlattenModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(azureResourceFlattenModel2, nameof(azureResourceFlattenModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel2(name, azureResourceFlattenModel2, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel2(name, azureResourceFlattenModel2, cancellationToken); } /// @@ -367,6 +406,10 @@ public static Response PutAzureResourceFlattenModel2 /// AzureResourceFlattenModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -375,9 +418,7 @@ public static Response PutAzureResourceFlattenModel2 /// is null. public static async Task> GetAzureResourceFlattenModel2Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel2Async(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel2Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -392,6 +433,10 @@ public static async Task> GetAzureResourceF /// AzureResourceFlattenModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -400,9 +445,7 @@ public static async Task> GetAzureResourceF /// is null. public static Response GetAzureResourceFlattenModel2(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel2(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel2(name, cancellationToken); } /// @@ -417,13 +460,17 @@ public static Response GetAzureResourceFlattenModel2 /// AzureResourceFlattenModel3s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAzureResourceFlattenModel3sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel3sAsync(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel3sAsync(cancellationToken); } /// @@ -438,13 +485,17 @@ public static AsyncPageable GetAzureResourceFlattenM /// AzureResourceFlattenModel3s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAzureResourceFlattenModel3s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel3s(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel3s(cancellationToken); } /// @@ -459,6 +510,10 @@ public static Pageable GetAzureResourceFlattenModel3 /// AzureResourceFlattenModel3s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -468,10 +523,7 @@ public static Pageable GetAzureResourceFlattenModel3 /// or is null. public static async Task> PutAzureResourceFlattenModel3Async(this ResourceGroupResource resourceGroupResource, string name, AzureResourceFlattenModel3 azureResourceFlattenModel3, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(azureResourceFlattenModel3, nameof(azureResourceFlattenModel3)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel3Async(name, azureResourceFlattenModel3, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel3Async(name, azureResourceFlattenModel3, cancellationToken).ConfigureAwait(false); } /// @@ -486,6 +538,10 @@ public static async Task> PutAzureResourceF /// AzureResourceFlattenModel3s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -495,10 +551,7 @@ public static async Task> PutAzureResourceF /// or is null. public static Response PutAzureResourceFlattenModel3(this ResourceGroupResource resourceGroupResource, string name, AzureResourceFlattenModel3 azureResourceFlattenModel3, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(azureResourceFlattenModel3, nameof(azureResourceFlattenModel3)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel3(name, azureResourceFlattenModel3, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel3(name, azureResourceFlattenModel3, cancellationToken); } /// @@ -513,6 +566,10 @@ public static Response PutAzureResourceFlattenModel3 /// AzureResourceFlattenModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -521,9 +578,7 @@ public static Response PutAzureResourceFlattenModel3 /// is null. public static async Task> GetAzureResourceFlattenModel3Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel3Async(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel3Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -538,6 +593,10 @@ public static async Task> GetAzureResourceF /// AzureResourceFlattenModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -546,9 +605,7 @@ public static async Task> GetAzureResourceF /// is null. public static Response GetAzureResourceFlattenModel3(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel3(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel3(name, cancellationToken); } /// @@ -563,13 +620,17 @@ public static Response GetAzureResourceFlattenModel3 /// AzureResourceFlattenModel4s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAzureResourceFlattenModel4sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel4sAsync(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel4sAsync(cancellationToken); } /// @@ -584,13 +645,17 @@ public static AsyncPageable GetAzureResourceFlattenM /// AzureResourceFlattenModel4s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAzureResourceFlattenModel4s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel4s(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel4s(cancellationToken); } /// @@ -605,6 +670,10 @@ public static Pageable GetAzureResourceFlattenModel4 /// AzureResourceFlattenModel4s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -614,10 +683,7 @@ public static Pageable GetAzureResourceFlattenModel4 /// or is null. public static async Task> PutAzureResourceFlattenModel4Async(this ResourceGroupResource resourceGroupResource, string name, AzureResourceFlattenModel4 azureResourceFlattenModel4, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(azureResourceFlattenModel4, nameof(azureResourceFlattenModel4)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel4Async(name, azureResourceFlattenModel4, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel4Async(name, azureResourceFlattenModel4, cancellationToken).ConfigureAwait(false); } /// @@ -632,6 +698,10 @@ public static async Task> PutAzureResourceF /// AzureResourceFlattenModel4s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -641,10 +711,7 @@ public static async Task> PutAzureResourceF /// or is null. public static Response PutAzureResourceFlattenModel4(this ResourceGroupResource resourceGroupResource, string name, AzureResourceFlattenModel4 azureResourceFlattenModel4, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - Argument.AssertNotNull(azureResourceFlattenModel4, nameof(azureResourceFlattenModel4)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel4(name, azureResourceFlattenModel4, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel4(name, azureResourceFlattenModel4, cancellationToken); } /// @@ -659,6 +726,10 @@ public static Response PutAzureResourceFlattenModel4 /// AzureResourceFlattenModel4s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -667,9 +738,7 @@ public static Response PutAzureResourceFlattenModel4 /// is null. public static async Task> GetAzureResourceFlattenModel4Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel4Async(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel4Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -684,6 +753,10 @@ public static async Task> GetAzureResourceF /// AzureResourceFlattenModel4s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -692,9 +765,7 @@ public static async Task> GetAzureResourceF /// is null. public static Response GetAzureResourceFlattenModel4(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel4(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel4(name, cancellationToken); } /// @@ -709,13 +780,17 @@ public static Response GetAzureResourceFlattenModel4 /// AzureResourceFlattenModel5s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAzureResourceFlattenModel5sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel5sAsync(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel5sAsync(cancellationToken); } /// @@ -730,13 +805,17 @@ public static AsyncPageable GetAzureResourceFlattenM /// AzureResourceFlattenModel5s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAzureResourceFlattenModel5s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel5s(cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel5s(cancellationToken); } /// @@ -751,6 +830,10 @@ public static Pageable GetAzureResourceFlattenModel5 /// AzureResourceFlattenModel5s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -760,9 +843,7 @@ public static Pageable GetAzureResourceFlattenModel5 /// is null. public static async Task> PutAzureResourceFlattenModel5Async(this ResourceGroupResource resourceGroupResource, string name, int? foo = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel5Async(name, foo, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel5Async(name, foo, cancellationToken).ConfigureAwait(false); } /// @@ -777,6 +858,10 @@ public static async Task> PutAzureResourceF /// AzureResourceFlattenModel5s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -786,9 +871,7 @@ public static async Task> PutAzureResourceF /// is null. public static Response PutAzureResourceFlattenModel5(this ResourceGroupResource resourceGroupResource, string name, int? foo = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutAzureResourceFlattenModel5(name, foo, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).PutAzureResourceFlattenModel5(name, foo, cancellationToken); } /// @@ -803,6 +886,10 @@ public static Response PutAzureResourceFlattenModel5 /// AzureResourceFlattenModel5s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -811,9 +898,7 @@ public static Response PutAzureResourceFlattenModel5 /// is null. public static async Task> GetAzureResourceFlattenModel5Async(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel5Async(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel5Async(name, cancellationToken).ConfigureAwait(false); } /// @@ -828,6 +913,10 @@ public static async Task> GetAzureResourceF /// AzureResourceFlattenModel5s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -836,9 +925,7 @@ public static async Task> GetAzureResourceF /// is null. public static Response GetAzureResourceFlattenModel5(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAzureResourceFlattenModel5(name, cancellationToken); + return GetMockableMgmtExactMatchFlattenInheritanceResourceGroupResource(resourceGroupResource).GetAzureResourceFlattenModel5(name, cancellationToken); } } } diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MockableMgmtExactMatchFlattenInheritanceArmClient.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MockableMgmtExactMatchFlattenInheritanceArmClient.cs new file mode 100644 index 00000000000..aa1f69d900a --- /dev/null +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MockableMgmtExactMatchFlattenInheritanceArmClient.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtExactMatchFlattenInheritance; + +namespace MgmtExactMatchFlattenInheritance.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtExactMatchFlattenInheritanceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExactMatchFlattenInheritanceArmClient() + { + } + + /// 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 MockableMgmtExactMatchFlattenInheritanceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtExactMatchFlattenInheritanceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AzureResourceFlattenModel1Resource GetAzureResourceFlattenModel1Resource(ResourceIdentifier id) + { + AzureResourceFlattenModel1Resource.ValidateResourceId(id); + return new AzureResourceFlattenModel1Resource(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 CustomModel2Resource GetCustomModel2Resource(ResourceIdentifier id) + { + CustomModel2Resource.ValidateResourceId(id); + return new CustomModel2Resource(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 CustomModel3Resource GetCustomModel3Resource(ResourceIdentifier id) + { + CustomModel3Resource.ValidateResourceId(id); + return new CustomModel3Resource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.cs similarity index 68% rename from test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs rename to test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.cs index a809fdae913..7f68e9289f3 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/Generated/Extensions/MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.cs @@ -13,12 +13,13 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtExactMatchFlattenInheritance; using MgmtExactMatchFlattenInheritance.Models; -namespace MgmtExactMatchFlattenInheritance +namespace MgmtExactMatchFlattenInheritance.Mocking { /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource + public partial class MockableMgmtExactMatchFlattenInheritanceResourceGroupResource : ArmResource { private ClientDiagnostics _azureResourceFlattenModel2sClientDiagnostics; private AzureResourceFlattenModel2SRestOperations _azureResourceFlattenModel2sRestClient; @@ -29,15 +30,15 @@ internal partial class ResourceGroupResourceExtensionClient : ArmResource private ClientDiagnostics _azureResourceFlattenModel5sClientDiagnostics; private AzureResourceFlattenModel5SRestOperations _azureResourceFlattenModel5sRestClient; - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExactMatchFlattenInheritanceResourceGroupResource() { } - /// Initializes a new instance of the class. + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtExactMatchFlattenInheritanceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -60,21 +61,159 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of AzureResourceFlattenModel1Resources and their operations over a AzureResourceFlattenModel1Resource. public virtual AzureResourceFlattenModel1Collection GetAzureResourceFlattenModel1s() { - return GetCachedClient(Client => new AzureResourceFlattenModel1Collection(Client, Id)); + return GetCachedClient(client => new AzureResourceFlattenModel1Collection(client, Id)); + } + + /// + /// Get an AzureResourceFlattenModel1. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/azureResourceFlattenModel1s/{name} + /// + /// + /// Operation Id + /// AzureResourceFlattenModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAzureResourceFlattenModel1Async(string name, CancellationToken cancellationToken = default) + { + return await GetAzureResourceFlattenModel1s().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an AzureResourceFlattenModel1. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/azureResourceFlattenModel1s/{name} + /// + /// + /// Operation Id + /// AzureResourceFlattenModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAzureResourceFlattenModel1(string name, CancellationToken cancellationToken = default) + { + return GetAzureResourceFlattenModel1s().Get(name, cancellationToken); } /// Gets a collection of CustomModel2Resources in the ResourceGroupResource. /// An object representing collection of CustomModel2Resources and their operations over a CustomModel2Resource. public virtual CustomModel2Collection GetCustomModel2s() { - return GetCachedClient(Client => new CustomModel2Collection(Client, Id)); + return GetCachedClient(client => new CustomModel2Collection(client, Id)); + } + + /// + /// Get an CustomModel2. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/customModel2s/{name} + /// + /// + /// Operation Id + /// CustomModel2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetCustomModel2Async(string name, CancellationToken cancellationToken = default) + { + return await GetCustomModel2s().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an CustomModel2. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/customModel2s/{name} + /// + /// + /// Operation Id + /// CustomModel2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetCustomModel2(string name, CancellationToken cancellationToken = default) + { + return GetCustomModel2s().Get(name, cancellationToken); } /// Gets a collection of CustomModel3Resources in the ResourceGroupResource. /// An object representing collection of CustomModel3Resources and their operations over a CustomModel3Resource. public virtual CustomModel3Collection GetCustomModel3s() { - return GetCachedClient(Client => new CustomModel3Collection(Client, Id)); + return GetCachedClient(client => new CustomModel3Collection(client, Id)); + } + + /// + /// Get an CustomModel3. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/customModel3s/{name} + /// + /// + /// Operation Id + /// CustomModel3s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetCustomModel3Async(string name, CancellationToken cancellationToken = default) + { + return await GetCustomModel3s().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get an CustomModel3. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/customModel3s/{name} + /// + /// + /// Operation Id + /// CustomModel3s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetCustomModel3(string name, CancellationToken cancellationToken = default) + { + return GetCustomModel3s().Get(name, cancellationToken); } /// @@ -95,7 +234,7 @@ public virtual CustomModel3Collection GetCustomModel3s() public virtual AsyncPageable GetAzureResourceFlattenModel2sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel2.DeserializeAzureResourceFlattenModel2, AzureResourceFlattenModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel2.DeserializeAzureResourceFlattenModel2, AzureResourceFlattenModel2sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel2s", "value", null, cancellationToken); } /// @@ -116,7 +255,7 @@ public virtual AsyncPageable GetAzureResourceFlatten public virtual Pageable GetAzureResourceFlattenModel2s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel2.DeserializeAzureResourceFlattenModel2, AzureResourceFlattenModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel2.DeserializeAzureResourceFlattenModel2, AzureResourceFlattenModel2sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel2s", "value", null, cancellationToken); } /// @@ -135,9 +274,14 @@ public virtual Pageable GetAzureResourceFlattenModel /// The String to use. /// The AzureResourceFlattenModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutAzureResourceFlattenModel2Async(string name, AzureResourceFlattenModel2 azureResourceFlattenModel2, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel2"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(azureResourceFlattenModel2, nameof(azureResourceFlattenModel2)); + + using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel2"); scope.Start(); try { @@ -167,9 +311,14 @@ public virtual async Task> PutAzureResource /// The String to use. /// The AzureResourceFlattenModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutAzureResourceFlattenModel2(string name, AzureResourceFlattenModel2 azureResourceFlattenModel2, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel2"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(azureResourceFlattenModel2, nameof(azureResourceFlattenModel2)); + + using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel2"); scope.Start(); try { @@ -198,9 +347,13 @@ public virtual Response PutAzureResourceFlattenModel /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetAzureResourceFlattenModel2Async(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel2"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel2"); scope.Start(); try { @@ -229,9 +382,13 @@ public virtual async Task> GetAzureResource /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetAzureResourceFlattenModel2(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel2"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel2sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel2"); scope.Start(); try { @@ -263,7 +420,7 @@ public virtual Response GetAzureResourceFlattenModel public virtual AsyncPageable GetAzureResourceFlattenModel3sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel3sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel3.DeserializeAzureResourceFlattenModel3, AzureResourceFlattenModel3sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel3s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel3.DeserializeAzureResourceFlattenModel3, AzureResourceFlattenModel3sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel3s", "value", null, cancellationToken); } /// @@ -284,7 +441,7 @@ public virtual AsyncPageable GetAzureResourceFlatten public virtual Pageable GetAzureResourceFlattenModel3s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel3sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel3.DeserializeAzureResourceFlattenModel3, AzureResourceFlattenModel3sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel3s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel3.DeserializeAzureResourceFlattenModel3, AzureResourceFlattenModel3sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel3s", "value", null, cancellationToken); } /// @@ -303,9 +460,14 @@ public virtual Pageable GetAzureResourceFlattenModel /// The String to use. /// The AzureResourceFlattenModel3 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutAzureResourceFlattenModel3Async(string name, AzureResourceFlattenModel3 azureResourceFlattenModel3, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel3"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(azureResourceFlattenModel3, nameof(azureResourceFlattenModel3)); + + using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel3"); scope.Start(); try { @@ -335,9 +497,14 @@ public virtual async Task> PutAzureResource /// The String to use. /// The AzureResourceFlattenModel3 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutAzureResourceFlattenModel3(string name, AzureResourceFlattenModel3 azureResourceFlattenModel3, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel3"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(azureResourceFlattenModel3, nameof(azureResourceFlattenModel3)); + + using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel3"); scope.Start(); try { @@ -366,9 +533,13 @@ public virtual Response PutAzureResourceFlattenModel /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetAzureResourceFlattenModel3Async(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel3"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel3"); scope.Start(); try { @@ -397,9 +568,13 @@ public virtual async Task> GetAzureResource /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetAzureResourceFlattenModel3(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel3"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel3"); scope.Start(); try { @@ -431,7 +606,7 @@ public virtual Response GetAzureResourceFlattenModel public virtual AsyncPageable GetAzureResourceFlattenModel4sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel4sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel4.DeserializeAzureResourceFlattenModel4, AzureResourceFlattenModel4sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel4s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel4.DeserializeAzureResourceFlattenModel4, AzureResourceFlattenModel4sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel4s", "value", null, cancellationToken); } /// @@ -452,7 +627,7 @@ public virtual AsyncPageable GetAzureResourceFlatten public virtual Pageable GetAzureResourceFlattenModel4s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel4sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel4.DeserializeAzureResourceFlattenModel4, AzureResourceFlattenModel4sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel4s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel4.DeserializeAzureResourceFlattenModel4, AzureResourceFlattenModel4sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel4s", "value", null, cancellationToken); } /// @@ -471,9 +646,14 @@ public virtual Pageable GetAzureResourceFlattenModel /// The String to use. /// The AzureResourceFlattenModel4 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutAzureResourceFlattenModel4Async(string name, AzureResourceFlattenModel4 azureResourceFlattenModel4, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel4"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(azureResourceFlattenModel4, nameof(azureResourceFlattenModel4)); + + using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel4"); scope.Start(); try { @@ -503,9 +683,14 @@ public virtual async Task> PutAzureResource /// The String to use. /// The AzureResourceFlattenModel4 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutAzureResourceFlattenModel4(string name, AzureResourceFlattenModel4 azureResourceFlattenModel4, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel4"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(azureResourceFlattenModel4, nameof(azureResourceFlattenModel4)); + + using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel4"); scope.Start(); try { @@ -534,9 +719,13 @@ public virtual Response PutAzureResourceFlattenModel /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetAzureResourceFlattenModel4Async(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel4"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel4"); scope.Start(); try { @@ -565,9 +754,13 @@ public virtual async Task> GetAzureResource /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetAzureResourceFlattenModel4(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel4"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel4sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel4"); scope.Start(); try { @@ -599,7 +792,7 @@ public virtual Response GetAzureResourceFlattenModel public virtual AsyncPageable GetAzureResourceFlattenModel5sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel5sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel5.DeserializeAzureResourceFlattenModel5, AzureResourceFlattenModel5sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel5s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, AzureResourceFlattenModel5.DeserializeAzureResourceFlattenModel5, AzureResourceFlattenModel5sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel5s", "value", null, cancellationToken); } /// @@ -620,7 +813,7 @@ public virtual AsyncPageable GetAzureResourceFlatten public virtual Pageable GetAzureResourceFlattenModel5s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => AzureResourceFlattenModel5sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel5.DeserializeAzureResourceFlattenModel5, AzureResourceFlattenModel5sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel5s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, AzureResourceFlattenModel5.DeserializeAzureResourceFlattenModel5, AzureResourceFlattenModel5sClientDiagnostics, Pipeline, "MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel5s", "value", null, cancellationToken); } /// @@ -639,9 +832,13 @@ public virtual Pageable GetAzureResourceFlattenModel /// The String to use. /// New property. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> PutAzureResourceFlattenModel5Async(string name, int? foo = null, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel5"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel5"); scope.Start(); try { @@ -671,9 +868,13 @@ public virtual async Task> PutAzureResource /// The String to use. /// New property. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response PutAzureResourceFlattenModel5(string name, int? foo = null, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutAzureResourceFlattenModel5"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.PutAzureResourceFlattenModel5"); scope.Start(); try { @@ -702,9 +903,13 @@ public virtual Response PutAzureResourceFlattenModel /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetAzureResourceFlattenModel5Async(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel5"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel5"); scope.Start(); try { @@ -733,9 +938,13 @@ public virtual async Task> GetAzureResource /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetAzureResourceFlattenModel5(string name, CancellationToken cancellationToken = default) { - using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetAzureResourceFlattenModel5"); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var scope = AzureResourceFlattenModel5sClientDiagnostics.CreateScope("MockableMgmtExactMatchFlattenInheritanceResourceGroupResource.GetAzureResourceFlattenModel5"); scope.Start(); try { diff --git a/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MgmtExactMatchInheritanceExtensions.cs b/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MgmtExactMatchInheritanceExtensions.cs index 022f2bbd61f..7a744276285 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MgmtExactMatchInheritanceExtensions.cs +++ b/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MgmtExactMatchInheritanceExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtExactMatchInheritance.Mocking; using MgmtExactMatchInheritance.Models; namespace MgmtExactMatchInheritance @@ -19,65 +20,60 @@ namespace MgmtExactMatchInheritance /// A class to add extension methods to MgmtExactMatchInheritance. public static partial class MgmtExactMatchInheritanceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtExactMatchInheritanceArmClient GetMockableMgmtExactMatchInheritanceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtExactMatchInheritanceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtExactMatchInheritanceResourceGroupResource GetMockableMgmtExactMatchInheritanceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtExactMatchInheritanceResourceGroupResource(client, resource.Id)); } - #region ExactMatchModel1Resource + /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static ExactMatchModel1Resource GetExactMatchModel1Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ExactMatchModel1Resource.ValidateResourceId(id); - return new ExactMatchModel1Resource(client, id); - } - ); + return GetMockableMgmtExactMatchInheritanceArmClient(client).GetExactMatchModel1Resource(id); } - #endregion - #region ExactMatchModel5Resource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static ExactMatchModel5Resource GetExactMatchModel5Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ExactMatchModel5Resource.ValidateResourceId(id); - return new ExactMatchModel5Resource(client, id); - } - ); + return GetMockableMgmtExactMatchInheritanceArmClient(client).GetExactMatchModel5Resource(id); } - #endregion - /// Gets a collection of ExactMatchModel1Resources in the ResourceGroupResource. + /// + /// Gets a collection of ExactMatchModel1Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ExactMatchModel1Resources and their operations over a ExactMatchModel1Resource. public static ExactMatchModel1Collection GetExactMatchModel1s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetExactMatchModel1s(); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel1s(); } /// @@ -91,16 +87,20 @@ public static ExactMatchModel1Collection GetExactMatchModel1s(this ResourceGroup /// ExactMatchModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetExactMatchModel1Async(this ResourceGroupResource resourceGroupResource, string exactMatchModel1SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetExactMatchModel1s().GetAsync(exactMatchModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel1Async(exactMatchModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -114,24 +114,34 @@ public static async Task> GetExactMatchModel1 /// ExactMatchModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetExactMatchModel1(this ResourceGroupResource resourceGroupResource, string exactMatchModel1SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetExactMatchModel1s().Get(exactMatchModel1SName, cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel1(exactMatchModel1SName, cancellationToken); } - /// Gets a collection of ExactMatchModel5Resources in the ResourceGroupResource. + /// + /// Gets a collection of ExactMatchModel5Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ExactMatchModel5Resources and their operations over a ExactMatchModel5Resource. public static ExactMatchModel5Collection GetExactMatchModel5s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetExactMatchModel5s(); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel5s(); } /// @@ -145,16 +155,20 @@ public static ExactMatchModel5Collection GetExactMatchModel5s(this ResourceGroup /// ExactMatchModel5s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetExactMatchModel5Async(this ResourceGroupResource resourceGroupResource, string exactMatchModel5SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetExactMatchModel5s().GetAsync(exactMatchModel5SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel5Async(exactMatchModel5SName, cancellationToken).ConfigureAwait(false); } /// @@ -168,16 +182,20 @@ public static async Task> GetExactMatchModel5 /// ExactMatchModel5s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetExactMatchModel5(this ResourceGroupResource resourceGroupResource, string exactMatchModel5SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetExactMatchModel5s().Get(exactMatchModel5SName, cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel5(exactMatchModel5SName, cancellationToken); } /// @@ -191,6 +209,10 @@ public static Response GetExactMatchModel5(this Resour /// ExactMatchModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -200,10 +222,7 @@ public static Response GetExactMatchModel5(this Resour /// or is null. public static async Task> PutExactMatchModel2Async(this ResourceGroupResource resourceGroupResource, string exactMatchModel2SName, ExactMatchModel2 exactMatchModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel2SName, nameof(exactMatchModel2SName)); - Argument.AssertNotNull(exactMatchModel2, nameof(exactMatchModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutExactMatchModel2Async(exactMatchModel2SName, exactMatchModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).PutExactMatchModel2Async(exactMatchModel2SName, exactMatchModel2, cancellationToken).ConfigureAwait(false); } /// @@ -217,6 +236,10 @@ public static async Task> PutExactMatchModel2Async(th /// ExactMatchModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -226,10 +249,7 @@ public static async Task> PutExactMatchModel2Async(th /// or is null. public static Response PutExactMatchModel2(this ResourceGroupResource resourceGroupResource, string exactMatchModel2SName, ExactMatchModel2 exactMatchModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel2SName, nameof(exactMatchModel2SName)); - Argument.AssertNotNull(exactMatchModel2, nameof(exactMatchModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutExactMatchModel2(exactMatchModel2SName, exactMatchModel2, cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).PutExactMatchModel2(exactMatchModel2SName, exactMatchModel2, cancellationToken); } /// @@ -243,13 +263,17 @@ public static Response PutExactMatchModel2(this ResourceGroupR /// ExactMatchModel3s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetExactMatchModel3sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetExactMatchModel3sAsync(cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel3sAsync(cancellationToken); } /// @@ -263,13 +287,17 @@ public static AsyncPageable GetExactMatchModel3sAsync(this Res /// ExactMatchModel3s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetExactMatchModel3s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetExactMatchModel3s(cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel3s(cancellationToken); } /// @@ -283,6 +311,10 @@ public static Pageable GetExactMatchModel3s(this ResourceGroup /// ExactMatchModel3s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -292,10 +324,7 @@ public static Pageable GetExactMatchModel3s(this ResourceGroup /// or is null. public static async Task> PutExactMatchModel3Async(this ResourceGroupResource resourceGroupResource, string exactMatchModel3SName, ExactMatchModel3 exactMatchModel3, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); - Argument.AssertNotNull(exactMatchModel3, nameof(exactMatchModel3)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutExactMatchModel3Async(exactMatchModel3SName, exactMatchModel3, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).PutExactMatchModel3Async(exactMatchModel3SName, exactMatchModel3, cancellationToken).ConfigureAwait(false); } /// @@ -309,6 +338,10 @@ public static async Task> PutExactMatchModel3Async(th /// ExactMatchModel3s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -318,10 +351,7 @@ public static async Task> PutExactMatchModel3Async(th /// or is null. public static Response PutExactMatchModel3(this ResourceGroupResource resourceGroupResource, string exactMatchModel3SName, ExactMatchModel3 exactMatchModel3, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); - Argument.AssertNotNull(exactMatchModel3, nameof(exactMatchModel3)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutExactMatchModel3(exactMatchModel3SName, exactMatchModel3, cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).PutExactMatchModel3(exactMatchModel3SName, exactMatchModel3, cancellationToken); } /// @@ -335,6 +365,10 @@ public static Response PutExactMatchModel3(this ResourceGroupR /// ExactMatchModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -343,9 +377,7 @@ public static Response PutExactMatchModel3(this ResourceGroupR /// is null. public static async Task> GetExactMatchModel3Async(this ResourceGroupResource resourceGroupResource, string exactMatchModel3SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetExactMatchModel3Async(exactMatchModel3SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel3Async(exactMatchModel3SName, cancellationToken).ConfigureAwait(false); } /// @@ -359,6 +391,10 @@ public static async Task> GetExactMatchModel3Async(th /// ExactMatchModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -367,9 +403,7 @@ public static async Task> GetExactMatchModel3Async(th /// is null. public static Response GetExactMatchModel3(this ResourceGroupResource resourceGroupResource, string exactMatchModel3SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetExactMatchModel3(exactMatchModel3SName, cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).GetExactMatchModel3(exactMatchModel3SName, cancellationToken); } /// @@ -383,6 +417,10 @@ public static Response GetExactMatchModel3(this ResourceGroupR /// ExactMatchModel4s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -392,10 +430,7 @@ public static Response GetExactMatchModel3(this ResourceGroupR /// or is null. public static async Task> PutExactMatchModel4Async(this ResourceGroupResource resourceGroupResource, string exactMatchModel4SName, ExactMatchModel4 exactMatchModel4, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel4SName, nameof(exactMatchModel4SName)); - Argument.AssertNotNull(exactMatchModel4, nameof(exactMatchModel4)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutExactMatchModel4Async(exactMatchModel4SName, exactMatchModel4, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).PutExactMatchModel4Async(exactMatchModel4SName, exactMatchModel4, cancellationToken).ConfigureAwait(false); } /// @@ -409,6 +444,10 @@ public static async Task> PutExactMatchModel4Async(th /// ExactMatchModel4s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -418,10 +457,7 @@ public static async Task> PutExactMatchModel4Async(th /// or is null. public static Response PutExactMatchModel4(this ResourceGroupResource resourceGroupResource, string exactMatchModel4SName, ExactMatchModel4 exactMatchModel4, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(exactMatchModel4SName, nameof(exactMatchModel4SName)); - Argument.AssertNotNull(exactMatchModel4, nameof(exactMatchModel4)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutExactMatchModel4(exactMatchModel4SName, exactMatchModel4, cancellationToken); + return GetMockableMgmtExactMatchInheritanceResourceGroupResource(resourceGroupResource).PutExactMatchModel4(exactMatchModel4SName, exactMatchModel4, cancellationToken); } } } diff --git a/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MockableMgmtExactMatchInheritanceArmClient.cs b/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MockableMgmtExactMatchInheritanceArmClient.cs new file mode 100644 index 00000000000..b8f7fef54c5 --- /dev/null +++ b/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MockableMgmtExactMatchInheritanceArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtExactMatchInheritance; + +namespace MgmtExactMatchInheritance.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtExactMatchInheritanceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExactMatchInheritanceArmClient() + { + } + + /// 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 MockableMgmtExactMatchInheritanceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtExactMatchInheritanceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ExactMatchModel1Resource GetExactMatchModel1Resource(ResourceIdentifier id) + { + ExactMatchModel1Resource.ValidateResourceId(id); + return new ExactMatchModel1Resource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ExactMatchModel5Resource GetExactMatchModel5Resource(ResourceIdentifier id) + { + ExactMatchModel5Resource.ValidateResourceId(id); + return new ExactMatchModel5Resource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MockableMgmtExactMatchInheritanceResourceGroupResource.cs similarity index 61% rename from test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs rename to test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MockableMgmtExactMatchInheritanceResourceGroupResource.cs index c61d20905b2..258874f9e17 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ b/test/TestProjects/MgmtExactMatchInheritance/Generated/Extensions/MockableMgmtExactMatchInheritanceResourceGroupResource.cs @@ -13,12 +13,13 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtExactMatchInheritance; using MgmtExactMatchInheritance.Models; -namespace MgmtExactMatchInheritance +namespace MgmtExactMatchInheritance.Mocking { /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource + public partial class MockableMgmtExactMatchInheritanceResourceGroupResource : ArmResource { private ClientDiagnostics _exactMatchModel2sClientDiagnostics; private ExactMatchModel2SRestOperations _exactMatchModel2sRestClient; @@ -27,15 +28,15 @@ internal partial class ResourceGroupResourceExtensionClient : ArmResource private ClientDiagnostics _exactMatchModel4sClientDiagnostics; private ExactMatchModel4SRestOperations _exactMatchModel4sRestClient; - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExactMatchInheritanceResourceGroupResource() { } - /// Initializes a new instance of the class. + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtExactMatchInheritanceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -56,14 +57,102 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of ExactMatchModel1Resources and their operations over a ExactMatchModel1Resource. public virtual ExactMatchModel1Collection GetExactMatchModel1s() { - return GetCachedClient(Client => new ExactMatchModel1Collection(Client, Id)); + return GetCachedClient(client => new ExactMatchModel1Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/exactMatchModel1s/{exactMatchModel1sName} + /// + /// + /// Operation Id + /// ExactMatchModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetExactMatchModel1Async(string exactMatchModel1SName, CancellationToken cancellationToken = default) + { + return await GetExactMatchModel1s().GetAsync(exactMatchModel1SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/exactMatchModel1s/{exactMatchModel1sName} + /// + /// + /// Operation Id + /// ExactMatchModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetExactMatchModel1(string exactMatchModel1SName, CancellationToken cancellationToken = default) + { + return GetExactMatchModel1s().Get(exactMatchModel1SName, cancellationToken); } /// Gets a collection of ExactMatchModel5Resources in the ResourceGroupResource. /// An object representing collection of ExactMatchModel5Resources and their operations over a ExactMatchModel5Resource. public virtual ExactMatchModel5Collection GetExactMatchModel5s() { - return GetCachedClient(Client => new ExactMatchModel5Collection(Client, Id)); + return GetCachedClient(client => new ExactMatchModel5Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/exactMatchModel5s/{exactMatchModel5sName} + /// + /// + /// Operation Id + /// ExactMatchModel5s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetExactMatchModel5Async(string exactMatchModel5SName, CancellationToken cancellationToken = default) + { + return await GetExactMatchModel5s().GetAsync(exactMatchModel5SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/exactMatchModel5s/{exactMatchModel5sName} + /// + /// + /// Operation Id + /// ExactMatchModel5s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetExactMatchModel5(string exactMatchModel5SName, CancellationToken cancellationToken = default) + { + return GetExactMatchModel5s().Get(exactMatchModel5SName, cancellationToken); } /// @@ -81,9 +170,14 @@ public virtual ExactMatchModel5Collection GetExactMatchModel5s() /// The String to use. /// The ExactMatchModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutExactMatchModel2Async(string exactMatchModel2SName, ExactMatchModel2 exactMatchModel2, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutExactMatchModel2"); + Argument.AssertNotNullOrEmpty(exactMatchModel2SName, nameof(exactMatchModel2SName)); + Argument.AssertNotNull(exactMatchModel2, nameof(exactMatchModel2)); + + using var scope = ExactMatchModel2sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.PutExactMatchModel2"); scope.Start(); try { @@ -112,9 +206,14 @@ public virtual async Task> PutExactMatchModel2Async(s /// The String to use. /// The ExactMatchModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutExactMatchModel2(string exactMatchModel2SName, ExactMatchModel2 exactMatchModel2, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutExactMatchModel2"); + Argument.AssertNotNullOrEmpty(exactMatchModel2SName, nameof(exactMatchModel2SName)); + Argument.AssertNotNull(exactMatchModel2, nameof(exactMatchModel2)); + + using var scope = ExactMatchModel2sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.PutExactMatchModel2"); scope.Start(); try { @@ -145,7 +244,7 @@ public virtual Response PutExactMatchModel2(string exactMatchM public virtual AsyncPageable GetExactMatchModel3sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => ExactMatchModel3sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, ExactMatchModel3.DeserializeExactMatchModel3, ExactMatchModel3sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetExactMatchModel3s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, ExactMatchModel3.DeserializeExactMatchModel3, ExactMatchModel3sClientDiagnostics, Pipeline, "MockableMgmtExactMatchInheritanceResourceGroupResource.GetExactMatchModel3s", "value", null, cancellationToken); } /// @@ -165,7 +264,7 @@ public virtual AsyncPageable GetExactMatchModel3sAsync(Cancell public virtual Pageable GetExactMatchModel3s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => ExactMatchModel3sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, ExactMatchModel3.DeserializeExactMatchModel3, ExactMatchModel3sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetExactMatchModel3s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, ExactMatchModel3.DeserializeExactMatchModel3, ExactMatchModel3sClientDiagnostics, Pipeline, "MockableMgmtExactMatchInheritanceResourceGroupResource.GetExactMatchModel3s", "value", null, cancellationToken); } /// @@ -183,9 +282,14 @@ public virtual Pageable GetExactMatchModel3s(CancellationToken /// The String to use. /// The ExactMatchModel3 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutExactMatchModel3Async(string exactMatchModel3SName, ExactMatchModel3 exactMatchModel3, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutExactMatchModel3"); + Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); + Argument.AssertNotNull(exactMatchModel3, nameof(exactMatchModel3)); + + using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.PutExactMatchModel3"); scope.Start(); try { @@ -214,9 +318,14 @@ public virtual async Task> PutExactMatchModel3Async(s /// The String to use. /// The ExactMatchModel3 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutExactMatchModel3(string exactMatchModel3SName, ExactMatchModel3 exactMatchModel3, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutExactMatchModel3"); + Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); + Argument.AssertNotNull(exactMatchModel3, nameof(exactMatchModel3)); + + using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.PutExactMatchModel3"); scope.Start(); try { @@ -244,9 +353,13 @@ public virtual Response PutExactMatchModel3(string exactMatchM /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetExactMatchModel3Async(string exactMatchModel3SName, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetExactMatchModel3"); + Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); + + using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.GetExactMatchModel3"); scope.Start(); try { @@ -274,9 +387,13 @@ public virtual async Task> GetExactMatchModel3Async(s /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetExactMatchModel3(string exactMatchModel3SName, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetExactMatchModel3"); + Argument.AssertNotNullOrEmpty(exactMatchModel3SName, nameof(exactMatchModel3SName)); + + using var scope = ExactMatchModel3sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.GetExactMatchModel3"); scope.Start(); try { @@ -305,9 +422,14 @@ public virtual Response GetExactMatchModel3(string exactMatchM /// The String to use. /// The ExactMatchModel4 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutExactMatchModel4Async(string exactMatchModel4SName, ExactMatchModel4 exactMatchModel4, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel4sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutExactMatchModel4"); + Argument.AssertNotNullOrEmpty(exactMatchModel4SName, nameof(exactMatchModel4SName)); + Argument.AssertNotNull(exactMatchModel4, nameof(exactMatchModel4)); + + using var scope = ExactMatchModel4sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.PutExactMatchModel4"); scope.Start(); try { @@ -336,9 +458,14 @@ public virtual async Task> PutExactMatchModel4Async(s /// The String to use. /// The ExactMatchModel4 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutExactMatchModel4(string exactMatchModel4SName, ExactMatchModel4 exactMatchModel4, CancellationToken cancellationToken = default) { - using var scope = ExactMatchModel4sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutExactMatchModel4"); + Argument.AssertNotNullOrEmpty(exactMatchModel4SName, nameof(exactMatchModel4SName)); + Argument.AssertNotNull(exactMatchModel4, nameof(exactMatchModel4)); + + using var scope = ExactMatchModel4sClientDiagnostics.CreateScope("MockableMgmtExactMatchInheritanceResourceGroupResource.PutExactMatchModel4"); scope.Start(); try { diff --git a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MgmtExpandResourceTypesExtensions.cs b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MgmtExpandResourceTypesExtensions.cs index a3bc091e94a..418ce911863 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MgmtExpandResourceTypesExtensions.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MgmtExpandResourceTypesExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtExpandResourceTypes.Mocking; using MgmtExpandResourceTypes.Models; namespace MgmtExpandResourceTypes @@ -19,252 +20,209 @@ namespace MgmtExpandResourceTypes /// A class to add extension methods to MgmtExpandResourceTypes. public static partial class MgmtExpandResourceTypesExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtExpandResourceTypesArmClient GetMockableMgmtExpandResourceTypesArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtExpandResourceTypesArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtExpandResourceTypesResourceGroupResource GetMockableMgmtExpandResourceTypesResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtExpandResourceTypesResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtExpandResourceTypesSubscriptionResource GetMockableMgmtExpandResourceTypesSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtExpandResourceTypesSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region RecordSetAResource /// /// 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. /// Returns a object. public static RecordSetAResource GetRecordSetAResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetAResource.ValidateResourceId(id); - return new RecordSetAResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetAResource(id); } - #endregion - #region RecordSetAaaaResource /// /// 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. /// Returns a object. public static RecordSetAaaaResource GetRecordSetAaaaResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetAaaaResource.ValidateResourceId(id); - return new RecordSetAaaaResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetAaaaResource(id); } - #endregion - #region RecordSetCaaResource /// /// 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. /// Returns a object. public static RecordSetCaaResource GetRecordSetCaaResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetCaaResource.ValidateResourceId(id); - return new RecordSetCaaResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetCaaResource(id); } - #endregion - #region RecordSetCNameResource /// /// 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. /// Returns a object. public static RecordSetCNameResource GetRecordSetCNameResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetCNameResource.ValidateResourceId(id); - return new RecordSetCNameResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetCNameResource(id); } - #endregion - #region RecordSetMxResource /// /// 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. /// Returns a object. public static RecordSetMxResource GetRecordSetMxResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetMxResource.ValidateResourceId(id); - return new RecordSetMxResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetMxResource(id); } - #endregion - #region RecordSetNsResource /// /// 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. /// Returns a object. public static RecordSetNsResource GetRecordSetNsResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetNsResource.ValidateResourceId(id); - return new RecordSetNsResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetNsResource(id); } - #endregion - #region RecordSetPtrResource /// /// 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. /// Returns a object. public static RecordSetPtrResource GetRecordSetPtrResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetPtrResource.ValidateResourceId(id); - return new RecordSetPtrResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetPtrResource(id); } - #endregion - #region RecordSetSoaResource /// /// 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. /// Returns a object. public static RecordSetSoaResource GetRecordSetSoaResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetSoaResource.ValidateResourceId(id); - return new RecordSetSoaResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetSoaResource(id); } - #endregion - #region RecordSetSrvResource /// /// 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. /// Returns a object. public static RecordSetSrvResource GetRecordSetSrvResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetSrvResource.ValidateResourceId(id); - return new RecordSetSrvResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetSrvResource(id); } - #endregion - #region RecordSetTxtResource /// /// 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. /// Returns a object. public static RecordSetTxtResource GetRecordSetTxtResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RecordSetTxtResource.ValidateResourceId(id); - return new RecordSetTxtResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetRecordSetTxtResource(id); } - #endregion - #region ZoneResource /// /// 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. /// Returns a object. public static ZoneResource GetZoneResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ZoneResource.ValidateResourceId(id); - return new ZoneResource(client, id); - } - ); + return GetMockableMgmtExpandResourceTypesArmClient(client).GetZoneResource(id); } - #endregion - /// Gets a collection of ZoneResources in the ResourceGroupResource. + /// + /// Gets a collection of ZoneResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ZoneResources and their operations over a ZoneResource. public static ZoneCollection GetZones(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetZones(); + return GetMockableMgmtExpandResourceTypesResourceGroupResource(resourceGroupResource).GetZones(); } /// @@ -279,16 +237,20 @@ public static ZoneCollection GetZones(this ResourceGroupResource resourceGroupRe /// Zones_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the DNS zone (without a terminating dot). /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetZoneAsync(this ResourceGroupResource resourceGroupResource, string zoneName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetZones().GetAsync(zoneName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExpandResourceTypesResourceGroupResource(resourceGroupResource).GetZoneAsync(zoneName, cancellationToken).ConfigureAwait(false); } /// @@ -303,16 +265,20 @@ public static async Task> GetZoneAsync(this ResourceGroup /// Zones_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the DNS zone (without a terminating dot). /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetZone(this ResourceGroupResource resourceGroupResource, string zoneName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetZones().Get(zoneName, cancellationToken); + return GetMockableMgmtExpandResourceTypesResourceGroupResource(resourceGroupResource).GetZone(zoneName, cancellationToken); } /// @@ -327,6 +293,10 @@ public static Response GetZone(this ResourceGroupResource resource /// Zones_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The maximum number of DNS zones to return. If not specified, returns up to 100 zones. @@ -334,7 +304,7 @@ public static Response GetZone(this ResourceGroupResource resource /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetZonesByDnszoneAsync(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetZonesByDnszoneAsync(top, cancellationToken); + return GetMockableMgmtExpandResourceTypesSubscriptionResource(subscriptionResource).GetZonesByDnszoneAsync(top, cancellationToken); } /// @@ -349,6 +319,10 @@ public static AsyncPageable GetZonesByDnszoneAsync(this Subscripti /// Zones_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The maximum number of DNS zones to return. If not specified, returns up to 100 zones. @@ -356,7 +330,7 @@ public static AsyncPageable GetZonesByDnszoneAsync(this Subscripti /// A collection of that may take multiple service requests to iterate over. public static Pageable GetZonesByDnszone(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetZonesByDnszone(top, cancellationToken); + return GetMockableMgmtExpandResourceTypesSubscriptionResource(subscriptionResource).GetZonesByDnszone(top, cancellationToken); } /// @@ -371,6 +345,10 @@ public static Pageable GetZonesByDnszone(this SubscriptionResource /// DnsResourceReference_GetByTargetResources /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Properties for dns resource reference request. @@ -378,9 +356,7 @@ public static Pageable GetZonesByDnszone(this SubscriptionResource /// is null. public static async Task> GetByTargetResourcesDnsResourceReferenceAsync(this SubscriptionResource subscriptionResource, DnsResourceReferenceContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).GetByTargetResourcesDnsResourceReferenceAsync(content, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExpandResourceTypesSubscriptionResource(subscriptionResource).GetByTargetResourcesDnsResourceReferenceAsync(content, cancellationToken).ConfigureAwait(false); } /// @@ -395,6 +371,10 @@ public static async Task> GetByTargetResour /// DnsResourceReference_GetByTargetResources /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Properties for dns resource reference request. @@ -402,9 +382,7 @@ public static async Task> GetByTargetResour /// is null. public static Response GetByTargetResourcesDnsResourceReference(this SubscriptionResource subscriptionResource, DnsResourceReferenceContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetByTargetResourcesDnsResourceReference(content, cancellationToken); + return GetMockableMgmtExpandResourceTypesSubscriptionResource(subscriptionResource).GetByTargetResourcesDnsResourceReference(content, cancellationToken); } } } diff --git a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesArmClient.cs b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesArmClient.cs new file mode 100644 index 00000000000..82a5877912a --- /dev/null +++ b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesArmClient.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtExpandResourceTypes; + +namespace MgmtExpandResourceTypes.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtExpandResourceTypesArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExpandResourceTypesArmClient() + { + } + + /// 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 MockableMgmtExpandResourceTypesArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtExpandResourceTypesArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 RecordSetAResource GetRecordSetAResource(ResourceIdentifier id) + { + RecordSetAResource.ValidateResourceId(id); + return new RecordSetAResource(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 RecordSetAaaaResource GetRecordSetAaaaResource(ResourceIdentifier id) + { + RecordSetAaaaResource.ValidateResourceId(id); + return new RecordSetAaaaResource(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 RecordSetCaaResource GetRecordSetCaaResource(ResourceIdentifier id) + { + RecordSetCaaResource.ValidateResourceId(id); + return new RecordSetCaaResource(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 RecordSetCNameResource GetRecordSetCNameResource(ResourceIdentifier id) + { + RecordSetCNameResource.ValidateResourceId(id); + return new RecordSetCNameResource(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 RecordSetMxResource GetRecordSetMxResource(ResourceIdentifier id) + { + RecordSetMxResource.ValidateResourceId(id); + return new RecordSetMxResource(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 RecordSetNsResource GetRecordSetNsResource(ResourceIdentifier id) + { + RecordSetNsResource.ValidateResourceId(id); + return new RecordSetNsResource(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 RecordSetPtrResource GetRecordSetPtrResource(ResourceIdentifier id) + { + RecordSetPtrResource.ValidateResourceId(id); + return new RecordSetPtrResource(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 RecordSetSoaResource GetRecordSetSoaResource(ResourceIdentifier id) + { + RecordSetSoaResource.ValidateResourceId(id); + return new RecordSetSoaResource(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 RecordSetSrvResource GetRecordSetSrvResource(ResourceIdentifier id) + { + RecordSetSrvResource.ValidateResourceId(id); + return new RecordSetSrvResource(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 RecordSetTxtResource GetRecordSetTxtResource(ResourceIdentifier id) + { + RecordSetTxtResource.ValidateResourceId(id); + return new RecordSetTxtResource(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 ZoneResource GetZoneResource(ResourceIdentifier id) + { + ZoneResource.ValidateResourceId(id); + return new ZoneResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesResourceGroupResource.cs b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesResourceGroupResource.cs new file mode 100644 index 00000000000..d2c301ddfe3 --- /dev/null +++ b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesResourceGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtExpandResourceTypes; + +namespace MgmtExpandResourceTypes.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtExpandResourceTypesResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExpandResourceTypesResourceGroupResource() + { + } + + /// 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 MockableMgmtExpandResourceTypesResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ZoneResources in the ResourceGroupResource. + /// An object representing collection of ZoneResources and their operations over a ZoneResource. + public virtual ZoneCollection GetZones() + { + return GetCachedClient(client => new ZoneCollection(client, Id)); + } + + /// + /// Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName} + /// + /// + /// Operation Id + /// Zones_Get + /// + /// + /// + /// The name of the DNS zone (without a terminating dot). + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetZoneAsync(string zoneName, CancellationToken cancellationToken = default) + { + return await GetZones().GetAsync(zoneName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName} + /// + /// + /// Operation Id + /// Zones_Get + /// + /// + /// + /// The name of the DNS zone (without a terminating dot). + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetZone(string zoneName, CancellationToken cancellationToken = default) + { + return GetZones().Get(zoneName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesSubscriptionResource.cs similarity index 85% rename from test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesSubscriptionResource.cs index 8f8301e8b0a..543cdc61ebe 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/MockableMgmtExpandResourceTypesSubscriptionResource.cs @@ -13,27 +13,28 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtExpandResourceTypes; using MgmtExpandResourceTypes.Models; -namespace MgmtExpandResourceTypes +namespace MgmtExpandResourceTypes.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtExpandResourceTypesSubscriptionResource : ArmResource { private ClientDiagnostics _zoneClientDiagnostics; private ZonesRestOperations _zoneRestClient; private ClientDiagnostics _dnsResourceReferenceClientDiagnostics; private DnsResourceReferenceRestOperations _dnsResourceReferenceRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExpandResourceTypesSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtExpandResourceTypesSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -68,7 +69,7 @@ public virtual AsyncPageable GetZonesByDnszoneAsync(int? top = nul { HttpMessage FirstPageRequest(int? pageSizeHint) => ZoneRestClient.CreateListRequest(Id.SubscriptionId, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ZoneRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, top); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ZoneResource(Client, ZoneData.DeserializeZoneData(e)), ZoneClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetZonesByDnszone", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ZoneResource(Client, ZoneData.DeserializeZoneData(e)), ZoneClientDiagnostics, Pipeline, "MockableMgmtExpandResourceTypesSubscriptionResource.GetZonesByDnszone", "value", "nextLink", cancellationToken); } /// @@ -91,7 +92,7 @@ public virtual Pageable GetZonesByDnszone(int? top = null, Cancell { HttpMessage FirstPageRequest(int? pageSizeHint) => ZoneRestClient.CreateListRequest(Id.SubscriptionId, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ZoneRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, top); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ZoneResource(Client, ZoneData.DeserializeZoneData(e)), ZoneClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetZonesByDnszone", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ZoneResource(Client, ZoneData.DeserializeZoneData(e)), ZoneClientDiagnostics, Pipeline, "MockableMgmtExpandResourceTypesSubscriptionResource.GetZonesByDnszone", "value", "nextLink", cancellationToken); } /// @@ -109,9 +110,12 @@ public virtual Pageable GetZonesByDnszone(int? top = null, Cancell /// /// Properties for dns resource reference request. /// The cancellation token to use. + /// is null. public virtual async Task> GetByTargetResourcesDnsResourceReferenceAsync(DnsResourceReferenceContent content, CancellationToken cancellationToken = default) { - using var scope = DnsResourceReferenceClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetByTargetResourcesDnsResourceReference"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = DnsResourceReferenceClientDiagnostics.CreateScope("MockableMgmtExpandResourceTypesSubscriptionResource.GetByTargetResourcesDnsResourceReference"); scope.Start(); try { @@ -140,9 +144,12 @@ public virtual async Task> GetByTargetResou /// /// Properties for dns resource reference request. /// The cancellation token to use. + /// is null. public virtual Response GetByTargetResourcesDnsResourceReference(DnsResourceReferenceContent content, CancellationToken cancellationToken = default) { - using var scope = DnsResourceReferenceClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetByTargetResourcesDnsResourceReference"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = DnsResourceReferenceClientDiagnostics.CreateScope("MockableMgmtExpandResourceTypesSubscriptionResource.GetByTargetResourcesDnsResourceReference"); scope.Start(); try { diff --git a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index a1cd03d6649..00000000000 --- a/test/TestProjects/MgmtExpandResourceTypes/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtExpandResourceTypes -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of ZoneResources in the ResourceGroupResource. - /// An object representing collection of ZoneResources and their operations over a ZoneResource. - public virtual ZoneCollection GetZones() - { - return GetCachedClient(Client => new ZoneCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtExpandResourceTypes/Generated/ZoneResource.cs b/test/TestProjects/MgmtExpandResourceTypes/Generated/ZoneResource.cs index 02ccd382585..3cc30255762 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/Generated/ZoneResource.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/Generated/ZoneResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of RecordSetAResources and their operations over a RecordSetAResource. public virtual RecordSetACollection GetRecordSetAs() { - return GetCachedClient(Client => new RecordSetACollection(Client, Id)); + return GetCachedClient(client => new RecordSetACollection(client, Id)); } /// @@ -152,7 +152,7 @@ public virtual Response GetRecordSetA(string relativeRecordS /// An object representing collection of RecordSetAaaaResources and their operations over a RecordSetAaaaResource. public virtual RecordSetAaaaCollection GetRecordSetAaaas() { - return GetCachedClient(Client => new RecordSetAaaaCollection(Client, Id)); + return GetCachedClient(client => new RecordSetAaaaCollection(client, Id)); } /// @@ -203,7 +203,7 @@ public virtual Response GetRecordSetAaaa(string relativeR /// An object representing collection of RecordSetCaaResources and their operations over a RecordSetCaaResource. public virtual RecordSetCaaCollection GetRecordSetCaas() { - return GetCachedClient(Client => new RecordSetCaaCollection(Client, Id)); + return GetCachedClient(client => new RecordSetCaaCollection(client, Id)); } /// @@ -254,7 +254,7 @@ public virtual Response GetRecordSetCaa(string relativeRec /// An object representing collection of RecordSetCNameResources and their operations over a RecordSetCNameResource. public virtual RecordSetCNameCollection GetRecordSetCNames() { - return GetCachedClient(Client => new RecordSetCNameCollection(Client, Id)); + return GetCachedClient(client => new RecordSetCNameCollection(client, Id)); } /// @@ -305,7 +305,7 @@ public virtual Response GetRecordSetCName(string relativ /// An object representing collection of RecordSetMxResources and their operations over a RecordSetMxResource. public virtual RecordSetMxCollection GetRecordSetMxes() { - return GetCachedClient(Client => new RecordSetMxCollection(Client, Id)); + return GetCachedClient(client => new RecordSetMxCollection(client, Id)); } /// @@ -356,7 +356,7 @@ public virtual Response GetRecordSetMx(string relativeRecor /// An object representing collection of RecordSetNsResources and their operations over a RecordSetNsResource. public virtual RecordSetNsCollection GetAllRecordSetNs() { - return GetCachedClient(Client => new RecordSetNsCollection(Client, Id)); + return GetCachedClient(client => new RecordSetNsCollection(client, Id)); } /// @@ -407,7 +407,7 @@ public virtual Response GetRecordSetNs(string relativeRecor /// An object representing collection of RecordSetPtrResources and their operations over a RecordSetPtrResource. public virtual RecordSetPtrCollection GetRecordSetPtrs() { - return GetCachedClient(Client => new RecordSetPtrCollection(Client, Id)); + return GetCachedClient(client => new RecordSetPtrCollection(client, Id)); } /// @@ -458,7 +458,7 @@ public virtual Response GetRecordSetPtr(string relativeRec /// An object representing collection of RecordSetSoaResources and their operations over a RecordSetSoaResource. public virtual RecordSetSoaCollection GetRecordSetSoas() { - return GetCachedClient(Client => new RecordSetSoaCollection(Client, Id)); + return GetCachedClient(client => new RecordSetSoaCollection(client, Id)); } /// @@ -509,7 +509,7 @@ public virtual Response GetRecordSetSoa(string relativeRec /// An object representing collection of RecordSetSrvResources and their operations over a RecordSetSrvResource. public virtual RecordSetSrvCollection GetRecordSetSrvs() { - return GetCachedClient(Client => new RecordSetSrvCollection(Client, Id)); + return GetCachedClient(client => new RecordSetSrvCollection(client, Id)); } /// @@ -560,7 +560,7 @@ public virtual Response GetRecordSetSrv(string relativeRec /// An object representing collection of RecordSetTxtResources and their operations over a RecordSetTxtResource. public virtual RecordSetTxtCollection GetRecordSetTxts() { - return GetCachedClient(Client => new RecordSetTxtCollection(Client, Id)); + return GetCachedClient(client => new RecordSetTxtCollection(client, Id)); } /// diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MgmtExtensionCommonRestOperationExtensions.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MgmtExtensionCommonRestOperationExtensions.cs index 6fda91710c5..4ff79c136ff 100644 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MgmtExtensionCommonRestOperationExtensions.cs +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MgmtExtensionCommonRestOperationExtensions.cs @@ -12,87 +12,72 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtExtensionCommonRestOperation.Mocking; namespace MgmtExtensionCommonRestOperation { /// A class to add extension methods to MgmtExtensionCommonRestOperation. public static partial class MgmtExtensionCommonRestOperationExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtExtensionCommonRestOperationArmClient GetMockableMgmtExtensionCommonRestOperationArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtExtensionCommonRestOperationArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtExtensionCommonRestOperationResourceGroupResource GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtExtensionCommonRestOperationResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtExtensionCommonRestOperationSubscriptionResource GetMockableMgmtExtensionCommonRestOperationSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtExtensionCommonRestOperationSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region TypeOneResource /// /// 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. /// Returns a object. public static TypeOneResource GetTypeOneResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TypeOneResource.ValidateResourceId(id); - return new TypeOneResource(client, id); - } - ); + return GetMockableMgmtExtensionCommonRestOperationArmClient(client).GetTypeOneResource(id); } - #endregion - #region TypeTwoResource /// /// 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. /// Returns a object. public static TypeTwoResource GetTypeTwoResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TypeTwoResource.ValidateResourceId(id); - return new TypeTwoResource(client, id); - } - ); + return GetMockableMgmtExtensionCommonRestOperationArmClient(client).GetTypeTwoResource(id); } - #endregion - /// Gets a collection of TypeOneResources in the ResourceGroupResource. + /// + /// Gets a collection of TypeOneResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TypeOneResources and their operations over a TypeOneResource. public static TypeOneCollection GetTypeOnes(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTypeOnes(); + return GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(resourceGroupResource).GetTypeOnes(); } /// @@ -107,16 +92,20 @@ public static TypeOneCollection GetTypeOnes(this ResourceGroupResource resourceG /// Common_GetTypeOne /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTypeOneAsync(this ResourceGroupResource resourceGroupResource, string typeOneName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetTypeOnes().GetAsync(typeOneName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(resourceGroupResource).GetTypeOneAsync(typeOneName, cancellationToken).ConfigureAwait(false); } /// @@ -131,24 +120,34 @@ public static async Task> GetTypeOneAsync(this Resourc /// Common_GetTypeOne /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTypeOne(this ResourceGroupResource resourceGroupResource, string typeOneName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetTypeOnes().Get(typeOneName, cancellationToken); + return GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(resourceGroupResource).GetTypeOne(typeOneName, cancellationToken); } - /// Gets a collection of TypeTwoResources in the ResourceGroupResource. + /// + /// Gets a collection of TypeTwoResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TypeTwoResources and their operations over a TypeTwoResource. public static TypeTwoCollection GetTypeTwos(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTypeTwos(); + return GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(resourceGroupResource).GetTypeTwos(); } /// @@ -163,16 +162,20 @@ public static TypeTwoCollection GetTypeTwos(this ResourceGroupResource resourceG /// Common_GetTypeTwo /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTypeTwoAsync(this ResourceGroupResource resourceGroupResource, string typeTwoName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetTypeTwos().GetAsync(typeTwoName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(resourceGroupResource).GetTypeTwoAsync(typeTwoName, cancellationToken).ConfigureAwait(false); } /// @@ -187,16 +190,20 @@ public static async Task> GetTypeTwoAsync(this Resourc /// Common_GetTypeTwo /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTypeTwo(this ResourceGroupResource resourceGroupResource, string typeTwoName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetTypeTwos().Get(typeTwoName, cancellationToken); + return GetMockableMgmtExtensionCommonRestOperationResourceGroupResource(resourceGroupResource).GetTypeTwo(typeTwoName, cancellationToken); } /// @@ -211,13 +218,17 @@ public static Response GetTypeTwo(this ResourceGroupResource re /// Common_ListTypeOnesBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTypeOnesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeOnesAsync(cancellationToken); + return GetMockableMgmtExtensionCommonRestOperationSubscriptionResource(subscriptionResource).GetTypeOnesAsync(cancellationToken); } /// @@ -232,13 +243,17 @@ public static AsyncPageable GetTypeOnesAsync(this SubscriptionR /// Common_ListTypeOnesBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTypeOnes(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeOnes(cancellationToken); + return GetMockableMgmtExtensionCommonRestOperationSubscriptionResource(subscriptionResource).GetTypeOnes(cancellationToken); } /// @@ -253,13 +268,17 @@ public static Pageable GetTypeOnes(this SubscriptionResource su /// Common_ListTypeTwosBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTypeTwosAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeTwosAsync(cancellationToken); + return GetMockableMgmtExtensionCommonRestOperationSubscriptionResource(subscriptionResource).GetTypeTwosAsync(cancellationToken); } /// @@ -274,13 +293,17 @@ public static AsyncPageable GetTypeTwosAsync(this SubscriptionR /// Common_ListTypeTwosBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTypeTwos(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeTwos(cancellationToken); + return GetMockableMgmtExtensionCommonRestOperationSubscriptionResource(subscriptionResource).GetTypeTwos(cancellationToken); } } } diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationArmClient.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationArmClient.cs new file mode 100644 index 00000000000..905a0649fc1 --- /dev/null +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtExtensionCommonRestOperation; + +namespace MgmtExtensionCommonRestOperation.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtExtensionCommonRestOperationArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionCommonRestOperationArmClient() + { + } + + /// 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 MockableMgmtExtensionCommonRestOperationArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtExtensionCommonRestOperationArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 TypeOneResource GetTypeOneResource(ResourceIdentifier id) + { + TypeOneResource.ValidateResourceId(id); + return new TypeOneResource(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 TypeTwoResource GetTypeTwoResource(ResourceIdentifier id) + { + TypeTwoResource.ValidateResourceId(id); + return new TypeTwoResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationResourceGroupResource.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationResourceGroupResource.cs new file mode 100644 index 00000000000..13421e596fe --- /dev/null +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationResourceGroupResource.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtExtensionCommonRestOperation; + +namespace MgmtExtensionCommonRestOperation.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtExtensionCommonRestOperationResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionCommonRestOperationResourceGroupResource() + { + } + + /// 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 MockableMgmtExtensionCommonRestOperationResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of TypeOneResources in the ResourceGroupResource. + /// An object representing collection of TypeOneResources and their operations over a TypeOneResource. + public virtual TypeOneCollection GetTypeOnes() + { + return GetCachedClient(client => new TypeOneCollection(client, Id)); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeOne/typeOnes/{typeOneName} + /// + /// + /// Operation Id + /// Common_GetTypeOne + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTypeOneAsync(string typeOneName, CancellationToken cancellationToken = default) + { + return await GetTypeOnes().GetAsync(typeOneName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeOne/typeOnes/{typeOneName} + /// + /// + /// Operation Id + /// Common_GetTypeOne + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTypeOne(string typeOneName, CancellationToken cancellationToken = default) + { + return GetTypeOnes().Get(typeOneName, cancellationToken); + } + + /// Gets a collection of TypeTwoResources in the ResourceGroupResource. + /// An object representing collection of TypeTwoResources and their operations over a TypeTwoResource. + public virtual TypeTwoCollection GetTypeTwos() + { + return GetCachedClient(client => new TypeTwoCollection(client, Id)); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeTwo/typeTwos/{typeTwoName} + /// + /// + /// Operation Id + /// Common_GetTypeTwo + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTypeTwoAsync(string typeTwoName, CancellationToken cancellationToken = default) + { + return await GetTypeTwos().GetAsync(typeTwoName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeTwo/typeTwos/{typeTwoName} + /// + /// + /// Operation Id + /// Common_GetTypeTwo + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTypeTwo(string typeTwoName, CancellationToken cancellationToken = default) + { + return GetTypeTwos().Get(typeTwoName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationSubscriptionResource.cs similarity index 86% rename from test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationSubscriptionResource.cs index 84b8ae25057..8ee225cb300 100644 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/MockableMgmtExtensionCommonRestOperationSubscriptionResource.cs @@ -11,26 +11,27 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtExtensionCommonRestOperation; -namespace MgmtExtensionCommonRestOperation +namespace MgmtExtensionCommonRestOperation.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtExtensionCommonRestOperationSubscriptionResource : ArmResource { private ClientDiagnostics _typeOneCommonClientDiagnostics; private CommonRestOperations _typeOneCommonRestClient; private ClientDiagnostics _typeTwoCommonClientDiagnostics; private CommonRestOperations _typeTwoCommonRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionCommonRestOperationSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtExtensionCommonRestOperationSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -63,7 +64,7 @@ private string GetApiVersionOrNull(ResourceType resourceType) public virtual AsyncPageable GetTypeOnesAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeOneCommonRestClient.CreateListTypeOnesBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeOnes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "MockableMgmtExtensionCommonRestOperationSubscriptionResource.GetTypeOnes", "value", null, cancellationToken); } /// @@ -84,7 +85,7 @@ public virtual AsyncPageable GetTypeOnesAsync(CancellationToken public virtual Pageable GetTypeOnes(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeOneCommonRestClient.CreateListTypeOnesBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeOnes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "MockableMgmtExtensionCommonRestOperationSubscriptionResource.GetTypeOnes", "value", null, cancellationToken); } /// @@ -105,7 +106,7 @@ public virtual Pageable GetTypeOnes(CancellationToken cancellat public virtual AsyncPageable GetTypeTwosAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeTwoCommonRestClient.CreateListTypeTwosBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeTwos", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "MockableMgmtExtensionCommonRestOperationSubscriptionResource.GetTypeTwos", "value", null, cancellationToken); } /// @@ -126,7 +127,7 @@ public virtual AsyncPageable GetTypeTwosAsync(CancellationToken public virtual Pageable GetTypeTwos(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeTwoCommonRestClient.CreateListTypeTwosBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeTwos", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "MockableMgmtExtensionCommonRestOperationSubscriptionResource.GetTypeTwos", "value", null, cancellationToken); } } } diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index e52759a1c39..00000000000 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtExtensionCommonRestOperation -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of TypeOneResources in the ResourceGroupResource. - /// An object representing collection of TypeOneResources and their operations over a TypeOneResource. - public virtual TypeOneCollection GetTypeOnes() - { - return GetCachedClient(Client => new TypeOneCollection(Client, Id)); - } - - /// Gets a collection of TypeTwoResources in the ResourceGroupResource. - /// An object representing collection of TypeTwoResources and their operations over a TypeTwoResource. - public virtual TypeTwoCollection GetTypeTwos() - { - return GetCachedClient(Client => new TypeTwoCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/ManagementGroupResourceExtensionClient.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/ManagementGroupResourceExtensionClient.cs deleted file mode 100644 index 5e5f0f1aa44..00000000000 --- a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/ManagementGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtExtensionResource -{ - /// A class to add extension methods to ManagementGroupResource. - internal partial class ManagementGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ManagementGroupResourceExtensionClient() - { - } - - /// 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 ManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of ManagementGroupPolicyDefinitionResources in the ManagementGroupResource. - /// An object representing collection of ManagementGroupPolicyDefinitionResources and their operations over a ManagementGroupPolicyDefinitionResource. - public virtual ManagementGroupPolicyDefinitionCollection GetManagementGroupPolicyDefinitions() - { - return GetCachedClient(Client => new ManagementGroupPolicyDefinitionCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MgmtExtensionResourceExtensions.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MgmtExtensionResourceExtensions.cs index fe6e2514999..3e10fe59595 100644 --- a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MgmtExtensionResourceExtensions.cs +++ b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MgmtExtensionResourceExtensions.cs @@ -13,6 +13,7 @@ using Azure.ResourceManager; using Azure.ResourceManager.ManagementGroups; using Azure.ResourceManager.Resources; +using MgmtExtensionResource.Mocking; using MgmtExtensionResource.Models; namespace MgmtExtensionResource @@ -20,135 +21,102 @@ namespace MgmtExtensionResource /// A class to add extension methods to MgmtExtensionResource. public static partial class MgmtExtensionResourceExtensions { - private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtExtensionResourceArmClient GetMockableMgmtExtensionResourceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ManagementGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtExtensionResourceArmClient(client0)); } - private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtExtensionResourceManagementGroupResource GetMockableMgmtExtensionResourceManagementGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ManagementGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtExtensionResourceManagementGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtExtensionResourceSubscriptionResource GetMockableMgmtExtensionResourceSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtExtensionResourceSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtExtensionResourceTenantResource GetMockableMgmtExtensionResourceTenantResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtExtensionResourceTenantResource(client, resource.Id)); } - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmResource resource) - { - return resource.GetCachedClient(client => - { - return new TenantResourceExtensionClient(client, resource.Id); - }); - } - - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new TenantResourceExtensionClient(client, scope); - }); - } - #region SubSingletonResource /// /// 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. /// Returns a object. public static SubSingletonResource GetSubSingletonResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubSingletonResource.ValidateResourceId(id); - return new SubSingletonResource(client, id); - } - ); + return GetMockableMgmtExtensionResourceArmClient(client).GetSubSingletonResource(id); } - #endregion - #region SubscriptionPolicyDefinitionResource /// /// 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. /// Returns a object. public static SubscriptionPolicyDefinitionResource GetSubscriptionPolicyDefinitionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubscriptionPolicyDefinitionResource.ValidateResourceId(id); - return new SubscriptionPolicyDefinitionResource(client, id); - } - ); + return GetMockableMgmtExtensionResourceArmClient(client).GetSubscriptionPolicyDefinitionResource(id); } - #endregion - #region BuiltInPolicyDefinitionResource /// /// 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. /// Returns a object. public static BuiltInPolicyDefinitionResource GetBuiltInPolicyDefinitionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BuiltInPolicyDefinitionResource.ValidateResourceId(id); - return new BuiltInPolicyDefinitionResource(client, id); - } - ); + return GetMockableMgmtExtensionResourceArmClient(client).GetBuiltInPolicyDefinitionResource(id); } - #endregion - #region ManagementGroupPolicyDefinitionResource /// /// 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. /// Returns a object. public static ManagementGroupPolicyDefinitionResource GetManagementGroupPolicyDefinitionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ManagementGroupPolicyDefinitionResource.ValidateResourceId(id); - return new ManagementGroupPolicyDefinitionResource(client, id); - } - ); + return GetMockableMgmtExtensionResourceArmClient(client).GetManagementGroupPolicyDefinitionResource(id); } - #endregion - /// Gets a collection of ManagementGroupPolicyDefinitionResources in the ManagementGroupResource. + /// + /// Gets a collection of ManagementGroupPolicyDefinitionResources in the ManagementGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ManagementGroupPolicyDefinitionResources and their operations over a ManagementGroupPolicyDefinitionResource. public static ManagementGroupPolicyDefinitionCollection GetManagementGroupPolicyDefinitions(this ManagementGroupResource managementGroupResource) { - return GetManagementGroupResourceExtensionClient(managementGroupResource).GetManagementGroupPolicyDefinitions(); + return GetMockableMgmtExtensionResourceManagementGroupResource(managementGroupResource).GetManagementGroupPolicyDefinitions(); } /// @@ -163,16 +131,20 @@ public static ManagementGroupPolicyDefinitionCollection GetManagementGroupPolicy /// PolicyDefinitions_GetAtManagementGroup /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the policy definition to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetManagementGroupPolicyDefinitionAsync(this ManagementGroupResource managementGroupResource, string policyDefinitionName, CancellationToken cancellationToken = default) { - return await GetManagementGroupPolicyDefinitions(managementGroupResource).GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionResourceManagementGroupResource(managementGroupResource).GetManagementGroupPolicyDefinitionAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); } /// @@ -187,32 +159,48 @@ public static async Task> GetM /// PolicyDefinitions_GetAtManagementGroup /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the policy definition to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetManagementGroupPolicyDefinition(this ManagementGroupResource managementGroupResource, string policyDefinitionName, CancellationToken cancellationToken = default) { - return GetManagementGroupPolicyDefinitions(managementGroupResource).Get(policyDefinitionName, cancellationToken); + return GetMockableMgmtExtensionResourceManagementGroupResource(managementGroupResource).GetManagementGroupPolicyDefinition(policyDefinitionName, cancellationToken); } - /// Gets an object representing a SubSingletonResource along with the instance operations that can be performed on it in the SubscriptionResource. + /// + /// Gets an object representing a SubSingletonResource along with the instance operations that can be performed on it in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// Returns a object. public static SubSingletonResource GetSubSingleton(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSubSingleton(); + return GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).GetSubSingleton(); } - /// Gets a collection of SubscriptionPolicyDefinitionResources in the SubscriptionResource. + /// + /// Gets a collection of SubscriptionPolicyDefinitionResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SubscriptionPolicyDefinitionResources and their operations over a SubscriptionPolicyDefinitionResource. public static SubscriptionPolicyDefinitionCollection GetSubscriptionPolicyDefinitions(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSubscriptionPolicyDefinitions(); + return GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).GetSubscriptionPolicyDefinitions(); } /// @@ -227,16 +215,20 @@ public static SubscriptionPolicyDefinitionCollection GetSubscriptionPolicyDefini /// PolicyDefinitions_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the policy definition to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSubscriptionPolicyDefinitionAsync(this SubscriptionResource subscriptionResource, string policyDefinitionName, CancellationToken cancellationToken = default) { - return await GetSubscriptionPolicyDefinitions(subscriptionResource).GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).GetSubscriptionPolicyDefinitionAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); } /// @@ -251,16 +243,20 @@ public static async Task> GetSubs /// PolicyDefinitions_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the policy definition to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSubscriptionPolicyDefinition(this SubscriptionResource subscriptionResource, string policyDefinitionName, CancellationToken cancellationToken = default) { - return GetSubscriptionPolicyDefinitions(subscriptionResource).Get(policyDefinitionName, cancellationToken); + return GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).GetSubscriptionPolicyDefinition(policyDefinitionName, cancellationToken); } /// @@ -275,6 +271,10 @@ public static Response GetSubscriptionPoli /// CheckDnsNameAvailability /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the domain name. @@ -284,10 +284,7 @@ public static Response GetSubscriptionPoli /// or is null. public static async Task> CheckDnsNameAvailabilityAsync(this SubscriptionResource subscriptionResource, string location, string domainNameLabel, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - Argument.AssertNotNull(domainNameLabel, nameof(domainNameLabel)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).CheckDnsNameAvailabilityAsync(location, domainNameLabel, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).CheckDnsNameAvailabilityAsync(location, domainNameLabel, cancellationToken).ConfigureAwait(false); } /// @@ -302,6 +299,10 @@ public static async Task> CheckDnsNameAvaila /// CheckDnsNameAvailability /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the domain name. @@ -311,10 +312,7 @@ public static async Task> CheckDnsNameAvaila /// or is null. public static Response CheckDnsNameAvailability(this SubscriptionResource subscriptionResource, string location, string domainNameLabel, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - Argument.AssertNotNull(domainNameLabel, nameof(domainNameLabel)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).CheckDnsNameAvailability(location, domainNameLabel, cancellationToken); + return GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).CheckDnsNameAvailability(location, domainNameLabel, cancellationToken); } /// @@ -329,6 +327,10 @@ public static Response CheckDnsNameAvailability(this /// OrphanedPost_ValidateSomething /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Information to validate. @@ -336,9 +338,7 @@ public static Response CheckDnsNameAvailability(this /// is null. public static async Task ValidateSomethingOrphanedPostAsync(this SubscriptionResource subscriptionResource, ValidateSomethingContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).ValidateSomethingOrphanedPostAsync(content, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).ValidateSomethingOrphanedPostAsync(content, cancellationToken).ConfigureAwait(false); } /// @@ -353,6 +353,10 @@ public static async Task ValidateSomethingOrphanedPostAsync(this Subsc /// OrphanedPost_ValidateSomething /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Information to validate. @@ -360,17 +364,21 @@ public static async Task ValidateSomethingOrphanedPostAsync(this Subsc /// is null. public static Response ValidateSomethingOrphanedPost(this SubscriptionResource subscriptionResource, ValidateSomethingContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).ValidateSomethingOrphanedPost(content, cancellationToken); + return GetMockableMgmtExtensionResourceSubscriptionResource(subscriptionResource).ValidateSomethingOrphanedPost(content, cancellationToken); } - /// Gets a collection of BuiltInPolicyDefinitionResources in the TenantResource. + /// + /// Gets a collection of BuiltInPolicyDefinitionResources in the TenantResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of BuiltInPolicyDefinitionResources and their operations over a BuiltInPolicyDefinitionResource. public static BuiltInPolicyDefinitionCollection GetBuiltInPolicyDefinitions(this TenantResource tenantResource) { - return GetTenantResourceExtensionClient(tenantResource).GetBuiltInPolicyDefinitions(); + return GetMockableMgmtExtensionResourceTenantResource(tenantResource).GetBuiltInPolicyDefinitions(); } /// @@ -385,16 +393,20 @@ public static BuiltInPolicyDefinitionCollection GetBuiltInPolicyDefinitions(this /// PolicyDefinitions_GetBuiltIn /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the built-in policy definition to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetBuiltInPolicyDefinitionAsync(this TenantResource tenantResource, string policyDefinitionName, CancellationToken cancellationToken = default) { - return await tenantResource.GetBuiltInPolicyDefinitions().GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtExtensionResourceTenantResource(tenantResource).GetBuiltInPolicyDefinitionAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); } /// @@ -409,16 +421,20 @@ public static async Task> GetBuiltInPo /// PolicyDefinitions_GetBuiltIn /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the built-in policy definition to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetBuiltInPolicyDefinition(this TenantResource tenantResource, string policyDefinitionName, CancellationToken cancellationToken = default) { - return tenantResource.GetBuiltInPolicyDefinitions().Get(policyDefinitionName, cancellationToken); + return GetMockableMgmtExtensionResourceTenantResource(tenantResource).GetBuiltInPolicyDefinition(policyDefinitionName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceArmClient.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceArmClient.cs new file mode 100644 index 00000000000..714e1bac983 --- /dev/null +++ b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceArmClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtExtensionResource; + +namespace MgmtExtensionResource.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtExtensionResourceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionResourceArmClient() + { + } + + /// 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 MockableMgmtExtensionResourceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtExtensionResourceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 SubSingletonResource GetSubSingletonResource(ResourceIdentifier id) + { + SubSingletonResource.ValidateResourceId(id); + return new SubSingletonResource(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 SubscriptionPolicyDefinitionResource GetSubscriptionPolicyDefinitionResource(ResourceIdentifier id) + { + SubscriptionPolicyDefinitionResource.ValidateResourceId(id); + return new SubscriptionPolicyDefinitionResource(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 BuiltInPolicyDefinitionResource GetBuiltInPolicyDefinitionResource(ResourceIdentifier id) + { + BuiltInPolicyDefinitionResource.ValidateResourceId(id); + return new BuiltInPolicyDefinitionResource(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 ManagementGroupPolicyDefinitionResource GetManagementGroupPolicyDefinitionResource(ResourceIdentifier id) + { + ManagementGroupPolicyDefinitionResource.ValidateResourceId(id); + return new ManagementGroupPolicyDefinitionResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceManagementGroupResource.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceManagementGroupResource.cs new file mode 100644 index 00000000000..20fbeee59d0 --- /dev/null +++ b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceManagementGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtExtensionResource; + +namespace MgmtExtensionResource.Mocking +{ + /// A class to add extension methods to ManagementGroupResource. + public partial class MockableMgmtExtensionResourceManagementGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionResourceManagementGroupResource() + { + } + + /// 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 MockableMgmtExtensionResourceManagementGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ManagementGroupPolicyDefinitionResources in the ManagementGroupResource. + /// An object representing collection of ManagementGroupPolicyDefinitionResources and their operations over a ManagementGroupPolicyDefinitionResource. + public virtual ManagementGroupPolicyDefinitionCollection GetManagementGroupPolicyDefinitions() + { + return GetCachedClient(client => new ManagementGroupPolicyDefinitionCollection(client, Id)); + } + + /// + /// This operation retrieves the policy definition in the given management group with the given name. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} + /// + /// + /// Operation Id + /// PolicyDefinitions_GetAtManagementGroup + /// + /// + /// + /// The name of the policy definition to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetManagementGroupPolicyDefinitionAsync(string policyDefinitionName, CancellationToken cancellationToken = default) + { + return await GetManagementGroupPolicyDefinitions().GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// This operation retrieves the policy definition in the given management group with the given name. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} + /// + /// + /// Operation Id + /// PolicyDefinitions_GetAtManagementGroup + /// + /// + /// + /// The name of the policy definition to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetManagementGroupPolicyDefinition(string policyDefinitionName, CancellationToken cancellationToken = default) + { + return GetManagementGroupPolicyDefinitions().Get(policyDefinitionName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceSubscriptionResource.cs similarity index 63% rename from test/TestProjects/MgmtExtensionResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceSubscriptionResource.cs index 1eea2f2efca..d6c8f25520d 100644 --- a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceSubscriptionResource.cs @@ -12,27 +12,28 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtExtensionResource; using MgmtExtensionResource.Models; -namespace MgmtExtensionResource +namespace MgmtExtensionResource.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtExtensionResourceSubscriptionResource : ArmResource { private ClientDiagnostics _defaultClientDiagnostics; private PolicyRestOperations _defaultRestClient; private ClientDiagnostics _orphanedPostClientDiagnostics; private OrphanedPostRestOperations _orphanedPostRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionResourceSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtExtensionResourceSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -58,7 +59,53 @@ public virtual SubSingletonResource GetSubSingleton() /// An object representing collection of SubscriptionPolicyDefinitionResources and their operations over a SubscriptionPolicyDefinitionResource. public virtual SubscriptionPolicyDefinitionCollection GetSubscriptionPolicyDefinitions() { - return GetCachedClient(Client => new SubscriptionPolicyDefinitionCollection(Client, Id)); + return GetCachedClient(client => new SubscriptionPolicyDefinitionCollection(client, Id)); + } + + /// + /// This operation retrieves the policy definition in the given subscription with the given name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} + /// + /// + /// Operation Id + /// PolicyDefinitions_Get + /// + /// + /// + /// The name of the policy definition to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSubscriptionPolicyDefinitionAsync(string policyDefinitionName, CancellationToken cancellationToken = default) + { + return await GetSubscriptionPolicyDefinitions().GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// This operation retrieves the policy definition in the given subscription with the given name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} + /// + /// + /// Operation Id + /// PolicyDefinitions_Get + /// + /// + /// + /// The name of the policy definition to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSubscriptionPolicyDefinition(string policyDefinitionName, CancellationToken cancellationToken = default) + { + return GetSubscriptionPolicyDefinitions().Get(policyDefinitionName, cancellationToken); } /// @@ -77,9 +124,14 @@ public virtual SubscriptionPolicyDefinitionCollection GetSubscriptionPolicyDefin /// The location of the domain name. /// The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> CheckDnsNameAvailabilityAsync(string location, string domainNameLabel, CancellationToken cancellationToken = default) { - using var scope = DefaultClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.CheckDnsNameAvailability"); + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNull(domainNameLabel, nameof(domainNameLabel)); + + using var scope = DefaultClientDiagnostics.CreateScope("MockableMgmtExtensionResourceSubscriptionResource.CheckDnsNameAvailability"); scope.Start(); try { @@ -109,9 +161,14 @@ public virtual async Task> CheckDnsNameAvail /// The location of the domain name. /// The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response CheckDnsNameAvailability(string location, string domainNameLabel, CancellationToken cancellationToken = default) { - using var scope = DefaultClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.CheckDnsNameAvailability"); + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNull(domainNameLabel, nameof(domainNameLabel)); + + using var scope = DefaultClientDiagnostics.CreateScope("MockableMgmtExtensionResourceSubscriptionResource.CheckDnsNameAvailability"); scope.Start(); try { @@ -140,9 +197,12 @@ public virtual Response CheckDnsNameAvailability(stri /// /// Information to validate. /// The cancellation token to use. + /// is null. public virtual async Task ValidateSomethingOrphanedPostAsync(ValidateSomethingContent content, CancellationToken cancellationToken = default) { - using var scope = OrphanedPostClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ValidateSomethingOrphanedPost"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = OrphanedPostClientDiagnostics.CreateScope("MockableMgmtExtensionResourceSubscriptionResource.ValidateSomethingOrphanedPost"); scope.Start(); try { @@ -171,9 +231,12 @@ public virtual async Task ValidateSomethingOrphanedPostAsync(ValidateS /// /// Information to validate. /// The cancellation token to use. + /// is null. public virtual Response ValidateSomethingOrphanedPost(ValidateSomethingContent content, CancellationToken cancellationToken = default) { - using var scope = OrphanedPostClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.ValidateSomethingOrphanedPost"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = OrphanedPostClientDiagnostics.CreateScope("MockableMgmtExtensionResourceSubscriptionResource.ValidateSomethingOrphanedPost"); scope.Start(); try { diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceTenantResource.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceTenantResource.cs new file mode 100644 index 00000000000..387261a9081 --- /dev/null +++ b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/MockableMgmtExtensionResourceTenantResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtExtensionResource; + +namespace MgmtExtensionResource.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableMgmtExtensionResourceTenantResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtExtensionResourceTenantResource() + { + } + + /// 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 MockableMgmtExtensionResourceTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of BuiltInPolicyDefinitionResources in the TenantResource. + /// An object representing collection of BuiltInPolicyDefinitionResources and their operations over a BuiltInPolicyDefinitionResource. + public virtual BuiltInPolicyDefinitionCollection GetBuiltInPolicyDefinitions() + { + return GetCachedClient(client => new BuiltInPolicyDefinitionCollection(client, Id)); + } + + /// + /// This operation retrieves the built-in policy definition with the given name. + /// + /// + /// Request Path + /// /providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} + /// + /// + /// Operation Id + /// PolicyDefinitions_GetBuiltIn + /// + /// + /// + /// The name of the built-in policy definition to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBuiltInPolicyDefinitionAsync(string policyDefinitionName, CancellationToken cancellationToken = default) + { + return await GetBuiltInPolicyDefinitions().GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// This operation retrieves the built-in policy definition with the given name. + /// + /// + /// Request Path + /// /providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName} + /// + /// + /// Operation Id + /// PolicyDefinitions_GetBuiltIn + /// + /// + /// + /// The name of the built-in policy definition to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBuiltInPolicyDefinition(string policyDefinitionName, CancellationToken cancellationToken = default) + { + return GetBuiltInPolicyDefinitions().Get(policyDefinitionName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/TenantResourceExtensionClient.cs b/test/TestProjects/MgmtExtensionResource/Generated/Extensions/TenantResourceExtensionClient.cs deleted file mode 100644 index 6f5f5453331..00000000000 --- a/test/TestProjects/MgmtExtensionResource/Generated/Extensions/TenantResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtExtensionResource -{ - /// A class to add extension methods to TenantResource. - internal partial class TenantResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected TenantResourceExtensionClient() - { - } - - /// 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 TenantResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of BuiltInPolicyDefinitionResources in the TenantResource. - /// An object representing collection of BuiltInPolicyDefinitionResources and their operations over a BuiltInPolicyDefinitionResource. - public virtual BuiltInPolicyDefinitionCollection GetBuiltInPolicyDefinitions() - { - return GetCachedClient(Client => new BuiltInPolicyDefinitionCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MgmtHierarchicalNonResourceExtensions.cs b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MgmtHierarchicalNonResourceExtensions.cs index d8b27116704..8da5f3d02a3 100644 --- a/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MgmtHierarchicalNonResourceExtensions.cs +++ b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MgmtHierarchicalNonResourceExtensions.cs @@ -12,57 +12,54 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtHierarchicalNonResource.Mocking; namespace MgmtHierarchicalNonResource { /// A class to add extension methods to MgmtHierarchicalNonResource. public static partial class MgmtHierarchicalNonResourceExtensions { - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtHierarchicalNonResourceArmClient GetMockableMgmtHierarchicalNonResourceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtHierarchicalNonResourceArmClient(client0)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtHierarchicalNonResourceSubscriptionResource GetMockableMgmtHierarchicalNonResourceSubscriptionResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtHierarchicalNonResourceSubscriptionResource(client, resource.Id)); } - #region SharedGalleryResource + /// /// 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. /// Returns a object. public static SharedGalleryResource GetSharedGalleryResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SharedGalleryResource.ValidateResourceId(id); - return new SharedGalleryResource(client, id); - } - ); + return GetMockableMgmtHierarchicalNonResourceArmClient(client).GetSharedGalleryResource(id); } - #endregion - /// Gets a collection of SharedGalleryResources in the SubscriptionResource. + /// + /// Gets a collection of SharedGalleryResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// Resource location. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of SharedGalleryResources and their operations over a SharedGalleryResource. public static SharedGalleryCollection GetSharedGalleries(this SubscriptionResource subscriptionResource, string location) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSharedGalleries(location); + return GetMockableMgmtHierarchicalNonResourceSubscriptionResource(subscriptionResource).GetSharedGalleries(location); } /// @@ -77,17 +74,21 @@ public static SharedGalleryCollection GetSharedGalleries(this SubscriptionResour /// SharedGalleries_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Resource location. /// The unique name of the Shared Gallery. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. /// or is null. + /// or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSharedGalleryAsync(this SubscriptionResource subscriptionResource, string location, string galleryUniqueName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetSharedGalleries(location).GetAsync(galleryUniqueName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtHierarchicalNonResourceSubscriptionResource(subscriptionResource).GetSharedGalleryAsync(location, galleryUniqueName, cancellationToken).ConfigureAwait(false); } /// @@ -102,17 +103,21 @@ public static async Task> GetSharedGalleryAsync( /// SharedGalleries_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Resource location. /// The unique name of the Shared Gallery. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. /// or is null. + /// or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSharedGallery(this SubscriptionResource subscriptionResource, string location, string galleryUniqueName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetSharedGalleries(location).Get(galleryUniqueName, cancellationToken); + return GetMockableMgmtHierarchicalNonResourceSubscriptionResource(subscriptionResource).GetSharedGallery(location, galleryUniqueName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MockableMgmtHierarchicalNonResourceArmClient.cs b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MockableMgmtHierarchicalNonResourceArmClient.cs new file mode 100644 index 00000000000..5367a20aa78 --- /dev/null +++ b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MockableMgmtHierarchicalNonResourceArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtHierarchicalNonResource; + +namespace MgmtHierarchicalNonResource.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtHierarchicalNonResourceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtHierarchicalNonResourceArmClient() + { + } + + /// 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 MockableMgmtHierarchicalNonResourceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtHierarchicalNonResourceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 SharedGalleryResource GetSharedGalleryResource(ResourceIdentifier id) + { + SharedGalleryResource.ValidateResourceId(id); + return new SharedGalleryResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MockableMgmtHierarchicalNonResourceSubscriptionResource.cs b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MockableMgmtHierarchicalNonResourceSubscriptionResource.cs new file mode 100644 index 00000000000..13cdf5bf1cd --- /dev/null +++ b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/MockableMgmtHierarchicalNonResourceSubscriptionResource.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtHierarchicalNonResource; + +namespace MgmtHierarchicalNonResource.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableMgmtHierarchicalNonResourceSubscriptionResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtHierarchicalNonResourceSubscriptionResource() + { + } + + /// 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 MockableMgmtHierarchicalNonResourceSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of SharedGalleryResources in the SubscriptionResource. + /// Resource location. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// An object representing collection of SharedGalleryResources and their operations over a SharedGalleryResource. + public virtual SharedGalleryCollection GetSharedGalleries(string location) + { + return new SharedGalleryCollection(Client, Id, location); + } + + /// + /// Get a shared gallery by subscription id or tenant id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName} + /// + /// + /// Operation Id + /// SharedGalleries_Get + /// + /// + /// + /// Resource location. + /// The unique name of the Shared Gallery. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSharedGalleryAsync(string location, string galleryUniqueName, CancellationToken cancellationToken = default) + { + return await GetSharedGalleries(location).GetAsync(galleryUniqueName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a shared gallery by subscription id or tenant id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName} + /// + /// + /// Operation Id + /// SharedGalleries_Get + /// + /// + /// + /// Resource location. + /// The unique name of the Shared Gallery. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSharedGallery(string location, string galleryUniqueName, CancellationToken cancellationToken = default) + { + return GetSharedGalleries(location).Get(galleryUniqueName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs deleted file mode 100644 index 3cb3e0e1bd1..00000000000 --- a/test/TestProjects/MgmtHierarchicalNonResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtHierarchicalNonResource -{ - /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() - { - } - - /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of SharedGalleryResources in the SubscriptionResource. - /// Resource location. - /// An object representing collection of SharedGalleryResources and their operations over a SharedGalleryResource. - public virtual SharedGalleryCollection GetSharedGalleries(string location) - { - return new SharedGalleryCollection(Client, Id, location); - } - } -} diff --git a/test/TestProjects/MgmtLRO/Generated/Extensions/MgmtLROExtensions.cs b/test/TestProjects/MgmtLRO/Generated/Extensions/MgmtLROExtensions.cs index 9e374bc3db0..9967ad86643 100644 --- a/test/TestProjects/MgmtLRO/Generated/Extensions/MgmtLROExtensions.cs +++ b/test/TestProjects/MgmtLRO/Generated/Extensions/MgmtLROExtensions.cs @@ -12,71 +12,67 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtLRO.Mocking; namespace MgmtLRO { /// A class to add extension methods to MgmtLRO. public static partial class MgmtLROExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtLROArmClient GetMockableMgmtLROArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtLROArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtLROResourceGroupResource GetMockableMgmtLROResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtLROResourceGroupResource(client, resource.Id)); } - #region FakeResource + /// /// 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. /// Returns a object. public static FakeResource GetFakeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeResource.ValidateResourceId(id); - return new FakeResource(client, id); - } - ); + return GetMockableMgmtLROArmClient(client).GetFakeResource(id); } - #endregion - #region BarResource /// /// 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. /// Returns a object. public static BarResource GetBarResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BarResource.ValidateResourceId(id); - return new BarResource(client, id); - } - ); + return GetMockableMgmtLROArmClient(client).GetBarResource(id); } - #endregion - /// Gets a collection of FakeResources in the ResourceGroupResource. + /// + /// Gets a collection of FakeResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of FakeResources and their operations over a FakeResource. public static FakeCollection GetFakes(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetFakes(); + return GetMockableMgmtLROResourceGroupResource(resourceGroupResource).GetFakes(); } /// @@ -91,17 +87,21 @@ public static FakeCollection GetFakes(this ResourceGroupResource resourceGroupRe /// Fakes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetFakeAsync(this ResourceGroupResource resourceGroupResource, string fakeName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetFakes().GetAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtLROResourceGroupResource(resourceGroupResource).GetFakeAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -116,25 +116,35 @@ public static async Task> GetFakeAsync(this ResourceGroup /// Fakes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetFake(this ResourceGroupResource resourceGroupResource, string fakeName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetFakes().Get(fakeName, expand, cancellationToken); + return GetMockableMgmtLROResourceGroupResource(resourceGroupResource).GetFake(fakeName, expand, cancellationToken); } - /// Gets a collection of BarResources in the ResourceGroupResource. + /// + /// Gets a collection of BarResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of BarResources and their operations over a BarResource. public static BarCollection GetBars(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetBars(); + return GetMockableMgmtLROResourceGroupResource(resourceGroupResource).GetBars(); } /// @@ -149,16 +159,20 @@ public static BarCollection GetBars(this ResourceGroupResource resourceGroupReso /// Bars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetBarAsync(this ResourceGroupResource resourceGroupResource, string barName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetBars().GetAsync(barName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtLROResourceGroupResource(resourceGroupResource).GetBarAsync(barName, cancellationToken).ConfigureAwait(false); } /// @@ -173,16 +187,20 @@ public static async Task> GetBarAsync(this ResourceGroupRe /// Bars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetBar(this ResourceGroupResource resourceGroupResource, string barName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetBars().Get(barName, cancellationToken); + return GetMockableMgmtLROResourceGroupResource(resourceGroupResource).GetBar(barName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtLRO/Generated/Extensions/MockableMgmtLROArmClient.cs b/test/TestProjects/MgmtLRO/Generated/Extensions/MockableMgmtLROArmClient.cs new file mode 100644 index 00000000000..8bd1ed71d35 --- /dev/null +++ b/test/TestProjects/MgmtLRO/Generated/Extensions/MockableMgmtLROArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtLRO; + +namespace MgmtLRO.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtLROArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtLROArmClient() + { + } + + /// 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 MockableMgmtLROArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtLROArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 FakeResource GetFakeResource(ResourceIdentifier id) + { + FakeResource.ValidateResourceId(id); + return new FakeResource(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 BarResource GetBarResource(ResourceIdentifier id) + { + BarResource.ValidateResourceId(id); + return new BarResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtLRO/Generated/Extensions/MockableMgmtLROResourceGroupResource.cs b/test/TestProjects/MgmtLRO/Generated/Extensions/MockableMgmtLROResourceGroupResource.cs new file mode 100644 index 00000000000..7ccd86ca0ea --- /dev/null +++ b/test/TestProjects/MgmtLRO/Generated/Extensions/MockableMgmtLROResourceGroupResource.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtLRO; + +namespace MgmtLRO.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtLROResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtLROResourceGroupResource() + { + } + + /// 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 MockableMgmtLROResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of FakeResources in the ResourceGroupResource. + /// An object representing collection of FakeResources and their operations over a FakeResource. + public virtual FakeCollection GetFakes() + { + return GetCachedClient(client => new FakeCollection(client, Id)); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/fakes/{fakeName} + /// + /// + /// Operation Id + /// Fakes_Get + /// + /// + /// + /// The name of the fake. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetFakeAsync(string fakeName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetFakes().GetAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/fakes/{fakeName} + /// + /// + /// Operation Id + /// Fakes_Get + /// + /// + /// + /// The name of the fake. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetFake(string fakeName, string expand = null, CancellationToken cancellationToken = default) + { + return GetFakes().Get(fakeName, expand, cancellationToken); + } + + /// Gets a collection of BarResources in the ResourceGroupResource. + /// An object representing collection of BarResources and their operations over a BarResource. + public virtual BarCollection GetBars() + { + return GetCachedClient(client => new BarCollection(client, Id)); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName} + /// + /// + /// Operation Id + /// Bars_Get + /// + /// + /// + /// The name of the fake. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetBarAsync(string barName, CancellationToken cancellationToken = default) + { + return await GetBars().GetAsync(barName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName} + /// + /// + /// Operation Id + /// Bars_Get + /// + /// + /// + /// The name of the fake. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetBar(string barName, CancellationToken cancellationToken = default) + { + return GetBars().Get(barName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtLRO/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtLRO/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index f9d6f402eeb..00000000000 --- a/test/TestProjects/MgmtLRO/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtLRO -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of FakeResources in the ResourceGroupResource. - /// An object representing collection of FakeResources and their operations over a FakeResource. - public virtual FakeCollection GetFakes() - { - return GetCachedClient(Client => new FakeCollection(Client, Id)); - } - - /// Gets a collection of BarResources in the ResourceGroupResource. - /// An object representing collection of BarResources and their operations over a BarResource. - public virtual BarCollection GetBars() - { - return GetCachedClient(Client => new BarCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/ManagementGroupResourceExtensionClient.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/ManagementGroupResourceExtensionClient.cs deleted file mode 100644 index 02ac9275ca7..00000000000 --- a/test/TestProjects/MgmtListMethods/Generated/Extensions/ManagementGroupResourceExtensionClient.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtListMethods -{ - /// A class to add extension methods to ManagementGroupResource. - internal partial class ManagementGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ManagementGroupResourceExtensionClient() - { - } - - /// 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 ManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of MgmtGrpParentWithNonResChWithLocResources in the ManagementGroupResource. - /// An object representing collection of MgmtGrpParentWithNonResChWithLocResources and their operations over a MgmtGrpParentWithNonResChWithLocResource. - public virtual MgmtGrpParentWithNonResChWithLocCollection GetMgmtGrpParentWithNonResChWithLocs() - { - return GetCachedClient(Client => new MgmtGrpParentWithNonResChWithLocCollection(Client, Id)); - } - - /// Gets a collection of MgmtGrpParentWithNonResChResources in the ManagementGroupResource. - /// An object representing collection of MgmtGrpParentWithNonResChResources and their operations over a MgmtGrpParentWithNonResChResource. - public virtual MgmtGrpParentWithNonResChCollection GetMgmtGrpParentWithNonResChes() - { - return GetCachedClient(Client => new MgmtGrpParentWithNonResChCollection(Client, Id)); - } - - /// Gets a collection of MgmtGrpParentWithLocResources in the ManagementGroupResource. - /// An object representing collection of MgmtGrpParentWithLocResources and their operations over a MgmtGrpParentWithLocResource. - public virtual MgmtGrpParentWithLocCollection GetMgmtGrpParentWithLocs() - { - return GetCachedClient(Client => new MgmtGrpParentWithLocCollection(Client, Id)); - } - - /// Gets a collection of MgmtGroupParentResources in the ManagementGroupResource. - /// An object representing collection of MgmtGroupParentResources and their operations over a MgmtGroupParentResource. - public virtual MgmtGroupParentCollection GetMgmtGroupParents() - { - return GetCachedClient(Client => new MgmtGroupParentCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/MgmtListMethodsExtensions.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/MgmtListMethodsExtensions.cs index 8003950b533..9ab5ab07aea 100644 --- a/test/TestProjects/MgmtListMethods/Generated/Extensions/MgmtListMethodsExtensions.cs +++ b/test/TestProjects/MgmtListMethods/Generated/Extensions/MgmtListMethodsExtensions.cs @@ -13,6 +13,7 @@ using Azure.ResourceManager; using Azure.ResourceManager.ManagementGroups; using Azure.ResourceManager.Resources; +using MgmtListMethods.Mocking; using MgmtListMethods.Models; namespace MgmtListMethods @@ -20,588 +21,475 @@ namespace MgmtListMethods /// A class to add extension methods to MgmtListMethods. public static partial class MgmtListMethodsExtensions { - private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtListMethodsArmClient GetMockableMgmtListMethodsArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ManagementGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtListMethodsArmClient(client0)); } - private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtListMethodsManagementGroupResource GetMockableMgmtListMethodsManagementGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ManagementGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtListMethodsManagementGroupResource(client, resource.Id)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtListMethodsResourceGroupResource GetMockableMgmtListMethodsResourceGroupResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtListMethodsResourceGroupResource(client, resource.Id)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtListMethodsSubscriptionResource GetMockableMgmtListMethodsSubscriptionResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtListMethodsSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtListMethodsTenantResource GetMockableMgmtListMethodsTenantResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtListMethodsTenantResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmResource resource) - { - return resource.GetCachedClient(client => - { - return new TenantResourceExtensionClient(client, resource.Id); - }); - } - - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new TenantResourceExtensionClient(client, scope); - }); - } - #region FakeResource /// /// 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. /// Returns a object. public static FakeResource GetFakeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeResource.ValidateResourceId(id); - return new FakeResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeResource(id); } - #endregion - #region FakeParentWithAncestorWithNonResChWithLocResource /// /// 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. /// Returns a object. public static FakeParentWithAncestorWithNonResChWithLocResource GetFakeParentWithAncestorWithNonResChWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeParentWithAncestorWithNonResChWithLocResource.ValidateResourceId(id); - return new FakeParentWithAncestorWithNonResChWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeParentWithAncestorWithNonResChWithLocResource(id); } - #endregion - #region FakeParentWithAncestorWithNonResChResource /// /// 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. /// Returns a object. public static FakeParentWithAncestorWithNonResChResource GetFakeParentWithAncestorWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeParentWithAncestorWithNonResChResource.ValidateResourceId(id); - return new FakeParentWithAncestorWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeParentWithAncestorWithNonResChResource(id); } - #endregion - #region FakeParentWithAncestorWithLocResource /// /// 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. /// Returns a object. public static FakeParentWithAncestorWithLocResource GetFakeParentWithAncestorWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeParentWithAncestorWithLocResource.ValidateResourceId(id); - return new FakeParentWithAncestorWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeParentWithAncestorWithLocResource(id); } - #endregion - #region FakeParentWithAncestorResource /// /// 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. /// Returns a object. public static FakeParentWithAncestorResource GetFakeParentWithAncestorResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeParentWithAncestorResource.ValidateResourceId(id); - return new FakeParentWithAncestorResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeParentWithAncestorResource(id); } - #endregion - #region FakeParentWithNonResChResource /// /// 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. /// Returns a object. public static FakeParentWithNonResChResource GetFakeParentWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeParentWithNonResChResource.ValidateResourceId(id); - return new FakeParentWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeParentWithNonResChResource(id); } - #endregion - #region FakeParentResource /// /// 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. /// Returns a object. public static FakeParentResource GetFakeParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeParentResource.ValidateResourceId(id); - return new FakeParentResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeParentResource(id); } - #endregion - #region ResGrpParentWithAncestorWithNonResChWithLocResource /// /// 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. /// Returns a object. public static ResGrpParentWithAncestorWithNonResChWithLocResource GetResGrpParentWithAncestorWithNonResChWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResGrpParentWithAncestorWithNonResChWithLocResource.ValidateResourceId(id); - return new ResGrpParentWithAncestorWithNonResChWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetResGrpParentWithAncestorWithNonResChWithLocResource(id); } - #endregion - #region ResGrpParentWithAncestorWithNonResChResource /// /// 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. /// Returns a object. public static ResGrpParentWithAncestorWithNonResChResource GetResGrpParentWithAncestorWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResGrpParentWithAncestorWithNonResChResource.ValidateResourceId(id); - return new ResGrpParentWithAncestorWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetResGrpParentWithAncestorWithNonResChResource(id); } - #endregion - #region ResGrpParentWithAncestorWithLocResource /// /// 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. /// Returns a object. public static ResGrpParentWithAncestorWithLocResource GetResGrpParentWithAncestorWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResGrpParentWithAncestorWithLocResource.ValidateResourceId(id); - return new ResGrpParentWithAncestorWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetResGrpParentWithAncestorWithLocResource(id); } - #endregion - #region ResGrpParentWithAncestorResource /// /// 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. /// Returns a object. public static ResGrpParentWithAncestorResource GetResGrpParentWithAncestorResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResGrpParentWithAncestorResource.ValidateResourceId(id); - return new ResGrpParentWithAncestorResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetResGrpParentWithAncestorResource(id); } - #endregion - #region ResGrpParentWithNonResChResource /// /// 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. /// Returns a object. public static ResGrpParentWithNonResChResource GetResGrpParentWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResGrpParentWithNonResChResource.ValidateResourceId(id); - return new ResGrpParentWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetResGrpParentWithNonResChResource(id); } - #endregion - #region ResGrpParentResource /// /// 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. /// Returns a object. public static ResGrpParentResource GetResGrpParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResGrpParentResource.ValidateResourceId(id); - return new ResGrpParentResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetResGrpParentResource(id); } - #endregion - #region SubParentWithNonResChWithLocResource /// /// 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. /// Returns a object. public static SubParentWithNonResChWithLocResource GetSubParentWithNonResChWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubParentWithNonResChWithLocResource.ValidateResourceId(id); - return new SubParentWithNonResChWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetSubParentWithNonResChWithLocResource(id); } - #endregion - #region SubParentWithNonResChResource /// /// 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. /// Returns a object. public static SubParentWithNonResChResource GetSubParentWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubParentWithNonResChResource.ValidateResourceId(id); - return new SubParentWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetSubParentWithNonResChResource(id); } - #endregion - #region SubParentWithLocResource /// /// 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. /// Returns a object. public static SubParentWithLocResource GetSubParentWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubParentWithLocResource.ValidateResourceId(id); - return new SubParentWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetSubParentWithLocResource(id); } - #endregion - #region SubParentResource /// /// 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. /// Returns a object. public static SubParentResource GetSubParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubParentResource.ValidateResourceId(id); - return new SubParentResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetSubParentResource(id); } - #endregion - #region MgmtGrpParentWithNonResChWithLocResource /// /// 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. /// Returns a object. public static MgmtGrpParentWithNonResChWithLocResource GetMgmtGrpParentWithNonResChWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MgmtGrpParentWithNonResChWithLocResource.ValidateResourceId(id); - return new MgmtGrpParentWithNonResChWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetMgmtGrpParentWithNonResChWithLocResource(id); } - #endregion - #region MgmtGrpParentWithNonResChResource /// /// 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. /// Returns a object. public static MgmtGrpParentWithNonResChResource GetMgmtGrpParentWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MgmtGrpParentWithNonResChResource.ValidateResourceId(id); - return new MgmtGrpParentWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetMgmtGrpParentWithNonResChResource(id); } - #endregion - #region MgmtGrpParentWithLocResource /// /// 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. /// Returns a object. public static MgmtGrpParentWithLocResource GetMgmtGrpParentWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MgmtGrpParentWithLocResource.ValidateResourceId(id); - return new MgmtGrpParentWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetMgmtGrpParentWithLocResource(id); } - #endregion - #region MgmtGroupParentResource /// /// 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. /// Returns a object. public static MgmtGroupParentResource GetMgmtGroupParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MgmtGroupParentResource.ValidateResourceId(id); - return new MgmtGroupParentResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetMgmtGroupParentResource(id); } - #endregion - #region TenantTestResource /// /// 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. /// Returns a object. public static TenantTestResource GetTenantTestResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TenantTestResource.ValidateResourceId(id); - return new TenantTestResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetTenantTestResource(id); } - #endregion - #region TenantParentWithNonResChWithLocResource /// /// 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. /// Returns a object. public static TenantParentWithNonResChWithLocResource GetTenantParentWithNonResChWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TenantParentWithNonResChWithLocResource.ValidateResourceId(id); - return new TenantParentWithNonResChWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetTenantParentWithNonResChWithLocResource(id); } - #endregion - #region TenantParentWithNonResChResource /// /// 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. /// Returns a object. public static TenantParentWithNonResChResource GetTenantParentWithNonResChResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TenantParentWithNonResChResource.ValidateResourceId(id); - return new TenantParentWithNonResChResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetTenantParentWithNonResChResource(id); } - #endregion - #region TenantParentWithLocResource /// /// 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. /// Returns a object. public static TenantParentWithLocResource GetTenantParentWithLocResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TenantParentWithLocResource.ValidateResourceId(id); - return new TenantParentWithLocResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetTenantParentWithLocResource(id); } - #endregion - #region TenantParentResource /// /// 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. /// Returns a object. public static TenantParentResource GetTenantParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TenantParentResource.ValidateResourceId(id); - return new TenantParentResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetTenantParentResource(id); } - #endregion - #region FakeConfigurationResource /// /// 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. /// Returns a object. public static FakeConfigurationResource GetFakeConfigurationResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeConfigurationResource.ValidateResourceId(id); - return new FakeConfigurationResource(client, id); - } - ); + return GetMockableMgmtListMethodsArmClient(client).GetFakeConfigurationResource(id); } - #endregion - /// Gets a collection of MgmtGrpParentWithNonResChWithLocResources in the ManagementGroupResource. + /// + /// Gets a collection of MgmtGrpParentWithNonResChWithLocResources in the ManagementGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of MgmtGrpParentWithNonResChWithLocResources and their operations over a MgmtGrpParentWithNonResChWithLocResource. public static MgmtGrpParentWithNonResChWithLocCollection GetMgmtGrpParentWithNonResChWithLocs(this ManagementGroupResource managementGroupResource) { - return GetManagementGroupResourceExtensionClient(managementGroupResource).GetMgmtGrpParentWithNonResChWithLocs(); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithNonResChWithLocs(); } /// @@ -616,16 +504,20 @@ public static MgmtGrpParentWithNonResChWithLocCollection GetMgmtGrpParentWithNon /// MgmtGrpParentWithNonResChWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetMgmtGrpParentWithNonResChWithLocAsync(this ManagementGroupResource managementGroupResource, string mgmtGrpParentWithNonResChWithLocName, CancellationToken cancellationToken = default) { - return await managementGroupResource.GetMgmtGrpParentWithNonResChWithLocs().GetAsync(mgmtGrpParentWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithNonResChWithLocAsync(mgmtGrpParentWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); } /// @@ -640,24 +532,34 @@ public static async Task> Get /// MgmtGrpParentWithNonResChWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetMgmtGrpParentWithNonResChWithLoc(this ManagementGroupResource managementGroupResource, string mgmtGrpParentWithNonResChWithLocName, CancellationToken cancellationToken = default) { - return managementGroupResource.GetMgmtGrpParentWithNonResChWithLocs().Get(mgmtGrpParentWithNonResChWithLocName, cancellationToken); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithNonResChWithLoc(mgmtGrpParentWithNonResChWithLocName, cancellationToken); } - /// Gets a collection of MgmtGrpParentWithNonResChResources in the ManagementGroupResource. + /// + /// Gets a collection of MgmtGrpParentWithNonResChResources in the ManagementGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of MgmtGrpParentWithNonResChResources and their operations over a MgmtGrpParentWithNonResChResource. public static MgmtGrpParentWithNonResChCollection GetMgmtGrpParentWithNonResChes(this ManagementGroupResource managementGroupResource) { - return GetManagementGroupResourceExtensionClient(managementGroupResource).GetMgmtGrpParentWithNonResChes(); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithNonResChes(); } /// @@ -672,16 +574,20 @@ public static MgmtGrpParentWithNonResChCollection GetMgmtGrpParentWithNonResChes /// MgmtGrpParentWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetMgmtGrpParentWithNonResChAsync(this ManagementGroupResource managementGroupResource, string mgmtGrpParentWithNonResChName, CancellationToken cancellationToken = default) { - return await managementGroupResource.GetMgmtGrpParentWithNonResChes().GetAsync(mgmtGrpParentWithNonResChName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithNonResChAsync(mgmtGrpParentWithNonResChName, cancellationToken).ConfigureAwait(false); } /// @@ -696,24 +602,34 @@ public static async Task> GetMgmtGrp /// MgmtGrpParentWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetMgmtGrpParentWithNonResCh(this ManagementGroupResource managementGroupResource, string mgmtGrpParentWithNonResChName, CancellationToken cancellationToken = default) { - return managementGroupResource.GetMgmtGrpParentWithNonResChes().Get(mgmtGrpParentWithNonResChName, cancellationToken); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithNonResCh(mgmtGrpParentWithNonResChName, cancellationToken); } - /// Gets a collection of MgmtGrpParentWithLocResources in the ManagementGroupResource. + /// + /// Gets a collection of MgmtGrpParentWithLocResources in the ManagementGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of MgmtGrpParentWithLocResources and their operations over a MgmtGrpParentWithLocResource. public static MgmtGrpParentWithLocCollection GetMgmtGrpParentWithLocs(this ManagementGroupResource managementGroupResource) { - return GetManagementGroupResourceExtensionClient(managementGroupResource).GetMgmtGrpParentWithLocs(); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithLocs(); } /// @@ -728,16 +644,20 @@ public static MgmtGrpParentWithLocCollection GetMgmtGrpParentWithLocs(this Manag /// MgmtGrpParentWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetMgmtGrpParentWithLocAsync(this ManagementGroupResource managementGroupResource, string mgmtGrpParentWithLocName, CancellationToken cancellationToken = default) { - return await managementGroupResource.GetMgmtGrpParentWithLocs().GetAsync(mgmtGrpParentWithLocName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithLocAsync(mgmtGrpParentWithLocName, cancellationToken).ConfigureAwait(false); } /// @@ -752,24 +672,34 @@ public static async Task> GetMgmtGrpParen /// MgmtGrpParentWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetMgmtGrpParentWithLoc(this ManagementGroupResource managementGroupResource, string mgmtGrpParentWithLocName, CancellationToken cancellationToken = default) { - return managementGroupResource.GetMgmtGrpParentWithLocs().Get(mgmtGrpParentWithLocName, cancellationToken); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGrpParentWithLoc(mgmtGrpParentWithLocName, cancellationToken); } - /// Gets a collection of MgmtGroupParentResources in the ManagementGroupResource. + /// + /// Gets a collection of MgmtGroupParentResources in the ManagementGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of MgmtGroupParentResources and their operations over a MgmtGroupParentResource. public static MgmtGroupParentCollection GetMgmtGroupParents(this ManagementGroupResource managementGroupResource) { - return GetManagementGroupResourceExtensionClient(managementGroupResource).GetMgmtGroupParents(); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGroupParents(); } /// @@ -784,16 +714,20 @@ public static MgmtGroupParentCollection GetMgmtGroupParents(this ManagementGroup /// MgmtGroupParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetMgmtGroupParentAsync(this ManagementGroupResource managementGroupResource, string mgmtGroupParentName, CancellationToken cancellationToken = default) { - return await managementGroupResource.GetMgmtGroupParents().GetAsync(mgmtGroupParentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGroupParentAsync(mgmtGroupParentName, cancellationToken).ConfigureAwait(false); } /// @@ -808,24 +742,34 @@ public static async Task> GetMgmtGroupParentAs /// MgmtGroupParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetMgmtGroupParent(this ManagementGroupResource managementGroupResource, string mgmtGroupParentName, CancellationToken cancellationToken = default) { - return managementGroupResource.GetMgmtGroupParents().Get(mgmtGroupParentName, cancellationToken); + return GetMockableMgmtListMethodsManagementGroupResource(managementGroupResource).GetMgmtGroupParent(mgmtGroupParentName, cancellationToken); } - /// Gets a collection of ResGrpParentWithAncestorWithNonResChWithLocResources in the ResourceGroupResource. + /// + /// Gets a collection of ResGrpParentWithAncestorWithNonResChWithLocResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResGrpParentWithAncestorWithNonResChWithLocResources and their operations over a ResGrpParentWithAncestorWithNonResChWithLocResource. public static ResGrpParentWithAncestorWithNonResChWithLocCollection GetResGrpParentWithAncestorWithNonResChWithLocs(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChWithLocs(); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChWithLocs(); } /// @@ -840,16 +784,20 @@ public static ResGrpParentWithAncestorWithNonResChWithLocCollection GetResGrpPar /// ResGrpParentWithAncestorWithNonResChWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResGrpParentWithAncestorWithNonResChWithLocAsync(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorWithNonResChWithLocName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResGrpParentWithAncestorWithNonResChWithLocs().GetAsync(resGrpParentWithAncestorWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChWithLocAsync(resGrpParentWithAncestorWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); } /// @@ -864,24 +812,34 @@ public static async TaskResGrpParentWithAncestorWithNonResChWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResGrpParentWithAncestorWithNonResChWithLoc(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorWithNonResChWithLocName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResGrpParentWithAncestorWithNonResChWithLocs().Get(resGrpParentWithAncestorWithNonResChWithLocName, cancellationToken); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChWithLoc(resGrpParentWithAncestorWithNonResChWithLocName, cancellationToken); } - /// Gets a collection of ResGrpParentWithAncestorWithNonResChResources in the ResourceGroupResource. + /// + /// Gets a collection of ResGrpParentWithAncestorWithNonResChResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResGrpParentWithAncestorWithNonResChResources and their operations over a ResGrpParentWithAncestorWithNonResChResource. public static ResGrpParentWithAncestorWithNonResChCollection GetResGrpParentWithAncestorWithNonResChes(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChes(); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChes(); } /// @@ -896,16 +854,20 @@ public static ResGrpParentWithAncestorWithNonResChCollection GetResGrpParentWith /// ResGrpParentWithAncestorWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResGrpParentWithAncestorWithNonResChAsync(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorWithNonResChName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResGrpParentWithAncestorWithNonResChes().GetAsync(resGrpParentWithAncestorWithNonResChName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithNonResChAsync(resGrpParentWithAncestorWithNonResChName, cancellationToken).ConfigureAwait(false); } /// @@ -920,24 +882,34 @@ public static async Task> /// ResGrpParentWithAncestorWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResGrpParentWithAncestorWithNonResCh(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorWithNonResChName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResGrpParentWithAncestorWithNonResChes().Get(resGrpParentWithAncestorWithNonResChName, cancellationToken); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithNonResCh(resGrpParentWithAncestorWithNonResChName, cancellationToken); } - /// Gets a collection of ResGrpParentWithAncestorWithLocResources in the ResourceGroupResource. + /// + /// Gets a collection of ResGrpParentWithAncestorWithLocResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResGrpParentWithAncestorWithLocResources and their operations over a ResGrpParentWithAncestorWithLocResource. public static ResGrpParentWithAncestorWithLocCollection GetResGrpParentWithAncestorWithLocs(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResGrpParentWithAncestorWithLocs(); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithLocs(); } /// @@ -952,16 +924,20 @@ public static ResGrpParentWithAncestorWithLocCollection GetResGrpParentWithAnces /// ResGrpParentWithAncestorWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResGrpParentWithAncestorWithLocAsync(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorWithLocName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResGrpParentWithAncestorWithLocs().GetAsync(resGrpParentWithAncestorWithLocName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithLocAsync(resGrpParentWithAncestorWithLocName, cancellationToken).ConfigureAwait(false); } /// @@ -976,24 +952,34 @@ public static async Task> GetR /// ResGrpParentWithAncestorWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResGrpParentWithAncestorWithLoc(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorWithLocName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResGrpParentWithAncestorWithLocs().Get(resGrpParentWithAncestorWithLocName, cancellationToken); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorWithLoc(resGrpParentWithAncestorWithLocName, cancellationToken); } - /// Gets a collection of ResGrpParentWithAncestorResources in the ResourceGroupResource. + /// + /// Gets a collection of ResGrpParentWithAncestorResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResGrpParentWithAncestorResources and their operations over a ResGrpParentWithAncestorResource. public static ResGrpParentWithAncestorCollection GetResGrpParentWithAncestors(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResGrpParentWithAncestors(); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestors(); } /// @@ -1008,16 +994,20 @@ public static ResGrpParentWithAncestorCollection GetResGrpParentWithAncestors(th /// ResGrpParentWithAncestors_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResGrpParentWithAncestorAsync(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResGrpParentWithAncestors().GetAsync(resGrpParentWithAncestorName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestorAsync(resGrpParentWithAncestorName, cancellationToken).ConfigureAwait(false); } /// @@ -1032,24 +1022,34 @@ public static async Task> GetResGrpPa /// ResGrpParentWithAncestors_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResGrpParentWithAncestor(this ResourceGroupResource resourceGroupResource, string resGrpParentWithAncestorName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResGrpParentWithAncestors().Get(resGrpParentWithAncestorName, cancellationToken); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithAncestor(resGrpParentWithAncestorName, cancellationToken); } - /// Gets a collection of ResGrpParentWithNonResChResources in the ResourceGroupResource. + /// + /// Gets a collection of ResGrpParentWithNonResChResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResGrpParentWithNonResChResources and their operations over a ResGrpParentWithNonResChResource. public static ResGrpParentWithNonResChCollection GetResGrpParentWithNonResChes(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResGrpParentWithNonResChes(); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithNonResChes(); } /// @@ -1064,16 +1064,20 @@ public static ResGrpParentWithNonResChCollection GetResGrpParentWithNonResChes(t /// ResGrpParentWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResGrpParentWithNonResChAsync(this ResourceGroupResource resourceGroupResource, string resGrpParentWithNonResChName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResGrpParentWithNonResChes().GetAsync(resGrpParentWithNonResChName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithNonResChAsync(resGrpParentWithNonResChName, cancellationToken).ConfigureAwait(false); } /// @@ -1088,24 +1092,34 @@ public static async Task> GetResGrpPa /// ResGrpParentWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResGrpParentWithNonResCh(this ResourceGroupResource resourceGroupResource, string resGrpParentWithNonResChName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResGrpParentWithNonResChes().Get(resGrpParentWithNonResChName, cancellationToken); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentWithNonResCh(resGrpParentWithNonResChName, cancellationToken); } - /// Gets a collection of ResGrpParentResources in the ResourceGroupResource. + /// + /// Gets a collection of ResGrpParentResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResGrpParentResources and their operations over a ResGrpParentResource. public static ResGrpParentCollection GetResGrpParents(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResGrpParents(); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParents(); } /// @@ -1120,16 +1134,20 @@ public static ResGrpParentCollection GetResGrpParents(this ResourceGroupResource /// ResGrpParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResGrpParentAsync(this ResourceGroupResource resourceGroupResource, string resGrpParentName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResGrpParents().GetAsync(resGrpParentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParentAsync(resGrpParentName, cancellationToken).ConfigureAwait(false); } /// @@ -1144,24 +1162,34 @@ public static async Task> GetResGrpParentAsync(th /// ResGrpParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResGrpParent(this ResourceGroupResource resourceGroupResource, string resGrpParentName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResGrpParents().Get(resGrpParentName, cancellationToken); + return GetMockableMgmtListMethodsResourceGroupResource(resourceGroupResource).GetResGrpParent(resGrpParentName, cancellationToken); } - /// Gets a collection of FakeResources in the SubscriptionResource. + /// + /// Gets a collection of FakeResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of FakeResources and their operations over a FakeResource. public static FakeCollection GetFakes(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakes(); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakes(); } /// @@ -1176,17 +1204,21 @@ public static FakeCollection GetFakes(this SubscriptionResource subscriptionReso /// Fakes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetFakeAsync(this SubscriptionResource subscriptionResource, string fakeName, string expand = null, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetFakes().GetAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -1201,25 +1233,35 @@ public static async Task> GetFakeAsync(this SubscriptionR /// Fakes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetFake(this SubscriptionResource subscriptionResource, string fakeName, string expand = null, CancellationToken cancellationToken = default) { - return subscriptionResource.GetFakes().Get(fakeName, expand, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFake(fakeName, expand, cancellationToken); } - /// Gets a collection of SubParentWithNonResChWithLocResources in the SubscriptionResource. + /// + /// Gets a collection of SubParentWithNonResChWithLocResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SubParentWithNonResChWithLocResources and their operations over a SubParentWithNonResChWithLocResource. public static SubParentWithNonResChWithLocCollection GetSubParentWithNonResChWithLocs(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSubParentWithNonResChWithLocs(); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithNonResChWithLocs(); } /// @@ -1234,16 +1276,20 @@ public static SubParentWithNonResChWithLocCollection GetSubParentWithNonResChWit /// SubParentWithNonResChWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSubParentWithNonResChWithLocAsync(this SubscriptionResource subscriptionResource, string subParentWithNonResChWithLocName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetSubParentWithNonResChWithLocs().GetAsync(subParentWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithNonResChWithLocAsync(subParentWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); } /// @@ -1258,24 +1304,34 @@ public static async Task> GetSubP /// SubParentWithNonResChWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSubParentWithNonResChWithLoc(this SubscriptionResource subscriptionResource, string subParentWithNonResChWithLocName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetSubParentWithNonResChWithLocs().Get(subParentWithNonResChWithLocName, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithNonResChWithLoc(subParentWithNonResChWithLocName, cancellationToken); } - /// Gets a collection of SubParentWithNonResChResources in the SubscriptionResource. + /// + /// Gets a collection of SubParentWithNonResChResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SubParentWithNonResChResources and their operations over a SubParentWithNonResChResource. public static SubParentWithNonResChCollection GetSubParentWithNonResChes(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSubParentWithNonResChes(); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithNonResChes(); } /// @@ -1290,16 +1346,20 @@ public static SubParentWithNonResChCollection GetSubParentWithNonResChes(this Su /// SubParentWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSubParentWithNonResChAsync(this SubscriptionResource subscriptionResource, string subParentWithNonResChName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetSubParentWithNonResChes().GetAsync(subParentWithNonResChName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithNonResChAsync(subParentWithNonResChName, cancellationToken).ConfigureAwait(false); } /// @@ -1314,24 +1374,34 @@ public static async Task> GetSubParentWi /// SubParentWithNonResChes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSubParentWithNonResCh(this SubscriptionResource subscriptionResource, string subParentWithNonResChName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetSubParentWithNonResChes().Get(subParentWithNonResChName, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithNonResCh(subParentWithNonResChName, cancellationToken); } - /// Gets a collection of SubParentWithLocResources in the SubscriptionResource. + /// + /// Gets a collection of SubParentWithLocResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SubParentWithLocResources and their operations over a SubParentWithLocResource. public static SubParentWithLocCollection GetSubParentWithLocs(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSubParentWithLocs(); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithLocs(); } /// @@ -1346,16 +1416,20 @@ public static SubParentWithLocCollection GetSubParentWithLocs(this SubscriptionR /// SubParentWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSubParentWithLocAsync(this SubscriptionResource subscriptionResource, string subParentWithLocName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetSubParentWithLocs().GetAsync(subParentWithLocName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithLocAsync(subParentWithLocName, cancellationToken).ConfigureAwait(false); } /// @@ -1370,24 +1444,34 @@ public static async Task> GetSubParentWithLoc /// SubParentWithLocs_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSubParentWithLoc(this SubscriptionResource subscriptionResource, string subParentWithLocName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetSubParentWithLocs().Get(subParentWithLocName, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentWithLoc(subParentWithLocName, cancellationToken); } - /// Gets a collection of SubParentResources in the SubscriptionResource. + /// + /// Gets a collection of SubParentResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SubParentResources and their operations over a SubParentResource. public static SubParentCollection GetSubParents(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetSubParents(); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParents(); } /// @@ -1402,16 +1486,20 @@ public static SubParentCollection GetSubParents(this SubscriptionResource subscr /// SubParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSubParentAsync(this SubscriptionResource subscriptionResource, string subParentName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetSubParents().GetAsync(subParentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParentAsync(subParentName, cancellationToken).ConfigureAwait(false); } /// @@ -1426,16 +1514,20 @@ public static async Task> GetSubParentAsync(this Sub /// SubParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSubParent(this SubscriptionResource subscriptionResource, string subParentName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetSubParents().Get(subParentName, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetSubParent(subParentName, cancellationToken); } /// @@ -1450,13 +1542,17 @@ public static Response GetSubParent(this SubscriptionResource /// FakeParentWithAncestorWithNonResChWithLocs_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFakeParentWithAncestorWithNonResourceChWithLocAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithNonResourceChWithLocAsync(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithNonResourceChWithLocAsync(cancellationToken); } /// @@ -1471,13 +1567,17 @@ public static AsyncPageable G /// FakeParentWithAncestorWithNonResChWithLocs_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFakeParentWithAncestorWithNonResourceChWithLoc(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithNonResourceChWithLoc(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithNonResourceChWithLoc(cancellationToken); } /// @@ -1492,6 +1592,10 @@ public static Pageable GetFak /// FakeParentWithAncestorWithNonResChWithLocs_ListTestByLocations /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1501,9 +1605,7 @@ public static Pageable GetFak /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocsAsync(this SubscriptionResource subscriptionResource, string location, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocsAsync(location, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocsAsync(location, cancellationToken); } /// @@ -1518,6 +1620,10 @@ public static AsyncPageable GetTestByLocationsFakeParentWithAn /// FakeParentWithAncestorWithNonResChWithLocs_ListTestByLocations /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1527,9 +1633,7 @@ public static AsyncPageable GetTestByLocationsFakeParentWithAn /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs(this SubscriptionResource subscriptionResource, string location, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs(location, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs(location, cancellationToken); } /// @@ -1544,13 +1648,17 @@ public static Pageable GetTestByLocationsFakeParentWithAncesto /// FakeParentWithAncestorWithNonResChes_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFakeParentWithAncestorWithNonResChesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithNonResChesAsync(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithNonResChesAsync(cancellationToken); } /// @@ -1565,13 +1673,17 @@ public static AsyncPageable GetFakeP /// FakeParentWithAncestorWithNonResChes_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFakeParentWithAncestorWithNonResChes(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithNonResChes(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithNonResChes(cancellationToken); } /// @@ -1586,13 +1698,17 @@ public static Pageable GetFakeParent /// FakeParentWithAncestorWithLocs_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFakeParentWithAncestorWithLocsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithLocsAsync(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithLocsAsync(cancellationToken); } /// @@ -1607,13 +1723,17 @@ public static AsyncPageable GetFakeParent /// FakeParentWithAncestorWithLocs_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFakeParentWithAncestorWithLocs(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithLocs(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithLocs(cancellationToken); } /// @@ -1628,6 +1748,10 @@ public static Pageable GetFakeParentWithA /// FakeParentWithAncestorWithLocs_ListTestByLocations /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1637,9 +1761,7 @@ public static Pageable GetFakeParentWithA /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFakeParentWithAncestorWithLocsByLocationAsync(this SubscriptionResource subscriptionResource, string location, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithLocsByLocationAsync(location, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithLocsByLocationAsync(location, cancellationToken); } /// @@ -1654,6 +1776,10 @@ public static AsyncPageable GetFakeParent /// FakeParentWithAncestorWithLocs_ListTestByLocations /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1663,9 +1789,7 @@ public static AsyncPageable GetFakeParent /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFakeParentWithAncestorWithLocsByLocation(this SubscriptionResource subscriptionResource, string location, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorWithLocsByLocation(location, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorWithLocsByLocation(location, cancellationToken); } /// @@ -1680,13 +1804,17 @@ public static Pageable GetFakeParentWithA /// FakeParentWithAncestors_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFakeParentWithAncestorsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestorsAsync(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestorsAsync(cancellationToken); } /// @@ -1701,13 +1829,17 @@ public static AsyncPageable GetFakeParentWithAnc /// FakeParentWithAncestors_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFakeParentWithAncestors(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFakeParentWithAncestors(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetFakeParentWithAncestors(cancellationToken); } /// @@ -1722,6 +1854,10 @@ public static Pageable GetFakeParentWithAncestor /// ResGrpParentWithAncestorWithNonResChWithLocs_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -1729,7 +1865,7 @@ public static Pageable GetFakeParentWithAncestor /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResGrpParentWithAncestorWithNonResChWithLocsAsync(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocsAsync(expand, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocsAsync(expand, cancellationToken); } /// @@ -1744,6 +1880,10 @@ public static AsyncPageable /// ResGrpParentWithAncestorWithNonResChWithLocs_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -1751,7 +1891,7 @@ public static AsyncPageable /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResGrpParentWithAncestorWithNonResChWithLocs(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocs(expand, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocs(expand, cancellationToken); } /// @@ -1766,6 +1906,10 @@ public static Pageable GetR /// ResGrpParentWithAncestorWithNonResChes_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -1773,7 +1917,7 @@ public static Pageable GetR /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResGrpParentWithAncestorWithNonResChesAsync(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithNonResChesAsync(expand, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithNonResChesAsync(expand, cancellationToken); } /// @@ -1788,6 +1932,10 @@ public static AsyncPageable GetRes /// ResGrpParentWithAncestorWithNonResChes_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -1795,7 +1943,7 @@ public static AsyncPageable GetRes /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResGrpParentWithAncestorWithNonResChes(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithNonResChes(expand, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithNonResChes(expand, cancellationToken); } /// @@ -1810,13 +1958,17 @@ public static Pageable GetResGrpPa /// ResGrpParentWithAncestorWithLocs_ListTest /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResGrpParentWithAncestorWithLocsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithLocsAsync(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithLocsAsync(cancellationToken); } /// @@ -1831,13 +1983,17 @@ public static AsyncPageable GetResGrpPa /// ResGrpParentWithAncestorWithLocs_ListTest /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResGrpParentWithAncestorWithLocs(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithLocs(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithLocs(cancellationToken); } /// @@ -1852,6 +2008,10 @@ public static Pageable GetResGrpParentW /// ResGrpParentWithAncestorWithLocs_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1861,9 +2021,7 @@ public static Pageable GetResGrpParentW /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLocAsync(this SubscriptionResource subscriptionResource, string location, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLocAsync(location, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLocAsync(location, cancellationToken); } /// @@ -1878,6 +2036,10 @@ public static AsyncPageable /// ResGrpParentWithAncestorWithLocs_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for which virtual machines under the subscription are queried. @@ -1887,9 +2049,7 @@ public static AsyncPageable /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc(this SubscriptionResource subscriptionResource, string location, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc(location, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc(location, cancellationToken); } /// @@ -1904,13 +2064,17 @@ public static Pageable GetR /// ResGrpParentWithAncestors_NonPageableListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResGrpParentWithAncestorsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestorsAsync(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestorsAsync(cancellationToken); } /// @@ -1925,13 +2089,17 @@ public static AsyncPageable GetResGrpParentWit /// ResGrpParentWithAncestors_NonPageableListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResGrpParentWithAncestors(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResGrpParentWithAncestors(cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).GetResGrpParentWithAncestors(cancellationToken); } /// @@ -1946,6 +2114,10 @@ public static Pageable GetResGrpParentWithAnce /// Quotas_Update /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for update quota is queried. @@ -1956,10 +2128,7 @@ public static Pageable GetResGrpParentWithAnce /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable UpdateAllQuotaAsync(this SubscriptionResource subscriptionResource, string location, QuotaUpdateContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).UpdateAllQuotaAsync(location, content, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).UpdateAllQuotaAsync(location, content, cancellationToken); } /// @@ -1974,6 +2143,10 @@ public static AsyncPageable UpdateAllQuotaAsync(this Subs /// Quotas_Update /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location for update quota is queried. @@ -1984,18 +2157,21 @@ public static AsyncPageable UpdateAllQuotaAsync(this Subs /// A collection of that may take multiple service requests to iterate over. public static Pageable UpdateAllQuota(this SubscriptionResource subscriptionResource, string location, QuotaUpdateContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).UpdateAllQuota(location, content, cancellationToken); + return GetMockableMgmtListMethodsSubscriptionResource(subscriptionResource).UpdateAllQuota(location, content, cancellationToken); } - /// Gets a collection of TenantTestResources in the TenantResource. + /// + /// Gets a collection of TenantTestResources in the TenantResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TenantTestResources and their operations over a TenantTestResource. public static TenantTestCollection GetTenantTests(this TenantResource tenantResource) { - return GetTenantResourceExtensionClient(tenantResource).GetTenantTests(); + return GetMockableMgmtListMethodsTenantResource(tenantResource).GetTenantTests(); } /// @@ -2010,17 +2186,21 @@ public static TenantTestCollection GetTenantTests(this TenantResource tenantReso /// TenantTests_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The ID that uniquely identifies a billing account. /// May be used to expand the soldTo, invoice sections and billing profiles. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTenantTestAsync(this TenantResource tenantResource, string tenantTestName, string expand = null, CancellationToken cancellationToken = default) { - return await tenantResource.GetTenantTests().GetAsync(tenantTestName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtListMethodsTenantResource(tenantResource).GetTenantTestAsync(tenantTestName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -2035,17 +2215,21 @@ public static async Task> GetTenantTestAsync(this T /// TenantTests_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The ID that uniquely identifies a billing account. /// May be used to expand the soldTo, invoice sections and billing profiles. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTenantTest(this TenantResource tenantResource, string tenantTestName, string expand = null, CancellationToken cancellationToken = default) { - return tenantResource.GetTenantTests().Get(tenantTestName, expand, cancellationToken); + return GetMockableMgmtListMethodsTenantResource(tenantResource).GetTenantTest(tenantTestName, expand, cancellationToken); } } } diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsArmClient.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsArmClient.cs new file mode 100644 index 00000000000..9454b1b4c39 --- /dev/null +++ b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsArmClient.cs @@ -0,0 +1,363 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtListMethods; + +namespace MgmtListMethods.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtListMethodsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtListMethodsArmClient() + { + } + + /// 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 MockableMgmtListMethodsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtListMethodsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 FakeResource GetFakeResource(ResourceIdentifier id) + { + FakeResource.ValidateResourceId(id); + return new FakeResource(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 FakeParentWithAncestorWithNonResChWithLocResource GetFakeParentWithAncestorWithNonResChWithLocResource(ResourceIdentifier id) + { + FakeParentWithAncestorWithNonResChWithLocResource.ValidateResourceId(id); + return new FakeParentWithAncestorWithNonResChWithLocResource(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 FakeParentWithAncestorWithNonResChResource GetFakeParentWithAncestorWithNonResChResource(ResourceIdentifier id) + { + FakeParentWithAncestorWithNonResChResource.ValidateResourceId(id); + return new FakeParentWithAncestorWithNonResChResource(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 FakeParentWithAncestorWithLocResource GetFakeParentWithAncestorWithLocResource(ResourceIdentifier id) + { + FakeParentWithAncestorWithLocResource.ValidateResourceId(id); + return new FakeParentWithAncestorWithLocResource(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 FakeParentWithAncestorResource GetFakeParentWithAncestorResource(ResourceIdentifier id) + { + FakeParentWithAncestorResource.ValidateResourceId(id); + return new FakeParentWithAncestorResource(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 FakeParentWithNonResChResource GetFakeParentWithNonResChResource(ResourceIdentifier id) + { + FakeParentWithNonResChResource.ValidateResourceId(id); + return new FakeParentWithNonResChResource(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 FakeParentResource GetFakeParentResource(ResourceIdentifier id) + { + FakeParentResource.ValidateResourceId(id); + return new FakeParentResource(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 ResGrpParentWithAncestorWithNonResChWithLocResource GetResGrpParentWithAncestorWithNonResChWithLocResource(ResourceIdentifier id) + { + ResGrpParentWithAncestorWithNonResChWithLocResource.ValidateResourceId(id); + return new ResGrpParentWithAncestorWithNonResChWithLocResource(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 ResGrpParentWithAncestorWithNonResChResource GetResGrpParentWithAncestorWithNonResChResource(ResourceIdentifier id) + { + ResGrpParentWithAncestorWithNonResChResource.ValidateResourceId(id); + return new ResGrpParentWithAncestorWithNonResChResource(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 ResGrpParentWithAncestorWithLocResource GetResGrpParentWithAncestorWithLocResource(ResourceIdentifier id) + { + ResGrpParentWithAncestorWithLocResource.ValidateResourceId(id); + return new ResGrpParentWithAncestorWithLocResource(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 ResGrpParentWithAncestorResource GetResGrpParentWithAncestorResource(ResourceIdentifier id) + { + ResGrpParentWithAncestorResource.ValidateResourceId(id); + return new ResGrpParentWithAncestorResource(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 ResGrpParentWithNonResChResource GetResGrpParentWithNonResChResource(ResourceIdentifier id) + { + ResGrpParentWithNonResChResource.ValidateResourceId(id); + return new ResGrpParentWithNonResChResource(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 ResGrpParentResource GetResGrpParentResource(ResourceIdentifier id) + { + ResGrpParentResource.ValidateResourceId(id); + return new ResGrpParentResource(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 SubParentWithNonResChWithLocResource GetSubParentWithNonResChWithLocResource(ResourceIdentifier id) + { + SubParentWithNonResChWithLocResource.ValidateResourceId(id); + return new SubParentWithNonResChWithLocResource(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 SubParentWithNonResChResource GetSubParentWithNonResChResource(ResourceIdentifier id) + { + SubParentWithNonResChResource.ValidateResourceId(id); + return new SubParentWithNonResChResource(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 SubParentWithLocResource GetSubParentWithLocResource(ResourceIdentifier id) + { + SubParentWithLocResource.ValidateResourceId(id); + return new SubParentWithLocResource(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 SubParentResource GetSubParentResource(ResourceIdentifier id) + { + SubParentResource.ValidateResourceId(id); + return new SubParentResource(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 MgmtGrpParentWithNonResChWithLocResource GetMgmtGrpParentWithNonResChWithLocResource(ResourceIdentifier id) + { + MgmtGrpParentWithNonResChWithLocResource.ValidateResourceId(id); + return new MgmtGrpParentWithNonResChWithLocResource(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 MgmtGrpParentWithNonResChResource GetMgmtGrpParentWithNonResChResource(ResourceIdentifier id) + { + MgmtGrpParentWithNonResChResource.ValidateResourceId(id); + return new MgmtGrpParentWithNonResChResource(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 MgmtGrpParentWithLocResource GetMgmtGrpParentWithLocResource(ResourceIdentifier id) + { + MgmtGrpParentWithLocResource.ValidateResourceId(id); + return new MgmtGrpParentWithLocResource(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 MgmtGroupParentResource GetMgmtGroupParentResource(ResourceIdentifier id) + { + MgmtGroupParentResource.ValidateResourceId(id); + return new MgmtGroupParentResource(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 TenantTestResource GetTenantTestResource(ResourceIdentifier id) + { + TenantTestResource.ValidateResourceId(id); + return new TenantTestResource(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 TenantParentWithNonResChWithLocResource GetTenantParentWithNonResChWithLocResource(ResourceIdentifier id) + { + TenantParentWithNonResChWithLocResource.ValidateResourceId(id); + return new TenantParentWithNonResChWithLocResource(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 TenantParentWithNonResChResource GetTenantParentWithNonResChResource(ResourceIdentifier id) + { + TenantParentWithNonResChResource.ValidateResourceId(id); + return new TenantParentWithNonResChResource(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 TenantParentWithLocResource GetTenantParentWithLocResource(ResourceIdentifier id) + { + TenantParentWithLocResource.ValidateResourceId(id); + return new TenantParentWithLocResource(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 TenantParentResource GetTenantParentResource(ResourceIdentifier id) + { + TenantParentResource.ValidateResourceId(id); + return new TenantParentResource(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 FakeConfigurationResource GetFakeConfigurationResource(ResourceIdentifier id) + { + FakeConfigurationResource.ValidateResourceId(id); + return new FakeConfigurationResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsManagementGroupResource.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsManagementGroupResource.cs new file mode 100644 index 00000000000..b6cc60268f8 --- /dev/null +++ b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsManagementGroupResource.cs @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtListMethods; + +namespace MgmtListMethods.Mocking +{ + /// A class to add extension methods to ManagementGroupResource. + public partial class MockableMgmtListMethodsManagementGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtListMethodsManagementGroupResource() + { + } + + /// 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 MockableMgmtListMethodsManagementGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of MgmtGrpParentWithNonResChWithLocResources in the ManagementGroupResource. + /// An object representing collection of MgmtGrpParentWithNonResChWithLocResources and their operations over a MgmtGrpParentWithNonResChWithLocResource. + public virtual MgmtGrpParentWithNonResChWithLocCollection GetMgmtGrpParentWithNonResChWithLocs() + { + return GetCachedClient(client => new MgmtGrpParentWithNonResChWithLocCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGrpParentWithNonResChWithLocs/{mgmtGrpParentWithNonResChWithLocName} + /// + /// + /// Operation Id + /// MgmtGrpParentWithNonResChWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMgmtGrpParentWithNonResChWithLocAsync(string mgmtGrpParentWithNonResChWithLocName, CancellationToken cancellationToken = default) + { + return await GetMgmtGrpParentWithNonResChWithLocs().GetAsync(mgmtGrpParentWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGrpParentWithNonResChWithLocs/{mgmtGrpParentWithNonResChWithLocName} + /// + /// + /// Operation Id + /// MgmtGrpParentWithNonResChWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMgmtGrpParentWithNonResChWithLoc(string mgmtGrpParentWithNonResChWithLocName, CancellationToken cancellationToken = default) + { + return GetMgmtGrpParentWithNonResChWithLocs().Get(mgmtGrpParentWithNonResChWithLocName, cancellationToken); + } + + /// Gets a collection of MgmtGrpParentWithNonResChResources in the ManagementGroupResource. + /// An object representing collection of MgmtGrpParentWithNonResChResources and their operations over a MgmtGrpParentWithNonResChResource. + public virtual MgmtGrpParentWithNonResChCollection GetMgmtGrpParentWithNonResChes() + { + return GetCachedClient(client => new MgmtGrpParentWithNonResChCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGrpParentWithNonResChes/{mgmtGrpParentWithNonResChName} + /// + /// + /// Operation Id + /// MgmtGrpParentWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMgmtGrpParentWithNonResChAsync(string mgmtGrpParentWithNonResChName, CancellationToken cancellationToken = default) + { + return await GetMgmtGrpParentWithNonResChes().GetAsync(mgmtGrpParentWithNonResChName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGrpParentWithNonResChes/{mgmtGrpParentWithNonResChName} + /// + /// + /// Operation Id + /// MgmtGrpParentWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMgmtGrpParentWithNonResCh(string mgmtGrpParentWithNonResChName, CancellationToken cancellationToken = default) + { + return GetMgmtGrpParentWithNonResChes().Get(mgmtGrpParentWithNonResChName, cancellationToken); + } + + /// Gets a collection of MgmtGrpParentWithLocResources in the ManagementGroupResource. + /// An object representing collection of MgmtGrpParentWithLocResources and their operations over a MgmtGrpParentWithLocResource. + public virtual MgmtGrpParentWithLocCollection GetMgmtGrpParentWithLocs() + { + return GetCachedClient(client => new MgmtGrpParentWithLocCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGrpParentWithLocs/{mgmtGrpParentWithLocName} + /// + /// + /// Operation Id + /// MgmtGrpParentWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMgmtGrpParentWithLocAsync(string mgmtGrpParentWithLocName, CancellationToken cancellationToken = default) + { + return await GetMgmtGrpParentWithLocs().GetAsync(mgmtGrpParentWithLocName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGrpParentWithLocs/{mgmtGrpParentWithLocName} + /// + /// + /// Operation Id + /// MgmtGrpParentWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMgmtGrpParentWithLoc(string mgmtGrpParentWithLocName, CancellationToken cancellationToken = default) + { + return GetMgmtGrpParentWithLocs().Get(mgmtGrpParentWithLocName, cancellationToken); + } + + /// Gets a collection of MgmtGroupParentResources in the ManagementGroupResource. + /// An object representing collection of MgmtGroupParentResources and their operations over a MgmtGroupParentResource. + public virtual MgmtGroupParentCollection GetMgmtGroupParents() + { + return GetCachedClient(client => new MgmtGroupParentCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGroupParents/{mgmtGroupParentName} + /// + /// + /// Operation Id + /// MgmtGroupParents_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMgmtGroupParentAsync(string mgmtGroupParentName, CancellationToken cancellationToken = default) + { + return await GetMgmtGroupParents().GetAsync(mgmtGroupParentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /providers/Microsoft.Management/managementGroups/{groupId}/mgmtGroupParents/{mgmtGroupParentName} + /// + /// + /// Operation Id + /// MgmtGroupParents_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMgmtGroupParent(string mgmtGroupParentName, CancellationToken cancellationToken = default) + { + return GetMgmtGroupParents().Get(mgmtGroupParentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsResourceGroupResource.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsResourceGroupResource.cs new file mode 100644 index 00000000000..b800ffb353e --- /dev/null +++ b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsResourceGroupResource.cs @@ -0,0 +1,357 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtListMethods; + +namespace MgmtListMethods.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtListMethodsResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtListMethodsResourceGroupResource() + { + } + + /// 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 MockableMgmtListMethodsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ResGrpParentWithAncestorWithNonResChWithLocResources in the ResourceGroupResource. + /// An object representing collection of ResGrpParentWithAncestorWithNonResChWithLocResources and their operations over a ResGrpParentWithAncestorWithNonResChWithLocResource. + public virtual ResGrpParentWithAncestorWithNonResChWithLocCollection GetResGrpParentWithAncestorWithNonResChWithLocs() + { + return GetCachedClient(client => new ResGrpParentWithAncestorWithNonResChWithLocCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestorWithNonResChWithLocs/{resGrpParentWithAncestorWithNonResChWithLocName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestorWithNonResChWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResGrpParentWithAncestorWithNonResChWithLocAsync(string resGrpParentWithAncestorWithNonResChWithLocName, CancellationToken cancellationToken = default) + { + return await GetResGrpParentWithAncestorWithNonResChWithLocs().GetAsync(resGrpParentWithAncestorWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestorWithNonResChWithLocs/{resGrpParentWithAncestorWithNonResChWithLocName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestorWithNonResChWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResGrpParentWithAncestorWithNonResChWithLoc(string resGrpParentWithAncestorWithNonResChWithLocName, CancellationToken cancellationToken = default) + { + return GetResGrpParentWithAncestorWithNonResChWithLocs().Get(resGrpParentWithAncestorWithNonResChWithLocName, cancellationToken); + } + + /// Gets a collection of ResGrpParentWithAncestorWithNonResChResources in the ResourceGroupResource. + /// An object representing collection of ResGrpParentWithAncestorWithNonResChResources and their operations over a ResGrpParentWithAncestorWithNonResChResource. + public virtual ResGrpParentWithAncestorWithNonResChCollection GetResGrpParentWithAncestorWithNonResChes() + { + return GetCachedClient(client => new ResGrpParentWithAncestorWithNonResChCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestorWithNonResChes/{resGrpParentWithAncestorWithNonResChName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestorWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResGrpParentWithAncestorWithNonResChAsync(string resGrpParentWithAncestorWithNonResChName, CancellationToken cancellationToken = default) + { + return await GetResGrpParentWithAncestorWithNonResChes().GetAsync(resGrpParentWithAncestorWithNonResChName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestorWithNonResChes/{resGrpParentWithAncestorWithNonResChName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestorWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResGrpParentWithAncestorWithNonResCh(string resGrpParentWithAncestorWithNonResChName, CancellationToken cancellationToken = default) + { + return GetResGrpParentWithAncestorWithNonResChes().Get(resGrpParentWithAncestorWithNonResChName, cancellationToken); + } + + /// Gets a collection of ResGrpParentWithAncestorWithLocResources in the ResourceGroupResource. + /// An object representing collection of ResGrpParentWithAncestorWithLocResources and their operations over a ResGrpParentWithAncestorWithLocResource. + public virtual ResGrpParentWithAncestorWithLocCollection GetResGrpParentWithAncestorWithLocs() + { + return GetCachedClient(client => new ResGrpParentWithAncestorWithLocCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestorWithLocs/{resGrpParentWithAncestorWithLocName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestorWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResGrpParentWithAncestorWithLocAsync(string resGrpParentWithAncestorWithLocName, CancellationToken cancellationToken = default) + { + return await GetResGrpParentWithAncestorWithLocs().GetAsync(resGrpParentWithAncestorWithLocName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestorWithLocs/{resGrpParentWithAncestorWithLocName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestorWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResGrpParentWithAncestorWithLoc(string resGrpParentWithAncestorWithLocName, CancellationToken cancellationToken = default) + { + return GetResGrpParentWithAncestorWithLocs().Get(resGrpParentWithAncestorWithLocName, cancellationToken); + } + + /// Gets a collection of ResGrpParentWithAncestorResources in the ResourceGroupResource. + /// An object representing collection of ResGrpParentWithAncestorResources and their operations over a ResGrpParentWithAncestorResource. + public virtual ResGrpParentWithAncestorCollection GetResGrpParentWithAncestors() + { + return GetCachedClient(client => new ResGrpParentWithAncestorCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestors/{resGrpParentWithAncestorName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestors_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResGrpParentWithAncestorAsync(string resGrpParentWithAncestorName, CancellationToken cancellationToken = default) + { + return await GetResGrpParentWithAncestors().GetAsync(resGrpParentWithAncestorName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithAncestors/{resGrpParentWithAncestorName} + /// + /// + /// Operation Id + /// ResGrpParentWithAncestors_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResGrpParentWithAncestor(string resGrpParentWithAncestorName, CancellationToken cancellationToken = default) + { + return GetResGrpParentWithAncestors().Get(resGrpParentWithAncestorName, cancellationToken); + } + + /// Gets a collection of ResGrpParentWithNonResChResources in the ResourceGroupResource. + /// An object representing collection of ResGrpParentWithNonResChResources and their operations over a ResGrpParentWithNonResChResource. + public virtual ResGrpParentWithNonResChCollection GetResGrpParentWithNonResChes() + { + return GetCachedClient(client => new ResGrpParentWithNonResChCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithNonResChes/{resGrpParentWithNonResChName} + /// + /// + /// Operation Id + /// ResGrpParentWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResGrpParentWithNonResChAsync(string resGrpParentWithNonResChName, CancellationToken cancellationToken = default) + { + return await GetResGrpParentWithNonResChes().GetAsync(resGrpParentWithNonResChName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParentWithNonResChes/{resGrpParentWithNonResChName} + /// + /// + /// Operation Id + /// ResGrpParentWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResGrpParentWithNonResCh(string resGrpParentWithNonResChName, CancellationToken cancellationToken = default) + { + return GetResGrpParentWithNonResChes().Get(resGrpParentWithNonResChName, cancellationToken); + } + + /// Gets a collection of ResGrpParentResources in the ResourceGroupResource. + /// An object representing collection of ResGrpParentResources and their operations over a ResGrpParentResource. + public virtual ResGrpParentCollection GetResGrpParents() + { + return GetCachedClient(client => new ResGrpParentCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParents/{resGrpParentName} + /// + /// + /// Operation Id + /// ResGrpParents_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResGrpParentAsync(string resGrpParentName, CancellationToken cancellationToken = default) + { + return await GetResGrpParents().GetAsync(resGrpParentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MgmtListMethods/resGrpParents/{resGrpParentName} + /// + /// + /// Operation Id + /// ResGrpParents_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResGrpParent(string resGrpParentName, CancellationToken cancellationToken = default) + { + return GetResGrpParents().Get(resGrpParentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsSubscriptionResource.cs similarity index 70% rename from test/TestProjects/MgmtListMethods/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsSubscriptionResource.cs index 15491577a1b..bff703e9c98 100644 --- a/test/TestProjects/MgmtListMethods/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsSubscriptionResource.cs @@ -5,18 +5,21 @@ #nullable disable +using System; using System.Threading; +using System.Threading.Tasks; using Autorest.CSharp.Core; using Azure; using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtListMethods; using MgmtListMethods.Models; -namespace MgmtListMethods +namespace MgmtListMethods.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtListMethodsSubscriptionResource : ArmResource { private ClientDiagnostics _fakeParentWithAncestorWithNonResChWithLocClientDiagnostics; private FakeParentWithAncestorWithNonResChWithLocsRestOperations _fakeParentWithAncestorWithNonResChWithLocRestClient; @@ -37,15 +40,15 @@ internal partial class SubscriptionResourceExtensionClient : ArmResource private ClientDiagnostics _quotasClientDiagnostics; private QuotasRestOperations _quotasRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtListMethodsSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtListMethodsSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -78,35 +81,267 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of FakeResources and their operations over a FakeResource. public virtual FakeCollection GetFakes() { - return GetCachedClient(Client => new FakeCollection(Client, Id)); + return GetCachedClient(client => new FakeCollection(client, Id)); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Fake/fakes/{fakeName} + /// + /// + /// Operation Id + /// Fakes_Get + /// + /// + /// + /// The name of the fake. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetFakeAsync(string fakeName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetFakes().GetAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Fake/fakes/{fakeName} + /// + /// + /// Operation Id + /// Fakes_Get + /// + /// + /// + /// The name of the fake. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetFake(string fakeName, string expand = null, CancellationToken cancellationToken = default) + { + return GetFakes().Get(fakeName, expand, cancellationToken); } /// Gets a collection of SubParentWithNonResChWithLocResources in the SubscriptionResource. /// An object representing collection of SubParentWithNonResChWithLocResources and their operations over a SubParentWithNonResChWithLocResource. public virtual SubParentWithNonResChWithLocCollection GetSubParentWithNonResChWithLocs() { - return GetCachedClient(Client => new SubParentWithNonResChWithLocCollection(Client, Id)); + return GetCachedClient(client => new SubParentWithNonResChWithLocCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParentWithNonResChWithLocs/{subParentWithNonResChWithLocName} + /// + /// + /// Operation Id + /// SubParentWithNonResChWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSubParentWithNonResChWithLocAsync(string subParentWithNonResChWithLocName, CancellationToken cancellationToken = default) + { + return await GetSubParentWithNonResChWithLocs().GetAsync(subParentWithNonResChWithLocName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParentWithNonResChWithLocs/{subParentWithNonResChWithLocName} + /// + /// + /// Operation Id + /// SubParentWithNonResChWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSubParentWithNonResChWithLoc(string subParentWithNonResChWithLocName, CancellationToken cancellationToken = default) + { + return GetSubParentWithNonResChWithLocs().Get(subParentWithNonResChWithLocName, cancellationToken); } /// Gets a collection of SubParentWithNonResChResources in the SubscriptionResource. /// An object representing collection of SubParentWithNonResChResources and their operations over a SubParentWithNonResChResource. public virtual SubParentWithNonResChCollection GetSubParentWithNonResChes() { - return GetCachedClient(Client => new SubParentWithNonResChCollection(Client, Id)); + return GetCachedClient(client => new SubParentWithNonResChCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParentWithNonResChes/{subParentWithNonResChName} + /// + /// + /// Operation Id + /// SubParentWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSubParentWithNonResChAsync(string subParentWithNonResChName, CancellationToken cancellationToken = default) + { + return await GetSubParentWithNonResChes().GetAsync(subParentWithNonResChName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParentWithNonResChes/{subParentWithNonResChName} + /// + /// + /// Operation Id + /// SubParentWithNonResChes_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSubParentWithNonResCh(string subParentWithNonResChName, CancellationToken cancellationToken = default) + { + return GetSubParentWithNonResChes().Get(subParentWithNonResChName, cancellationToken); } /// Gets a collection of SubParentWithLocResources in the SubscriptionResource. /// An object representing collection of SubParentWithLocResources and their operations over a SubParentWithLocResource. public virtual SubParentWithLocCollection GetSubParentWithLocs() { - return GetCachedClient(Client => new SubParentWithLocCollection(Client, Id)); + return GetCachedClient(client => new SubParentWithLocCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParentWithLocs/{subParentWithLocName} + /// + /// + /// Operation Id + /// SubParentWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSubParentWithLocAsync(string subParentWithLocName, CancellationToken cancellationToken = default) + { + return await GetSubParentWithLocs().GetAsync(subParentWithLocName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParentWithLocs/{subParentWithLocName} + /// + /// + /// Operation Id + /// SubParentWithLocs_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSubParentWithLoc(string subParentWithLocName, CancellationToken cancellationToken = default) + { + return GetSubParentWithLocs().Get(subParentWithLocName, cancellationToken); } /// Gets a collection of SubParentResources in the SubscriptionResource. /// An object representing collection of SubParentResources and their operations over a SubParentResource. public virtual SubParentCollection GetSubParents() { - return GetCachedClient(Client => new SubParentCollection(Client, Id)); + return GetCachedClient(client => new SubParentCollection(client, Id)); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParents/{subParentName} + /// + /// + /// Operation Id + /// SubParents_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSubParentAsync(string subParentName, CancellationToken cancellationToken = default) + { + return await GetSubParents().GetAsync(subParentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.MgmtListMethods/subParents/{subParentName} + /// + /// + /// Operation Id + /// SubParents_Get + /// + /// + /// + /// Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSubParent(string subParentName, CancellationToken cancellationToken = default) + { + return GetSubParents().Get(subParentName, cancellationToken); } /// @@ -128,7 +363,7 @@ public virtual AsyncPageable { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChWithLocResource(Client, FakeParentWithAncestorWithNonResChWithLocData.DeserializeFakeParentWithAncestorWithNonResChWithLocData(e)), FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithNonResourceChWithLoc", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChWithLocResource(Client, FakeParentWithAncestorWithNonResChWithLocData.DeserializeFakeParentWithAncestorWithNonResChWithLocData(e)), FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithNonResourceChWithLoc", "value", "nextLink", cancellationToken); } /// @@ -150,7 +385,7 @@ public virtual Pageable GetFa { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChWithLocResource(Client, FakeParentWithAncestorWithNonResChWithLocData.DeserializeFakeParentWithAncestorWithNonResChWithLocData(e)), FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithNonResourceChWithLoc", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChWithLocResource(Client, FakeParentWithAncestorWithNonResChWithLocData.DeserializeFakeParentWithAncestorWithNonResChWithLocData(e)), FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithNonResourceChWithLoc", "value", "nextLink", cancellationToken); } /// @@ -168,11 +403,15 @@ public virtual Pageable GetFa /// /// The location for which virtual machines under the subscription are queried. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocsAsync(string location, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithNonResChWithLocRestClient.CreateListTestByLocationsRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, NonResourceChild.DeserializeNonResourceChild, FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, NonResourceChild.DeserializeNonResourceChild, FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs", "value", null, cancellationToken); } /// @@ -190,11 +429,15 @@ public virtual AsyncPageable GetTestByLocationsFakeParentWithA /// /// The location for which virtual machines under the subscription are queried. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs(string location, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithNonResChWithLocRestClient.CreateListTestByLocationsRequest(Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, NonResourceChild.DeserializeNonResourceChild, FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, NonResourceChild.DeserializeNonResourceChild, FakeParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetTestByLocationsFakeParentWithAncestorWithNonResChWithLocs", "value", null, cancellationToken); } /// @@ -216,7 +459,7 @@ public virtual AsyncPageable GetFake { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChResource(Client, FakeParentWithAncestorWithNonResChData.DeserializeFakeParentWithAncestorWithNonResChData(e)), FakeParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChResource(Client, FakeParentWithAncestorWithNonResChData.DeserializeFakeParentWithAncestorWithNonResChData(e)), FakeParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); } /// @@ -238,7 +481,7 @@ public virtual Pageable GetFakeParen { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChResource(Client, FakeParentWithAncestorWithNonResChData.DeserializeFakeParentWithAncestorWithNonResChData(e)), FakeParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithNonResChResource(Client, FakeParentWithAncestorWithNonResChData.DeserializeFakeParentWithAncestorWithNonResChData(e)), FakeParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); } /// @@ -260,7 +503,7 @@ public virtual AsyncPageable GetFakeParen { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithLocRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithLocRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); } /// @@ -282,7 +525,7 @@ public virtual Pageable GetFakeParentWith { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithLocRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithLocRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); } /// @@ -300,12 +543,16 @@ public virtual Pageable GetFakeParentWith /// /// The location for which virtual machines under the subscription are queried. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetFakeParentWithAncestorWithLocsByLocationAsync(string location, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithLocRestClient.CreateListTestByLocationsRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithLocRestClient.CreateListTestByLocationsNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithLocsByLocation", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithLocsByLocation", "value", "nextLink", cancellationToken); } /// @@ -323,12 +570,16 @@ public virtual AsyncPageable GetFakeParen /// /// The location for which virtual machines under the subscription are queried. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetFakeParentWithAncestorWithLocsByLocation(string location, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorWithLocRestClient.CreateListTestByLocationsRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorWithLocRestClient.CreateListTestByLocationsNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestorWithLocsByLocation", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorWithLocResource(Client, FakeParentWithAncestorWithLocData.DeserializeFakeParentWithAncestorWithLocData(e)), FakeParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestorWithLocsByLocation", "value", "nextLink", cancellationToken); } /// @@ -350,7 +601,7 @@ public virtual AsyncPageable GetFakeParentWithAn { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorResource(Client, FakeParentWithAncestorData.DeserializeFakeParentWithAncestorData(e)), FakeParentWithAncestorClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestors", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorResource(Client, FakeParentWithAncestorData.DeserializeFakeParentWithAncestorData(e)), FakeParentWithAncestorClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestors", "value", "nextLink", cancellationToken); } /// @@ -372,7 +623,7 @@ public virtual Pageable GetFakeParentWithAncesto { HttpMessage FirstPageRequest(int? pageSizeHint) => FakeParentWithAncestorRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FakeParentWithAncestorRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorResource(Client, FakeParentWithAncestorData.DeserializeFakeParentWithAncestorData(e)), FakeParentWithAncestorClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFakeParentWithAncestors", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FakeParentWithAncestorResource(Client, FakeParentWithAncestorData.DeserializeFakeParentWithAncestorData(e)), FakeParentWithAncestorClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetFakeParentWithAncestors", "value", "nextLink", cancellationToken); } /// @@ -395,7 +646,7 @@ public virtual AsyncPageable ResGrpParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithNonResChWithLocs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithNonResChWithLocs", "value", "nextLink", cancellationToken); } /// @@ -418,7 +669,7 @@ public virtual Pageable Get { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithNonResChWithLocRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithNonResChWithLocs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithNonResChWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithNonResChWithLocs", "value", "nextLink", cancellationToken); } /// @@ -441,7 +692,7 @@ public virtual AsyncPageable GetRe { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChResource(Client, ResGrpParentWithAncestorWithNonResChData.DeserializeResGrpParentWithAncestorWithNonResChData(e)), ResGrpParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChResource(Client, ResGrpParentWithAncestorWithNonResChData.DeserializeResGrpParentWithAncestorWithNonResChData(e)), ResGrpParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); } /// @@ -464,7 +715,7 @@ public virtual Pageable GetResGrpP { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithNonResChRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChResource(Client, ResGrpParentWithAncestorWithNonResChData.DeserializeResGrpParentWithAncestorWithNonResChData(e)), ResGrpParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChResource(Client, ResGrpParentWithAncestorWithNonResChData.DeserializeResGrpParentWithAncestorWithNonResChData(e)), ResGrpParentWithAncestorWithNonResChClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithNonResChes", "value", "nextLink", cancellationToken); } /// @@ -486,7 +737,7 @@ public virtual AsyncPageable GetResGrpP { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithLocRestClient.CreateListTestRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithLocRestClient.CreateListTestNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithLocResource(Client, ResGrpParentWithAncestorWithLocData.DeserializeResGrpParentWithAncestorWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithLocResource(Client, ResGrpParentWithAncestorWithLocData.DeserializeResGrpParentWithAncestorWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); } /// @@ -508,7 +759,7 @@ public virtual Pageable GetResGrpParent { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithLocRestClient.CreateListTestRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithLocRestClient.CreateListTestNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithLocResource(Client, ResGrpParentWithAncestorWithLocData.DeserializeResGrpParentWithAncestorWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithLocResource(Client, ResGrpParentWithAncestorWithLocData.DeserializeResGrpParentWithAncestorWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithLocs", "value", "nextLink", cancellationToken); } /// @@ -526,12 +777,16 @@ public virtual Pageable GetResGrpParent /// /// The location for which virtual machines under the subscription are queried. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLocAsync(string location, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithLocRestClient.CreateListAllRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithLocRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc", "value", "nextLink", cancellationToken); } /// @@ -549,12 +804,16 @@ public virtual AsyncPageable /// The location for which virtual machines under the subscription are queried. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc(string location, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorWithLocRestClient.CreateListAllRequest(Id.SubscriptionId, location); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResGrpParentWithAncestorWithLocRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, location); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResGrpParentWithAncestorWithNonResChWithLocResource(Client, ResGrpParentWithAncestorWithNonResChWithLocData.DeserializeResGrpParentWithAncestorWithNonResChWithLocData(e)), ResGrpParentWithAncestorWithLocClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestorWithNonResChWithLocsByLocationResGrpParentWithAncestorWithLoc", "value", "nextLink", cancellationToken); } /// @@ -575,7 +834,7 @@ public virtual Pageable Get public virtual AsyncPageable GetResGrpParentWithAncestorsAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorRestClient.CreateNonPageableListBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new ResGrpParentWithAncestorResource(Client, ResGrpParentWithAncestorData.DeserializeResGrpParentWithAncestorData(e)), ResGrpParentWithAncestorClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestors", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new ResGrpParentWithAncestorResource(Client, ResGrpParentWithAncestorData.DeserializeResGrpParentWithAncestorData(e)), ResGrpParentWithAncestorClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestors", "value", null, cancellationToken); } /// @@ -596,7 +855,7 @@ public virtual AsyncPageable GetResGrpParentWi public virtual Pageable GetResGrpParentWithAncestors(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => ResGrpParentWithAncestorRestClient.CreateNonPageableListBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new ResGrpParentWithAncestorResource(Client, ResGrpParentWithAncestorData.DeserializeResGrpParentWithAncestorData(e)), ResGrpParentWithAncestorClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResGrpParentWithAncestors", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new ResGrpParentWithAncestorResource(Client, ResGrpParentWithAncestorData.DeserializeResGrpParentWithAncestorData(e)), ResGrpParentWithAncestorClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.GetResGrpParentWithAncestors", "value", null, cancellationToken); } /// @@ -615,11 +874,16 @@ public virtual Pageable GetResGrpParentWithAnc /// The location for update quota is queried. /// Quota update parameters. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable UpdateAllQuotaAsync(string location, QuotaUpdateContent content, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNull(content, nameof(content)); + HttpMessage FirstPageRequest(int? pageSizeHint) => QuotasRestClient.CreateUpdateRequest(Id.SubscriptionId, location, content); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, UpdateWorkspaceQuotas.DeserializeUpdateWorkspaceQuotas, QuotasClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.UpdateAllQuota", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, UpdateWorkspaceQuotas.DeserializeUpdateWorkspaceQuotas, QuotasClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.UpdateAllQuota", "value", null, cancellationToken); } /// @@ -638,11 +902,16 @@ public virtual AsyncPageable UpdateAllQuotaAsync(string l /// The location for update quota is queried. /// Quota update parameters. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. /// A collection of that may take multiple service requests to iterate over. public virtual Pageable UpdateAllQuota(string location, QuotaUpdateContent content, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(location, nameof(location)); + Argument.AssertNotNull(content, nameof(content)); + HttpMessage FirstPageRequest(int? pageSizeHint) => QuotasRestClient.CreateUpdateRequest(Id.SubscriptionId, location, content); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, UpdateWorkspaceQuotas.DeserializeUpdateWorkspaceQuotas, QuotasClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.UpdateAllQuota", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, UpdateWorkspaceQuotas.DeserializeUpdateWorkspaceQuotas, QuotasClientDiagnostics, Pipeline, "MockableMgmtListMethodsSubscriptionResource.UpdateAllQuota", "value", null, cancellationToken); } } } diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsTenantResource.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsTenantResource.cs new file mode 100644 index 00000000000..af89fb7edd1 --- /dev/null +++ b/test/TestProjects/MgmtListMethods/Generated/Extensions/MockableMgmtListMethodsTenantResource.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtListMethods; + +namespace MgmtListMethods.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableMgmtListMethodsTenantResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtListMethodsTenantResource() + { + } + + /// 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 MockableMgmtListMethodsTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of TenantTestResources in the TenantResource. + /// An object representing collection of TenantTestResources and their operations over a TenantTestResource. + public virtual TenantTestCollection GetTenantTests() + { + return GetCachedClient(client => new TenantTestCollection(client, Id)); + } + + /// + /// Gets a billing account by its ID. + /// + /// + /// Request Path + /// /providers/Microsoft.Tenant/tenantTests/{tenantTestName} + /// + /// + /// Operation Id + /// TenantTests_Get + /// + /// + /// + /// The ID that uniquely identifies a billing account. + /// May be used to expand the soldTo, invoice sections and billing profiles. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTenantTestAsync(string tenantTestName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetTenantTests().GetAsync(tenantTestName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a billing account by its ID. + /// + /// + /// Request Path + /// /providers/Microsoft.Tenant/tenantTests/{tenantTestName} + /// + /// + /// Operation Id + /// TenantTests_Get + /// + /// + /// + /// The ID that uniquely identifies a billing account. + /// May be used to expand the soldTo, invoice sections and billing profiles. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTenantTest(string tenantTestName, string expand = null, CancellationToken cancellationToken = default) + { + return GetTenantTests().Get(tenantTestName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index ee43a9e3e3b..00000000000 --- a/test/TestProjects/MgmtListMethods/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtListMethods -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of ResGrpParentWithAncestorWithNonResChWithLocResources in the ResourceGroupResource. - /// An object representing collection of ResGrpParentWithAncestorWithNonResChWithLocResources and their operations over a ResGrpParentWithAncestorWithNonResChWithLocResource. - public virtual ResGrpParentWithAncestorWithNonResChWithLocCollection GetResGrpParentWithAncestorWithNonResChWithLocs() - { - return GetCachedClient(Client => new ResGrpParentWithAncestorWithNonResChWithLocCollection(Client, Id)); - } - - /// Gets a collection of ResGrpParentWithAncestorWithNonResChResources in the ResourceGroupResource. - /// An object representing collection of ResGrpParentWithAncestorWithNonResChResources and their operations over a ResGrpParentWithAncestorWithNonResChResource. - public virtual ResGrpParentWithAncestorWithNonResChCollection GetResGrpParentWithAncestorWithNonResChes() - { - return GetCachedClient(Client => new ResGrpParentWithAncestorWithNonResChCollection(Client, Id)); - } - - /// Gets a collection of ResGrpParentWithAncestorWithLocResources in the ResourceGroupResource. - /// An object representing collection of ResGrpParentWithAncestorWithLocResources and their operations over a ResGrpParentWithAncestorWithLocResource. - public virtual ResGrpParentWithAncestorWithLocCollection GetResGrpParentWithAncestorWithLocs() - { - return GetCachedClient(Client => new ResGrpParentWithAncestorWithLocCollection(Client, Id)); - } - - /// Gets a collection of ResGrpParentWithAncestorResources in the ResourceGroupResource. - /// An object representing collection of ResGrpParentWithAncestorResources and their operations over a ResGrpParentWithAncestorResource. - public virtual ResGrpParentWithAncestorCollection GetResGrpParentWithAncestors() - { - return GetCachedClient(Client => new ResGrpParentWithAncestorCollection(Client, Id)); - } - - /// Gets a collection of ResGrpParentWithNonResChResources in the ResourceGroupResource. - /// An object representing collection of ResGrpParentWithNonResChResources and their operations over a ResGrpParentWithNonResChResource. - public virtual ResGrpParentWithNonResChCollection GetResGrpParentWithNonResChes() - { - return GetCachedClient(Client => new ResGrpParentWithNonResChCollection(Client, Id)); - } - - /// Gets a collection of ResGrpParentResources in the ResourceGroupResource. - /// An object representing collection of ResGrpParentResources and their operations over a ResGrpParentResource. - public virtual ResGrpParentCollection GetResGrpParents() - { - return GetCachedClient(Client => new ResGrpParentCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtListMethods/Generated/Extensions/TenantResourceExtensionClient.cs b/test/TestProjects/MgmtListMethods/Generated/Extensions/TenantResourceExtensionClient.cs deleted file mode 100644 index 311f1fe5e44..00000000000 --- a/test/TestProjects/MgmtListMethods/Generated/Extensions/TenantResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtListMethods -{ - /// A class to add extension methods to TenantResource. - internal partial class TenantResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected TenantResourceExtensionClient() - { - } - - /// 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 TenantResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of TenantTestResources in the TenantResource. - /// An object representing collection of TenantTestResources and their operations over a TenantTestResource. - public virtual TenantTestCollection GetTenantTests() - { - return GetCachedClient(Client => new TenantTestCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtListMethods/Generated/FakeResource.cs b/test/TestProjects/MgmtListMethods/Generated/FakeResource.cs index a295f8b8f1b..a1cb6050615 100644 --- a/test/TestProjects/MgmtListMethods/Generated/FakeResource.cs +++ b/test/TestProjects/MgmtListMethods/Generated/FakeResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of FakeParentWithAncestorWithNonResChWithLocResources and their operations over a FakeParentWithAncestorWithNonResChWithLocResource. public virtual FakeParentWithAncestorWithNonResChWithLocCollection GetFakeParentWithAncestorWithNonResChWithLocs() { - return GetCachedClient(Client => new FakeParentWithAncestorWithNonResChWithLocCollection(Client, Id)); + return GetCachedClient(client => new FakeParentWithAncestorWithNonResChWithLocCollection(client, Id)); } /// @@ -114,8 +114,8 @@ public virtual FakeParentWithAncestorWithNonResChWithLocCollection GetFakeParent /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeParentWithAncestorWithNonResChWithLocAsync(string fakeParentWithAncestorWithNonResChWithLocName, CancellationToken cancellationToken = default) { @@ -137,8 +137,8 @@ public virtual async Task /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeParentWithAncestorWithNonResChWithLoc(string fakeParentWithAncestorWithNonResChWithLocName, CancellationToken cancellationToken = default) { @@ -149,7 +149,7 @@ public virtual Response GetFa /// An object representing collection of FakeParentWithAncestorWithNonResChResources and their operations over a FakeParentWithAncestorWithNonResChResource. public virtual FakeParentWithAncestorWithNonResChCollection GetFakeParentWithAncestorWithNonResChes() { - return GetCachedClient(Client => new FakeParentWithAncestorWithNonResChCollection(Client, Id)); + return GetCachedClient(client => new FakeParentWithAncestorWithNonResChCollection(client, Id)); } /// @@ -167,8 +167,8 @@ public virtual FakeParentWithAncestorWithNonResChCollection GetFakeParentWithAnc /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeParentWithAncestorWithNonResChAsync(string fakeParentWithAncestorWithNonResChName, CancellationToken cancellationToken = default) { @@ -190,8 +190,8 @@ public virtual async Task> /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeParentWithAncestorWithNonResCh(string fakeParentWithAncestorWithNonResChName, CancellationToken cancellationToken = default) { @@ -202,7 +202,7 @@ public virtual Response GetFakeParen /// An object representing collection of FakeParentWithAncestorWithLocResources and their operations over a FakeParentWithAncestorWithLocResource. public virtual FakeParentWithAncestorWithLocCollection GetFakeParentWithAncestorWithLocs() { - return GetCachedClient(Client => new FakeParentWithAncestorWithLocCollection(Client, Id)); + return GetCachedClient(client => new FakeParentWithAncestorWithLocCollection(client, Id)); } /// @@ -220,8 +220,8 @@ public virtual FakeParentWithAncestorWithLocCollection GetFakeParentWithAncestor /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeParentWithAncestorWithLocAsync(string fakeParentWithAncestorWithLocName, CancellationToken cancellationToken = default) { @@ -243,8 +243,8 @@ public virtual async Task> GetFa /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeParentWithAncestorWithLoc(string fakeParentWithAncestorWithLocName, CancellationToken cancellationToken = default) { @@ -255,7 +255,7 @@ public virtual Response GetFakeParentWith /// An object representing collection of FakeParentWithAncestorResources and their operations over a FakeParentWithAncestorResource. public virtual FakeParentWithAncestorCollection GetFakeParentWithAncestors() { - return GetCachedClient(Client => new FakeParentWithAncestorCollection(Client, Id)); + return GetCachedClient(client => new FakeParentWithAncestorCollection(client, Id)); } /// @@ -273,8 +273,8 @@ public virtual FakeParentWithAncestorCollection GetFakeParentWithAncestors() /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeParentWithAncestorAsync(string fakeParentWithAncestorName, CancellationToken cancellationToken = default) { @@ -296,8 +296,8 @@ public virtual async Task> GetFakeParen /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeParentWithAncestor(string fakeParentWithAncestorName, CancellationToken cancellationToken = default) { @@ -308,7 +308,7 @@ public virtual Response GetFakeParentWithAncesto /// An object representing collection of FakeParentWithNonResChResources and their operations over a FakeParentWithNonResChResource. public virtual FakeParentWithNonResChCollection GetFakeParentWithNonResChes() { - return GetCachedClient(Client => new FakeParentWithNonResChCollection(Client, Id)); + return GetCachedClient(client => new FakeParentWithNonResChCollection(client, Id)); } /// @@ -326,8 +326,8 @@ public virtual FakeParentWithNonResChCollection GetFakeParentWithNonResChes() /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeParentWithNonResChAsync(string fakeParentWithNonResChName, CancellationToken cancellationToken = default) { @@ -349,8 +349,8 @@ public virtual async Task> GetFakeParen /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeParentWithNonResCh(string fakeParentWithNonResChName, CancellationToken cancellationToken = default) { @@ -361,7 +361,7 @@ public virtual Response GetFakeParentWithNonResC /// An object representing collection of FakeParentResources and their operations over a FakeParentResource. public virtual FakeParentCollection GetFakeParents() { - return GetCachedClient(Client => new FakeParentCollection(Client, Id)); + return GetCachedClient(client => new FakeParentCollection(client, Id)); } /// @@ -379,8 +379,8 @@ public virtual FakeParentCollection GetFakeParents() /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeParentAsync(string fakeParentName, CancellationToken cancellationToken = default) { @@ -402,8 +402,8 @@ public virtual async Task> GetFakeParentAsync(strin /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeParent(string fakeParentName, CancellationToken cancellationToken = default) { @@ -414,7 +414,7 @@ public virtual Response GetFakeParent(string fakeParentName, /// An object representing collection of FakeConfigurationResources and their operations over a FakeConfigurationResource. public virtual FakeConfigurationCollection GetFakeConfigurations() { - return GetCachedClient(Client => new FakeConfigurationCollection(Client, Id)); + return GetCachedClient(client => new FakeConfigurationCollection(client, Id)); } /// @@ -432,8 +432,8 @@ public virtual FakeConfigurationCollection GetFakeConfigurations() /// /// The name of the configuration. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFakeConfigurationAsync(string configurationName, CancellationToken cancellationToken = default) { @@ -455,8 +455,8 @@ public virtual async Task> GetFakeConfigurat /// /// The name of the configuration. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFakeConfiguration(string configurationName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtListMethods/Generated/TenantTestResource.cs b/test/TestProjects/MgmtListMethods/Generated/TenantTestResource.cs index 974c733c851..cb00c7937aa 100644 --- a/test/TestProjects/MgmtListMethods/Generated/TenantTestResource.cs +++ b/test/TestProjects/MgmtListMethods/Generated/TenantTestResource.cs @@ -93,7 +93,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of TenantParentWithNonResChWithLocResources and their operations over a TenantParentWithNonResChWithLocResource. public virtual TenantParentWithNonResChWithLocCollection GetTenantParentWithNonResChWithLocs() { - return GetCachedClient(Client => new TenantParentWithNonResChWithLocCollection(Client, Id)); + return GetCachedClient(client => new TenantParentWithNonResChWithLocCollection(client, Id)); } /// @@ -111,8 +111,8 @@ public virtual TenantParentWithNonResChWithLocCollection GetTenantParentWithNonR /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetTenantParentWithNonResChWithLocAsync(string tenantParentWithNonResChWithLocName, CancellationToken cancellationToken = default) { @@ -134,8 +134,8 @@ public virtual async Task> Get /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetTenantParentWithNonResChWithLoc(string tenantParentWithNonResChWithLocName, CancellationToken cancellationToken = default) { @@ -146,7 +146,7 @@ public virtual Response GetTenantParent /// An object representing collection of TenantParentWithNonResChResources and their operations over a TenantParentWithNonResChResource. public virtual TenantParentWithNonResChCollection GetTenantParentWithNonResChes() { - return GetCachedClient(Client => new TenantParentWithNonResChCollection(Client, Id)); + return GetCachedClient(client => new TenantParentWithNonResChCollection(client, Id)); } /// @@ -164,8 +164,8 @@ public virtual TenantParentWithNonResChCollection GetTenantParentWithNonResChes( /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetTenantParentWithNonResChAsync(string tenantParentWithNonResChName, CancellationToken cancellationToken = default) { @@ -187,8 +187,8 @@ public virtual async Task> GetTenantP /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetTenantParentWithNonResCh(string tenantParentWithNonResChName, CancellationToken cancellationToken = default) { @@ -199,7 +199,7 @@ public virtual Response GetTenantParentWithNon /// An object representing collection of TenantParentWithLocResources and their operations over a TenantParentWithLocResource. public virtual TenantParentWithLocCollection GetTenantParentWithLocs() { - return GetCachedClient(Client => new TenantParentWithLocCollection(Client, Id)); + return GetCachedClient(client => new TenantParentWithLocCollection(client, Id)); } /// @@ -217,8 +217,8 @@ public virtual TenantParentWithLocCollection GetTenantParentWithLocs() /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetTenantParentWithLocAsync(string tenantParentWithLocName, CancellationToken cancellationToken = default) { @@ -240,8 +240,8 @@ public virtual async Task> GetTenantParent /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetTenantParentWithLoc(string tenantParentWithLocName, CancellationToken cancellationToken = default) { @@ -252,7 +252,7 @@ public virtual Response GetTenantParentWithLoc(stri /// An object representing collection of TenantParentResources and their operations over a TenantParentResource. public virtual TenantParentCollection GetTenantParents() { - return GetCachedClient(Client => new TenantParentCollection(Client, Id)); + return GetCachedClient(client => new TenantParentCollection(client, Id)); } /// @@ -270,8 +270,8 @@ public virtual TenantParentCollection GetTenantParents() /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetTenantParentAsync(string tenantParentName, CancellationToken cancellationToken = default) { @@ -293,8 +293,8 @@ public virtual async Task> GetTenantParentAsync(s /// /// Name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetTenantParent(string tenantParentName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/ArmResourceExtensionClient.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/ArmResourceExtensionClient.cs deleted file mode 100644 index 256624732ec..00000000000 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/ArmResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtMockAndSample -{ - /// A class to add extension methods to ArmResource. - internal partial class ArmResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ArmResourceExtensionClient() - { - } - - /// 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 ArmResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of RoleAssignmentResources in the ArmResource. - /// An object representing collection of RoleAssignmentResources and their operations over a RoleAssignmentResource. - public virtual RoleAssignmentCollection GetRoleAssignments() - { - return GetCachedClient(Client => new RoleAssignmentCollection(Client, Id)); - } - - /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. - /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. - public virtual GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments() - { - return GetCachedClient(Client => new GuestConfigurationAssignmentCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MgmtMockAndSampleExtensions.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MgmtMockAndSampleExtensions.cs index 59482a55a77..79d394ab8fa 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MgmtMockAndSampleExtensions.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MgmtMockAndSampleExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtMockAndSample.Mocking; using MgmtMockAndSample.Models; namespace MgmtMockAndSample @@ -19,312 +20,381 @@ namespace MgmtMockAndSample /// A class to add extension methods to MgmtMockAndSample. public static partial class MgmtMockAndSampleExtensions { - private static ArmResourceExtensionClient GetArmResourceExtensionClient(ArmResource resource) + private static MockableMgmtMockAndSampleArmClient GetMockableMgmtMockAndSampleArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ArmResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtMockAndSampleArmClient(client0)); } - private static ArmResourceExtensionClient GetArmResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtMockAndSampleArmResource GetMockableMgmtMockAndSampleArmResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ArmResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtMockAndSampleArmResource(client, resource.Id)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtMockAndSampleResourceGroupResource GetMockableMgmtMockAndSampleResourceGroupResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtMockAndSampleResourceGroupResource(client, resource.Id)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtMockAndSampleSubscriptionResource GetMockableMgmtMockAndSampleSubscriptionResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtMockAndSampleSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtMockAndSampleTenantResource GetMockableMgmtMockAndSampleTenantResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtMockAndSampleTenantResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + /// + /// Gets a collection of RoleAssignmentResources 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. + /// An object representing collection of RoleAssignmentResources and their operations over a RoleAssignmentResource. + public static RoleAssignmentCollection GetRoleAssignments(this ArmClient client, ResourceIdentifier scope) { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); + return GetMockableMgmtMockAndSampleArmClient(client).GetRoleAssignments(scope); } - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmResource resource) + /// + /// Get the specified role assignment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} + /// + /// + /// Operation Id + /// RoleAssignments_Get + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the role assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetRoleAssignmentAsync(this ArmClient client, ResourceIdentifier scope, string roleAssignmentName, CancellationToken cancellationToken = default) { - return resource.GetCachedClient(client => - { - return new TenantResourceExtensionClient(client, resource.Id); - }); + return await GetMockableMgmtMockAndSampleArmClient(client).GetRoleAssignmentAsync(scope, roleAssignmentName, cancellationToken).ConfigureAwait(false); } - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + /// + /// Get the specified role assignment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} + /// + /// + /// Operation Id + /// RoleAssignments_Get + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The scope that the resource will apply against. + /// The name of the role assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetRoleAssignment(this ArmClient client, ResourceIdentifier scope, string roleAssignmentName, CancellationToken cancellationToken = default) + { + return GetMockableMgmtMockAndSampleArmClient(client).GetRoleAssignment(scope, roleAssignmentName, cancellationToken); + } + + /// + /// Gets a collection of GuestConfigurationAssignmentResources 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.Compute/virtualMachines. + /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. + public static GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(this ArmClient client, ResourceIdentifier scope) + { + return GetMockableMgmtMockAndSampleArmClient(client).GetGuestConfigurationAssignments(scope); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// 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.Compute/virtualMachines. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetGuestConfigurationAssignmentAsync(this ArmClient client, ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return await GetMockableMgmtMockAndSampleArmClient(client).GetGuestConfigurationAssignmentAsync(scope, guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// 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.Compute/virtualMachines. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetGuestConfigurationAssignment(this ArmClient client, ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) { - return client.GetResourceClient(() => - { - return new TenantResourceExtensionClient(client, scope); - }); + return GetMockableMgmtMockAndSampleArmClient(client).GetGuestConfigurationAssignment(scope, guestConfigurationAssignmentName, cancellationToken); } - #region VaultResource + /// /// 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. /// Returns a object. public static VaultResource GetVaultResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VaultResource.ValidateResourceId(id); - return new VaultResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetVaultResource(id); } - #endregion - #region DeletedVaultResource /// /// 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. /// Returns a object. public static DeletedVaultResource GetDeletedVaultResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DeletedVaultResource.ValidateResourceId(id); - return new DeletedVaultResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetDeletedVaultResource(id); } - #endregion - #region MgmtMockAndSamplePrivateEndpointConnectionResource /// /// 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. /// Returns a object. public static MgmtMockAndSamplePrivateEndpointConnectionResource GetMgmtMockAndSamplePrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MgmtMockAndSamplePrivateEndpointConnectionResource.ValidateResourceId(id); - return new MgmtMockAndSamplePrivateEndpointConnectionResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetMgmtMockAndSamplePrivateEndpointConnectionResource(id); } - #endregion - #region VirtualMachineExtensionImageResource /// /// 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. /// Returns a object. public static VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineExtensionImageResource.ValidateResourceId(id); - return new VirtualMachineExtensionImageResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetVirtualMachineExtensionImageResource(id); } - #endregion - #region DiskEncryptionSetResource /// /// 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. /// Returns a object. public static DiskEncryptionSetResource GetDiskEncryptionSetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DiskEncryptionSetResource.ValidateResourceId(id); - return new DiskEncryptionSetResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetDiskEncryptionSetResource(id); } - #endregion - #region ManagedHsmResource /// /// 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. /// Returns a object. public static ManagedHsmResource GetManagedHsmResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ManagedHsmResource.ValidateResourceId(id); - return new ManagedHsmResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetManagedHsmResource(id); } - #endregion - #region DeletedManagedHsmResource /// /// 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. /// Returns a object. public static DeletedManagedHsmResource GetDeletedManagedHsmResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DeletedManagedHsmResource.ValidateResourceId(id); - return new DeletedManagedHsmResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetDeletedManagedHsmResource(id); } - #endregion - #region MhsmPrivateEndpointConnectionResource /// /// 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. /// Returns a object. public static MhsmPrivateEndpointConnectionResource GetMhsmPrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MhsmPrivateEndpointConnectionResource.ValidateResourceId(id); - return new MhsmPrivateEndpointConnectionResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetMhsmPrivateEndpointConnectionResource(id); } - #endregion - #region FirewallPolicyResource /// /// 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. /// Returns a object. public static FirewallPolicyResource GetFirewallPolicyResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FirewallPolicyResource.ValidateResourceId(id); - return new FirewallPolicyResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetFirewallPolicyResource(id); } - #endregion - #region FirewallPolicyRuleCollectionGroupResource /// /// 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. /// Returns a object. public static FirewallPolicyRuleCollectionGroupResource GetFirewallPolicyRuleCollectionGroupResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FirewallPolicyRuleCollectionGroupResource.ValidateResourceId(id); - return new FirewallPolicyRuleCollectionGroupResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetFirewallPolicyRuleCollectionGroupResource(id); } - #endregion - #region RoleAssignmentResource /// /// 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. /// Returns a object. public static RoleAssignmentResource GetRoleAssignmentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - RoleAssignmentResource.ValidateResourceId(id); - return new RoleAssignmentResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetRoleAssignmentResource(id); } - #endregion - #region GuestConfigurationAssignmentResource /// /// 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. /// Returns a object. public static GuestConfigurationAssignmentResource GetGuestConfigurationAssignmentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - GuestConfigurationAssignmentResource.ValidateResourceId(id); - return new GuestConfigurationAssignmentResource(client, id); - } - ); + return GetMockableMgmtMockAndSampleArmClient(client).GetGuestConfigurationAssignmentResource(id); } - #endregion - /// Gets a collection of RoleAssignmentResources in the ArmResource. + /// + /// Gets a collection of RoleAssignmentResources in the ArmResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of RoleAssignmentResources and their operations over a RoleAssignmentResource. public static RoleAssignmentCollection GetRoleAssignments(this ArmResource armResource) { - return GetArmResourceExtensionClient(armResource).GetRoleAssignments(); - } - - /// Gets a collection of RoleAssignmentResources in the ArmResource. - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// An object representing collection of RoleAssignmentResources and their operations over a RoleAssignmentResource. - public static RoleAssignmentCollection GetRoleAssignments(this ArmClient client, ResourceIdentifier scope) - { - return GetArmResourceExtensionClient(client, scope).GetRoleAssignments(); + return GetMockableMgmtMockAndSampleArmResource(armResource).GetRoleAssignments(); } /// @@ -339,16 +409,20 @@ public static RoleAssignmentCollection GetRoleAssignments(this ArmClient client, /// RoleAssignments_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the role assignment to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetRoleAssignmentAsync(this ArmResource armResource, string roleAssignmentName, CancellationToken cancellationToken = default) { - return await armResource.GetRoleAssignments().GetAsync(roleAssignmentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleArmResource(armResource).GetRoleAssignmentAsync(roleAssignmentName, cancellationToken).ConfigureAwait(false); } /// @@ -363,145 +437,34 @@ public static async Task> GetRoleAssignmentAsyn /// RoleAssignments_Get /// /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// The name of the role assignment to get. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static async Task> GetRoleAssignmentAsync(this ArmClient client, ResourceIdentifier scope, string roleAssignmentName, CancellationToken cancellationToken = default) - { - return await client.GetRoleAssignments(scope).GetAsync(roleAssignmentName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get the specified role assignment. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} - /// /// - /// Operation Id - /// RoleAssignments_Get + /// Mocking + /// To mock this method, please mock instead. /// - /// /// /// The instance the method will execute against. /// The name of the role assignment to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. - [ForwardsClientCalls] - public static Response GetRoleAssignment(this ArmResource armResource, string roleAssignmentName, CancellationToken cancellationToken = default) - { - return armResource.GetRoleAssignments().Get(roleAssignmentName, cancellationToken); - } - - /// - /// Get the specified role assignment. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} - /// - /// - /// Operation Id - /// RoleAssignments_Get - /// - /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. - /// The name of the role assignment to get. - /// The cancellation token to use. /// is an empty string, and was expected to be non-empty. - /// is null. [ForwardsClientCalls] - public static Response GetRoleAssignment(this ArmClient client, ResourceIdentifier scope, string roleAssignmentName, CancellationToken cancellationToken = default) - { - return client.GetRoleAssignments(scope).Get(roleAssignmentName, cancellationToken); - } - - /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. - /// The instance the method will execute against. - /// The scope that the resource will apply against. Expected resource type includes the following: Microsoft.Compute/virtualMachines. - /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. - public static GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(this ArmClient client, ResourceIdentifier scope) + public static Response GetRoleAssignment(this ArmResource armResource, string roleAssignmentName, CancellationToken cancellationToken = default) { - if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) - { - throw new ArgumentException(string.Format("Invalid resource type {0} expected Microsoft.Compute/virtualMachines", scope.ResourceType)); - } - return GetArmResourceExtensionClient(client, scope).GetGuestConfigurationAssignments(); + return GetMockableMgmtMockAndSampleArmResource(armResource).GetRoleAssignment(roleAssignmentName, cancellationToken); } /// - /// Get information about a guest configuration assignment - /// + /// Gets a collection of VaultResources in the ResourceGroupResource. /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} - /// - /// - /// Operation Id - /// GuestConfigurationAssignments_Get + /// 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.Compute/virtualMachines. - /// The guest configuration assignment name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static async Task> GetGuestConfigurationAssignmentAsync(this ArmClient client, ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) - { - if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) - { - throw new ArgumentException(string.Format("Invalid resource type {0} expected Microsoft.Compute/virtualMachines", scope.ResourceType)); - } - return await client.GetGuestConfigurationAssignments(scope).GetAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get information about a guest configuration assignment - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} - /// - /// - /// Operation Id - /// GuestConfigurationAssignments_Get - /// - /// - /// - /// The instance the method will execute against. - /// The scope that the resource will apply against. Expected resource type includes the following: Microsoft.Compute/virtualMachines. - /// The guest configuration assignment name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static Response GetGuestConfigurationAssignment(this ArmClient client, ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) - { - if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) - { - throw new ArgumentException(string.Format("Invalid resource type {0} expected Microsoft.Compute/virtualMachines", scope.ResourceType)); - } - return client.GetGuestConfigurationAssignments(scope).Get(guestConfigurationAssignmentName, cancellationToken); - } - - /// Gets a collection of VaultResources in the ResourceGroupResource. /// The instance the method will execute against. /// An object representing collection of VaultResources and their operations over a VaultResource. public static VaultCollection GetVaults(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVaults(); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetVaults(); } /// @@ -516,16 +479,20 @@ public static VaultCollection GetVaults(this ResourceGroupResource resourceGroup /// Vaults_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the vault. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVaultAsync(this ResourceGroupResource resourceGroupResource, string vaultName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVaults().GetAsync(vaultName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetVaultAsync(vaultName, cancellationToken).ConfigureAwait(false); } /// @@ -540,24 +507,34 @@ public static async Task> GetVaultAsync(this ResourceGro /// Vaults_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the vault. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVault(this ResourceGroupResource resourceGroupResource, string vaultName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVaults().Get(vaultName, cancellationToken); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetVault(vaultName, cancellationToken); } - /// Gets a collection of DiskEncryptionSetResources in the ResourceGroupResource. + /// + /// Gets a collection of DiskEncryptionSetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DiskEncryptionSetResources and their operations over a DiskEncryptionSetResource. public static DiskEncryptionSetCollection GetDiskEncryptionSets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDiskEncryptionSets(); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetDiskEncryptionSets(); } /// @@ -572,16 +549,20 @@ public static DiskEncryptionSetCollection GetDiskEncryptionSets(this ResourceGro /// DiskEncryptionSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the disk encryption set that is being created. The name can't be changed after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDiskEncryptionSetAsync(this ResourceGroupResource resourceGroupResource, string diskEncryptionSetName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDiskEncryptionSets().GetAsync(diskEncryptionSetName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetDiskEncryptionSetAsync(diskEncryptionSetName, cancellationToken).ConfigureAwait(false); } /// @@ -596,24 +577,34 @@ public static async Task> GetDiskEncryptionS /// DiskEncryptionSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the disk encryption set that is being created. The name can't be changed after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDiskEncryptionSet(this ResourceGroupResource resourceGroupResource, string diskEncryptionSetName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDiskEncryptionSets().Get(diskEncryptionSetName, cancellationToken); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetDiskEncryptionSet(diskEncryptionSetName, cancellationToken); } - /// Gets a collection of ManagedHsmResources in the ResourceGroupResource. + /// + /// Gets a collection of ManagedHsmResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ManagedHsmResources and their operations over a ManagedHsmResource. public static ManagedHsmCollection GetManagedHsms(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetManagedHsms(); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetManagedHsms(); } /// @@ -628,16 +619,20 @@ public static ManagedHsmCollection GetManagedHsms(this ResourceGroupResource res /// ManagedHsms_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the managed HSM Pool. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetManagedHsmAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetManagedHsms().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetManagedHsmAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -652,24 +647,34 @@ public static async Task> GetManagedHsmAsync(this R /// ManagedHsms_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the managed HSM Pool. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetManagedHsm(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetManagedHsms().Get(name, cancellationToken); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetManagedHsm(name, cancellationToken); } - /// Gets a collection of FirewallPolicyResources in the ResourceGroupResource. + /// + /// Gets a collection of FirewallPolicyResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of FirewallPolicyResources and their operations over a FirewallPolicyResource. public static FirewallPolicyCollection GetFirewallPolicies(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetFirewallPolicies(); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetFirewallPolicies(); } /// @@ -684,17 +689,21 @@ public static FirewallPolicyCollection GetFirewallPolicies(this ResourceGroupRes /// FirewallPolicies_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the Firewall Policy. /// Expands referenced resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetFirewallPolicyAsync(this ResourceGroupResource resourceGroupResource, string firewallPolicyName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetFirewallPolicies().GetAsync(firewallPolicyName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetFirewallPolicyAsync(firewallPolicyName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -709,25 +718,35 @@ public static async Task> GetFirewallPolicyAsyn /// FirewallPolicies_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the Firewall Policy. /// Expands referenced resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetFirewallPolicy(this ResourceGroupResource resourceGroupResource, string firewallPolicyName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetFirewallPolicies().Get(firewallPolicyName, expand, cancellationToken); + return GetMockableMgmtMockAndSampleResourceGroupResource(resourceGroupResource).GetFirewallPolicy(firewallPolicyName, expand, cancellationToken); } - /// Gets a collection of DeletedVaultResources in the SubscriptionResource. + /// + /// Gets a collection of DeletedVaultResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeletedVaultResources and their operations over a DeletedVaultResource. public static DeletedVaultCollection GetDeletedVaults(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedVaults(); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedVaults(); } /// @@ -742,17 +761,21 @@ public static DeletedVaultCollection GetDeletedVaults(this SubscriptionResource /// Vaults_GetDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the deleted vault. /// The name of the vault. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeletedVaultAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string vaultName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetDeletedVaults().GetAsync(location, vaultName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedVaultAsync(location, vaultName, cancellationToken).ConfigureAwait(false); } /// @@ -767,31 +790,39 @@ public static async Task> GetDeletedVaultAsync(th /// Vaults_GetDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the deleted vault. /// The name of the vault. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeletedVault(this SubscriptionResource subscriptionResource, AzureLocation location, string vaultName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetDeletedVaults().Get(location, vaultName, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedVault(location, vaultName, cancellationToken); } - /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// The name of a supported Azure region. /// The String to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); } /// @@ -806,6 +837,10 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -813,12 +848,12 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// The String to use. /// The String to use. /// The cancellation token to use. - /// , or is an empty string, and was expected to be non-empty. /// , or is null. + /// , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineExtensionImageAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImageAsync(location, publisherName, type, version, cancellationToken).ConfigureAwait(false); } /// @@ -833,6 +868,10 @@ public static async Task> GetVirt /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -840,20 +879,26 @@ public static async Task> GetVirt /// The String to use. /// The String to use. /// The cancellation token to use. - /// , or is an empty string, and was expected to be non-empty. /// , or is null. + /// , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineExtensionImage(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImage(location, publisherName, type, version, cancellationToken); } - /// Gets a collection of DeletedManagedHsmResources in the SubscriptionResource. + /// + /// Gets a collection of DeletedManagedHsmResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeletedManagedHsmResources and their operations over a DeletedManagedHsmResource. public static DeletedManagedHsmCollection GetDeletedManagedHsms(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedManagedHsms(); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedManagedHsms(); } /// @@ -868,17 +913,21 @@ public static DeletedManagedHsmCollection GetDeletedManagedHsms(this Subscriptio /// ManagedHsms_GetDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the deleted managed HSM. /// The name of the deleted managed HSM. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeletedManagedHsmAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string name, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetDeletedManagedHsms().GetAsync(location, name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedManagedHsmAsync(location, name, cancellationToken).ConfigureAwait(false); } /// @@ -893,17 +942,21 @@ public static async Task> GetDeletedManagedH /// ManagedHsms_GetDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The location of the deleted managed HSM. /// The name of the deleted managed HSM. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeletedManagedHsm(this SubscriptionResource subscriptionResource, AzureLocation location, string name, CancellationToken cancellationToken = default) { - return subscriptionResource.GetDeletedManagedHsms().Get(location, name, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedManagedHsm(location, name, cancellationToken); } /// @@ -918,6 +971,10 @@ public static Response GetDeletedManagedHsm(this Subs /// Vaults_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Maximum number of results to return. @@ -925,7 +982,7 @@ public static Response GetDeletedManagedHsm(this Subs /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetVaultsAsync(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVaultsAsync(top, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetVaultsAsync(top, cancellationToken); } /// @@ -940,6 +997,10 @@ public static AsyncPageable GetVaultsAsync(this SubscriptionResou /// Vaults_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Maximum number of results to return. @@ -947,7 +1008,7 @@ public static AsyncPageable GetVaultsAsync(this SubscriptionResou /// A collection of that may take multiple service requests to iterate over. public static Pageable GetVaults(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVaults(top, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetVaults(top, cancellationToken); } /// @@ -962,13 +1023,17 @@ public static Pageable GetVaults(this SubscriptionResource subscr /// Vaults_ListDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetDeletedVaultsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedVaultsAsync(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedVaultsAsync(cancellationToken); } /// @@ -983,13 +1048,17 @@ public static AsyncPageable GetDeletedVaultsAsync(this Sub /// Vaults_ListDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetDeletedVaults(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedVaults(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedVaults(cancellationToken); } /// @@ -1004,6 +1073,10 @@ public static Pageable GetDeletedVaults(this SubscriptionR /// Vaults_CheckNameAvailability /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the vault. @@ -1011,9 +1084,7 @@ public static Pageable GetDeletedVaults(this SubscriptionR /// is null. public static async Task> CheckNameAvailabilityVaultAsync(this SubscriptionResource subscriptionResource, VaultCheckNameAvailabilityContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return await GetSubscriptionResourceExtensionClient(subscriptionResource).CheckNameAvailabilityVaultAsync(content, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).CheckNameAvailabilityVaultAsync(content, cancellationToken).ConfigureAwait(false); } /// @@ -1028,6 +1099,10 @@ public static async Task> CheckNameAvailab /// Vaults_CheckNameAvailability /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the vault. @@ -1035,9 +1110,7 @@ public static async Task> CheckNameAvailab /// is null. public static Response CheckNameAvailabilityVault(this SubscriptionResource subscriptionResource, VaultCheckNameAvailabilityContent content, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).CheckNameAvailabilityVault(content, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).CheckNameAvailabilityVault(content, cancellationToken); } /// @@ -1052,13 +1125,17 @@ public static Response CheckNameAvailabilityVault(t /// DiskEncryptionSets_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetDiskEncryptionSetsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDiskEncryptionSetsAsync(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDiskEncryptionSetsAsync(cancellationToken); } /// @@ -1073,13 +1150,17 @@ public static AsyncPageable GetDiskEncryptionSetsAsyn /// DiskEncryptionSets_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetDiskEncryptionSets(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDiskEncryptionSets(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDiskEncryptionSets(cancellationToken); } /// @@ -1094,6 +1175,10 @@ public static Pageable GetDiskEncryptionSets(this Sub /// ManagedHsms_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Maximum number of results to return. @@ -1101,7 +1186,7 @@ public static Pageable GetDiskEncryptionSets(this Sub /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetManagedHsmsAsync(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetManagedHsmsAsync(top, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetManagedHsmsAsync(top, cancellationToken); } /// @@ -1116,6 +1201,10 @@ public static AsyncPageable GetManagedHsmsAsync(this Subscri /// ManagedHsms_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Maximum number of results to return. @@ -1123,7 +1212,7 @@ public static AsyncPageable GetManagedHsmsAsync(this Subscri /// A collection of that may take multiple service requests to iterate over. public static Pageable GetManagedHsms(this SubscriptionResource subscriptionResource, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetManagedHsms(top, cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetManagedHsms(top, cancellationToken); } /// @@ -1138,13 +1227,17 @@ public static Pageable GetManagedHsms(this SubscriptionResou /// ManagedHsms_ListDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetDeletedManagedHsmsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedManagedHsmsAsync(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedManagedHsmsAsync(cancellationToken); } /// @@ -1159,13 +1252,17 @@ public static AsyncPageable GetDeletedManagedHsmsAsyn /// ManagedHsms_ListDeleted /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetDeletedManagedHsms(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeletedManagedHsms(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetDeletedManagedHsms(cancellationToken); } /// @@ -1180,13 +1277,17 @@ public static Pageable GetDeletedManagedHsms(this Sub /// FirewallPolicies_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFirewallPoliciesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFirewallPoliciesAsync(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetFirewallPoliciesAsync(cancellationToken); } /// @@ -1201,13 +1302,17 @@ public static AsyncPageable GetFirewallPoliciesAsync(thi /// FirewallPolicies_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFirewallPolicies(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFirewallPolicies(cancellationToken); + return GetMockableMgmtMockAndSampleSubscriptionResource(subscriptionResource).GetFirewallPolicies(cancellationToken); } /// @@ -1222,6 +1327,10 @@ public static Pageable GetFirewallPolicies(this Subscrip /// TenantActivityLogs_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. @@ -1230,7 +1339,7 @@ public static Pageable GetFirewallPolicies(this Subscrip /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTenantActivityLogsAsync(this TenantResource tenantResource, string filter = null, string select = null, CancellationToken cancellationToken = default) { - return GetTenantResourceExtensionClient(tenantResource).GetTenantActivityLogsAsync(filter, select, cancellationToken); + return GetMockableMgmtMockAndSampleTenantResource(tenantResource).GetTenantActivityLogsAsync(filter, select, cancellationToken); } /// @@ -1245,6 +1354,10 @@ public static AsyncPageable GetTenantActivityLogsAsync(this TenantRes /// TenantActivityLogs_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Reduces the set of data collected. <br>The **$filter** is very restricted and allows only the following patterns.<br>- List events for a resource group: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceGroupName eq '<ResourceGroupName>'.<br>- List events for resource: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceUri eq '<ResourceURI>'.<br>- List events for a subscription: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation'.<br>- List events for a resource provider: $filter=eventTimestamp ge '<Start Time>' and eventTimestamp le '<End Time>' and eventChannels eq 'Admin, Operation' and resourceProvider eq '<ResourceProviderName>'.<br>- List events for a correlation Id: api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq '<CorrelationID>'.<br>**NOTE**: No other syntax is allowed. @@ -1253,7 +1366,7 @@ public static AsyncPageable GetTenantActivityLogsAsync(this TenantRes /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTenantActivityLogs(this TenantResource tenantResource, string filter = null, string select = null, CancellationToken cancellationToken = default) { - return GetTenantResourceExtensionClient(tenantResource).GetTenantActivityLogs(filter, select, cancellationToken); + return GetMockableMgmtMockAndSampleTenantResource(tenantResource).GetTenantActivityLogs(filter, select, cancellationToken); } /// @@ -1268,6 +1381,10 @@ public static Pageable GetTenantActivityLogs(this TenantResource tena /// Deployments_CalculateTemplateHash /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The template provided to calculate hash. @@ -1275,9 +1392,7 @@ public static Pageable GetTenantActivityLogs(this TenantResource tena /// is null. public static async Task> CalculateTemplateHashDeploymentAsync(this TenantResource tenantResource, BinaryData template, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(template, nameof(template)); - - return await GetTenantResourceExtensionClient(tenantResource).CalculateTemplateHashDeploymentAsync(template, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMockAndSampleTenantResource(tenantResource).CalculateTemplateHashDeploymentAsync(template, cancellationToken).ConfigureAwait(false); } /// @@ -1292,6 +1407,10 @@ public static async Task> CalculateTemplateHashDepl /// Deployments_CalculateTemplateHash /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The template provided to calculate hash. @@ -1299,9 +1418,7 @@ public static async Task> CalculateTemplateHashDepl /// is null. public static Response CalculateTemplateHashDeployment(this TenantResource tenantResource, BinaryData template, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(template, nameof(template)); - - return GetTenantResourceExtensionClient(tenantResource).CalculateTemplateHashDeployment(template, cancellationToken); + return GetMockableMgmtMockAndSampleTenantResource(tenantResource).CalculateTemplateHashDeployment(template, cancellationToken); } } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleArmClient.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleArmClient.cs new file mode 100644 index 00000000000..35a137c8ebe --- /dev/null +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleArmClient.cs @@ -0,0 +1,303 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtMockAndSample; + +namespace MgmtMockAndSample.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtMockAndSampleArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMockAndSampleArmClient() + { + } + + /// 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 MockableMgmtMockAndSampleArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtMockAndSampleArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of RoleAssignmentResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of RoleAssignmentResources and their operations over a RoleAssignmentResource. + public virtual RoleAssignmentCollection GetRoleAssignments(ResourceIdentifier scope) + { + return new RoleAssignmentCollection(Client, scope); + } + + /// + /// Get the specified role assignment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} + /// + /// + /// Operation Id + /// RoleAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the role assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRoleAssignmentAsync(ResourceIdentifier scope, string roleAssignmentName, CancellationToken cancellationToken = default) + { + return await GetRoleAssignments(scope).GetAsync(roleAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the specified role assignment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} + /// + /// + /// Operation Id + /// RoleAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the role assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRoleAssignment(ResourceIdentifier scope, string roleAssignmentName, CancellationToken cancellationToken = default) + { + return GetRoleAssignments(scope).Get(roleAssignmentName, cancellationToken); + } + + /// Gets a collection of GuestConfigurationAssignmentResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. + public virtual GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(ResourceIdentifier scope) + { + if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) + { + throw new ArgumentException(string.Format("Invalid resource type {0}, expected Microsoft.Compute/virtualMachines", scope.ResourceType)); + } + return new GuestConfigurationAssignmentCollection(Client, scope); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetGuestConfigurationAssignmentAsync(ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return await GetGuestConfigurationAssignments(scope).GetAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetGuestConfigurationAssignment(ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return GetGuestConfigurationAssignments(scope).Get(guestConfigurationAssignmentName, 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 VaultResource GetVaultResource(ResourceIdentifier id) + { + VaultResource.ValidateResourceId(id); + return new VaultResource(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 DeletedVaultResource GetDeletedVaultResource(ResourceIdentifier id) + { + DeletedVaultResource.ValidateResourceId(id); + return new DeletedVaultResource(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 MgmtMockAndSamplePrivateEndpointConnectionResource GetMgmtMockAndSamplePrivateEndpointConnectionResource(ResourceIdentifier id) + { + MgmtMockAndSamplePrivateEndpointConnectionResource.ValidateResourceId(id); + return new MgmtMockAndSamplePrivateEndpointConnectionResource(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 VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(ResourceIdentifier id) + { + VirtualMachineExtensionImageResource.ValidateResourceId(id); + return new VirtualMachineExtensionImageResource(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 DiskEncryptionSetResource GetDiskEncryptionSetResource(ResourceIdentifier id) + { + DiskEncryptionSetResource.ValidateResourceId(id); + return new DiskEncryptionSetResource(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 ManagedHsmResource GetManagedHsmResource(ResourceIdentifier id) + { + ManagedHsmResource.ValidateResourceId(id); + return new ManagedHsmResource(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 DeletedManagedHsmResource GetDeletedManagedHsmResource(ResourceIdentifier id) + { + DeletedManagedHsmResource.ValidateResourceId(id); + return new DeletedManagedHsmResource(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 MhsmPrivateEndpointConnectionResource GetMhsmPrivateEndpointConnectionResource(ResourceIdentifier id) + { + MhsmPrivateEndpointConnectionResource.ValidateResourceId(id); + return new MhsmPrivateEndpointConnectionResource(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 FirewallPolicyResource GetFirewallPolicyResource(ResourceIdentifier id) + { + FirewallPolicyResource.ValidateResourceId(id); + return new FirewallPolicyResource(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 FirewallPolicyRuleCollectionGroupResource GetFirewallPolicyRuleCollectionGroupResource(ResourceIdentifier id) + { + FirewallPolicyRuleCollectionGroupResource.ValidateResourceId(id); + return new FirewallPolicyRuleCollectionGroupResource(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 RoleAssignmentResource GetRoleAssignmentResource(ResourceIdentifier id) + { + RoleAssignmentResource.ValidateResourceId(id); + return new RoleAssignmentResource(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 GuestConfigurationAssignmentResource GetGuestConfigurationAssignmentResource(ResourceIdentifier id) + { + GuestConfigurationAssignmentResource.ValidateResourceId(id); + return new GuestConfigurationAssignmentResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleArmResource.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleArmResource.cs new file mode 100644 index 00000000000..adee9a76384 --- /dev/null +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleArmResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtMockAndSample; + +namespace MgmtMockAndSample.Mocking +{ + /// A class to add extension methods to ArmResource. + public partial class MockableMgmtMockAndSampleArmResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMockAndSampleArmResource() + { + } + + /// 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 MockableMgmtMockAndSampleArmResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of RoleAssignmentResources in the ArmResource. + /// An object representing collection of RoleAssignmentResources and their operations over a RoleAssignmentResource. + public virtual RoleAssignmentCollection GetRoleAssignments() + { + return GetCachedClient(client => new RoleAssignmentCollection(client, Id)); + } + + /// + /// Get the specified role assignment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} + /// + /// + /// Operation Id + /// RoleAssignments_Get + /// + /// + /// + /// The name of the role assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetRoleAssignmentAsync(string roleAssignmentName, CancellationToken cancellationToken = default) + { + return await GetRoleAssignments().GetAsync(roleAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get the specified role assignment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName} + /// + /// + /// Operation Id + /// RoleAssignments_Get + /// + /// + /// + /// The name of the role assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetRoleAssignment(string roleAssignmentName, CancellationToken cancellationToken = default) + { + return GetRoleAssignments().Get(roleAssignmentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleResourceGroupResource.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleResourceGroupResource.cs new file mode 100644 index 00000000000..b8fe3d2eafc --- /dev/null +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleResourceGroupResource.cs @@ -0,0 +1,253 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtMockAndSample; + +namespace MgmtMockAndSample.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtMockAndSampleResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMockAndSampleResourceGroupResource() + { + } + + /// 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 MockableMgmtMockAndSampleResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of VaultResources in the ResourceGroupResource. + /// An object representing collection of VaultResources and their operations over a VaultResource. + public virtual VaultCollection GetVaults() + { + return GetCachedClient(client => new VaultCollection(client, Id)); + } + + /// + /// Gets the specified Azure key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName} + /// + /// + /// Operation Id + /// Vaults_Get + /// + /// + /// + /// The name of the vault. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVaultAsync(string vaultName, CancellationToken cancellationToken = default) + { + return await GetVaults().GetAsync(vaultName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Azure key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName} + /// + /// + /// Operation Id + /// Vaults_Get + /// + /// + /// + /// The name of the vault. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVault(string vaultName, CancellationToken cancellationToken = default) + { + return GetVaults().Get(vaultName, cancellationToken); + } + + /// Gets a collection of DiskEncryptionSetResources in the ResourceGroupResource. + /// An object representing collection of DiskEncryptionSetResources and their operations over a DiskEncryptionSetResource. + public virtual DiskEncryptionSetCollection GetDiskEncryptionSets() + { + return GetCachedClient(client => new DiskEncryptionSetCollection(client, Id)); + } + + /// + /// Gets information about a disk encryption set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName} + /// + /// + /// Operation Id + /// DiskEncryptionSets_Get + /// + /// + /// + /// The name of the disk encryption set that is being created. The name can't be changed after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDiskEncryptionSetAsync(string diskEncryptionSetName, CancellationToken cancellationToken = default) + { + return await GetDiskEncryptionSets().GetAsync(diskEncryptionSetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets information about a disk encryption set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName} + /// + /// + /// Operation Id + /// DiskEncryptionSets_Get + /// + /// + /// + /// The name of the disk encryption set that is being created. The name can't be changed after the disk encryption set is created. Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDiskEncryptionSet(string diskEncryptionSetName, CancellationToken cancellationToken = default) + { + return GetDiskEncryptionSets().Get(diskEncryptionSetName, cancellationToken); + } + + /// Gets a collection of ManagedHsmResources in the ResourceGroupResource. + /// An object representing collection of ManagedHsmResources and their operations over a ManagedHsmResource. + public virtual ManagedHsmCollection GetManagedHsms() + { + return GetCachedClient(client => new ManagedHsmCollection(client, Id)); + } + + /// + /// Gets the specified managed HSM Pool. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name} + /// + /// + /// Operation Id + /// ManagedHsms_Get + /// + /// + /// + /// The name of the managed HSM Pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetManagedHsmAsync(string name, CancellationToken cancellationToken = default) + { + return await GetManagedHsms().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified managed HSM Pool. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/managedHSMs/{name} + /// + /// + /// Operation Id + /// ManagedHsms_Get + /// + /// + /// + /// The name of the managed HSM Pool. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetManagedHsm(string name, CancellationToken cancellationToken = default) + { + return GetManagedHsms().Get(name, cancellationToken); + } + + /// Gets a collection of FirewallPolicyResources in the ResourceGroupResource. + /// An object representing collection of FirewallPolicyResources and their operations over a FirewallPolicyResource. + public virtual FirewallPolicyCollection GetFirewallPolicies() + { + return GetCachedClient(client => new FirewallPolicyCollection(client, Id)); + } + + /// + /// Gets the specified Firewall Policy. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/firewallPolicies/{firewallPolicyName} + /// + /// + /// Operation Id + /// FirewallPolicies_Get + /// + /// + /// + /// The name of the Firewall Policy. + /// Expands referenced resources. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetFirewallPolicyAsync(string firewallPolicyName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetFirewallPolicies().GetAsync(firewallPolicyName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified Firewall Policy. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/firewallPolicies/{firewallPolicyName} + /// + /// + /// Operation Id + /// FirewallPolicies_Get + /// + /// + /// + /// The name of the Firewall Policy. + /// Expands referenced resources. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetFirewallPolicy(string firewallPolicyName, string expand = null, CancellationToken cancellationToken = default) + { + return GetFirewallPolicies().Get(firewallPolicyName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleSubscriptionResource.cs similarity index 68% rename from test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleSubscriptionResource.cs index ae3b105d56a..279c2ecbcc9 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleSubscriptionResource.cs @@ -13,12 +13,13 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtMockAndSample; using MgmtMockAndSample.Models; -namespace MgmtMockAndSample +namespace MgmtMockAndSample.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtMockAndSampleSubscriptionResource : ArmResource { private ClientDiagnostics _vaultClientDiagnostics; private VaultsRestOperations _vaultRestClient; @@ -33,15 +34,15 @@ internal partial class SubscriptionResourceExtensionClient : ArmResource private ClientDiagnostics _firewallPolicyClientDiagnostics; private FirewallPoliciesRestOperations _firewallPolicyRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMockAndSampleSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtMockAndSampleSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -68,23 +69,173 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of DeletedVaultResources and their operations over a DeletedVaultResource. public virtual DeletedVaultCollection GetDeletedVaults() { - return GetCachedClient(Client => new DeletedVaultCollection(Client, Id)); + return GetCachedClient(client => new DeletedVaultCollection(client, Id)); + } + + /// + /// Gets the deleted Azure key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName} + /// + /// + /// Operation Id + /// Vaults_GetDeleted + /// + /// + /// + /// The location of the deleted vault. + /// The name of the vault. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeletedVaultAsync(AzureLocation location, string vaultName, CancellationToken cancellationToken = default) + { + return await GetDeletedVaults().GetAsync(location, vaultName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the deleted Azure key vault. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName} + /// + /// + /// Operation Id + /// Vaults_GetDeleted + /// + /// + /// + /// The location of the deleted vault. + /// The name of the vault. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeletedVault(AzureLocation location, string vaultName, CancellationToken cancellationToken = default) + { + return GetDeletedVaults().Get(location, vaultName, cancellationToken); } /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. /// The name of a supported Azure region. /// The String to use. + /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public virtual VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(AzureLocation location, string publisherName) { return new VirtualMachineExtensionImageCollection(Client, Id, location, publisherName); } + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineExtensionImageAsync(AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineExtensionImage(AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + } + /// Gets a collection of DeletedManagedHsmResources in the SubscriptionResource. /// An object representing collection of DeletedManagedHsmResources and their operations over a DeletedManagedHsmResource. public virtual DeletedManagedHsmCollection GetDeletedManagedHsms() { - return GetCachedClient(Client => new DeletedManagedHsmCollection(Client, Id)); + return GetCachedClient(client => new DeletedManagedHsmCollection(client, Id)); + } + + /// + /// Gets the specified deleted managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name} + /// + /// + /// Operation Id + /// ManagedHsms_GetDeleted + /// + /// + /// + /// The location of the deleted managed HSM. + /// The name of the deleted managed HSM. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeletedManagedHsmAsync(AzureLocation location, string name, CancellationToken cancellationToken = default) + { + return await GetDeletedManagedHsms().GetAsync(location, name, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified deleted managed HSM. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedManagedHSMs/{name} + /// + /// + /// Operation Id + /// ManagedHsms_GetDeleted + /// + /// + /// + /// The location of the deleted managed HSM. + /// The name of the deleted managed HSM. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeletedManagedHsm(AzureLocation location, string name, CancellationToken cancellationToken = default) + { + return GetDeletedManagedHsms().Get(location, name, cancellationToken); } /// @@ -107,7 +258,7 @@ public virtual AsyncPageable GetVaultsAsync(int? top = null, Canc { HttpMessage FirstPageRequest(int? pageSizeHint) => VaultRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VaultRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultResource(Client, VaultData.DeserializeVaultData(e)), VaultClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVaults", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new VaultResource(Client, VaultData.DeserializeVaultData(e)), VaultClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetVaults", "value", "nextLink", cancellationToken); } /// @@ -130,7 +281,7 @@ public virtual Pageable GetVaults(int? top = null, CancellationTo { HttpMessage FirstPageRequest(int? pageSizeHint) => VaultRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VaultRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultResource(Client, VaultData.DeserializeVaultData(e)), VaultClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetVaults", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new VaultResource(Client, VaultData.DeserializeVaultData(e)), VaultClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetVaults", "value", "nextLink", cancellationToken); } /// @@ -152,7 +303,7 @@ public virtual AsyncPageable GetDeletedVaultsAsync(Cancell { HttpMessage FirstPageRequest(int? pageSizeHint) => VaultsRestClient.CreateListDeletedRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VaultsRestClient.CreateListDeletedNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeletedVaultResource(Client, DeletedVaultData.DeserializeDeletedVaultData(e)), VaultsClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDeletedVaults", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeletedVaultResource(Client, DeletedVaultData.DeserializeDeletedVaultData(e)), VaultsClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetDeletedVaults", "value", "nextLink", cancellationToken); } /// @@ -174,7 +325,7 @@ public virtual Pageable GetDeletedVaults(CancellationToken { HttpMessage FirstPageRequest(int? pageSizeHint) => VaultsRestClient.CreateListDeletedRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => VaultsRestClient.CreateListDeletedNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeletedVaultResource(Client, DeletedVaultData.DeserializeDeletedVaultData(e)), VaultsClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDeletedVaults", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeletedVaultResource(Client, DeletedVaultData.DeserializeDeletedVaultData(e)), VaultsClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetDeletedVaults", "value", "nextLink", cancellationToken); } /// @@ -192,9 +343,12 @@ public virtual Pageable GetDeletedVaults(CancellationToken /// /// The name of the vault. /// The cancellation token to use. + /// is null. public virtual async Task> CheckNameAvailabilityVaultAsync(VaultCheckNameAvailabilityContent content, CancellationToken cancellationToken = default) { - using var scope = VaultClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.CheckNameAvailabilityVault"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = VaultClientDiagnostics.CreateScope("MockableMgmtMockAndSampleSubscriptionResource.CheckNameAvailabilityVault"); scope.Start(); try { @@ -223,9 +377,12 @@ public virtual async Task> CheckNameAvaila /// /// The name of the vault. /// The cancellation token to use. + /// is null. public virtual Response CheckNameAvailabilityVault(VaultCheckNameAvailabilityContent content, CancellationToken cancellationToken = default) { - using var scope = VaultClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.CheckNameAvailabilityVault"); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = VaultClientDiagnostics.CreateScope("MockableMgmtMockAndSampleSubscriptionResource.CheckNameAvailabilityVault"); scope.Start(); try { @@ -258,7 +415,7 @@ public virtual AsyncPageable GetDiskEncryptionSetsAsy { HttpMessage FirstPageRequest(int? pageSizeHint) => DiskEncryptionSetRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DiskEncryptionSetRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DiskEncryptionSetResource(Client, DiskEncryptionSetData.DeserializeDiskEncryptionSetData(e)), DiskEncryptionSetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDiskEncryptionSets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DiskEncryptionSetResource(Client, DiskEncryptionSetData.DeserializeDiskEncryptionSetData(e)), DiskEncryptionSetClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetDiskEncryptionSets", "value", "nextLink", cancellationToken); } /// @@ -280,7 +437,7 @@ public virtual Pageable GetDiskEncryptionSets(Cancell { HttpMessage FirstPageRequest(int? pageSizeHint) => DiskEncryptionSetRestClient.CreateListRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DiskEncryptionSetRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DiskEncryptionSetResource(Client, DiskEncryptionSetData.DeserializeDiskEncryptionSetData(e)), DiskEncryptionSetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDiskEncryptionSets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DiskEncryptionSetResource(Client, DiskEncryptionSetData.DeserializeDiskEncryptionSetData(e)), DiskEncryptionSetClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetDiskEncryptionSets", "value", "nextLink", cancellationToken); } /// @@ -303,7 +460,7 @@ public virtual AsyncPageable GetManagedHsmsAsync(int? top = { HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedHsmRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedHsmRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedHsmResource(Client, ManagedHsmData.DeserializeManagedHsmData(e)), ManagedHsmClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetManagedHsms", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ManagedHsmResource(Client, ManagedHsmData.DeserializeManagedHsmData(e)), ManagedHsmClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetManagedHsms", "value", "nextLink", cancellationToken); } /// @@ -326,7 +483,7 @@ public virtual Pageable GetManagedHsms(int? top = null, Canc { HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedHsmRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedHsmRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedHsmResource(Client, ManagedHsmData.DeserializeManagedHsmData(e)), ManagedHsmClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetManagedHsms", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ManagedHsmResource(Client, ManagedHsmData.DeserializeManagedHsmData(e)), ManagedHsmClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetManagedHsms", "value", "nextLink", cancellationToken); } /// @@ -348,7 +505,7 @@ public virtual AsyncPageable GetDeletedManagedHsmsAsy { HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedHsmsRestClient.CreateListDeletedRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedHsmsRestClient.CreateListDeletedNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeletedManagedHsmResource(Client, DeletedManagedHsmData.DeserializeDeletedManagedHsmData(e)), ManagedHsmsClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDeletedManagedHsms", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeletedManagedHsmResource(Client, DeletedManagedHsmData.DeserializeDeletedManagedHsmData(e)), ManagedHsmsClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetDeletedManagedHsms", "value", "nextLink", cancellationToken); } /// @@ -370,7 +527,7 @@ public virtual Pageable GetDeletedManagedHsms(Cancell { HttpMessage FirstPageRequest(int? pageSizeHint) => ManagedHsmsRestClient.CreateListDeletedRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ManagedHsmsRestClient.CreateListDeletedNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeletedManagedHsmResource(Client, DeletedManagedHsmData.DeserializeDeletedManagedHsmData(e)), ManagedHsmsClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetDeletedManagedHsms", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeletedManagedHsmResource(Client, DeletedManagedHsmData.DeserializeDeletedManagedHsmData(e)), ManagedHsmsClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetDeletedManagedHsms", "value", "nextLink", cancellationToken); } /// @@ -392,7 +549,7 @@ public virtual AsyncPageable GetFirewallPoliciesAsync(Ca { HttpMessage FirstPageRequest(int? pageSizeHint) => FirewallPolicyRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FirewallPolicyRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FirewallPolicyResource(Client, FirewallPolicyData.DeserializeFirewallPolicyData(e)), FirewallPolicyClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFirewallPolicies", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FirewallPolicyResource(Client, FirewallPolicyData.DeserializeFirewallPolicyData(e)), FirewallPolicyClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetFirewallPolicies", "value", "nextLink", cancellationToken); } /// @@ -414,7 +571,7 @@ public virtual Pageable GetFirewallPolicies(Cancellation { HttpMessage FirstPageRequest(int? pageSizeHint) => FirewallPolicyRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FirewallPolicyRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FirewallPolicyResource(Client, FirewallPolicyData.DeserializeFirewallPolicyData(e)), FirewallPolicyClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFirewallPolicies", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FirewallPolicyResource(Client, FirewallPolicyData.DeserializeFirewallPolicyData(e)), FirewallPolicyClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleSubscriptionResource.GetFirewallPolicies", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/TenantResourceExtensionClient.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleTenantResource.cs similarity index 90% rename from test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/TenantResourceExtensionClient.cs rename to test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleTenantResource.cs index c3c61dabfce..7000470db35 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/TenantResourceExtensionClient.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/MockableMgmtMockAndSampleTenantResource.cs @@ -13,27 +13,28 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtMockAndSample; using MgmtMockAndSample.Models; -namespace MgmtMockAndSample +namespace MgmtMockAndSample.Mocking { /// A class to add extension methods to TenantResource. - internal partial class TenantResourceExtensionClient : ArmResource + public partial class MockableMgmtMockAndSampleTenantResource : ArmResource { private ClientDiagnostics _tenantActivityLogsClientDiagnostics; private TenantActivityLogsRestOperations _tenantActivityLogsRestClient; private ClientDiagnostics _deploymentsClientDiagnostics; private DeploymentsRestOperations _deploymentsRestClient; - /// Initializes a new instance of the class for mocking. - protected TenantResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMockAndSampleTenantResource() { } - /// Initializes a new instance of the class. + /// 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 TenantResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtMockAndSampleTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -69,7 +70,7 @@ public virtual AsyncPageable GetTenantActivityLogsAsync(string filter { HttpMessage FirstPageRequest(int? pageSizeHint) => TenantActivityLogsRestClient.CreateListRequest(filter, select); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TenantActivityLogsRestClient.CreateListNextPageRequest(nextLink, filter, select); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, EventData.DeserializeEventData, TenantActivityLogsClientDiagnostics, Pipeline, "TenantResourceExtensionClient.GetTenantActivityLogs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, EventData.DeserializeEventData, TenantActivityLogsClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleTenantResource.GetTenantActivityLogs", "value", "nextLink", cancellationToken); } /// @@ -93,7 +94,7 @@ public virtual Pageable GetTenantActivityLogs(string filter = null, s { HttpMessage FirstPageRequest(int? pageSizeHint) => TenantActivityLogsRestClient.CreateListRequest(filter, select); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TenantActivityLogsRestClient.CreateListNextPageRequest(nextLink, filter, select); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, EventData.DeserializeEventData, TenantActivityLogsClientDiagnostics, Pipeline, "TenantResourceExtensionClient.GetTenantActivityLogs", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, EventData.DeserializeEventData, TenantActivityLogsClientDiagnostics, Pipeline, "MockableMgmtMockAndSampleTenantResource.GetTenantActivityLogs", "value", "nextLink", cancellationToken); } /// @@ -111,9 +112,12 @@ public virtual Pageable GetTenantActivityLogs(string filter = null, s /// /// The template provided to calculate hash. /// The cancellation token to use. + /// is null. public virtual async Task> CalculateTemplateHashDeploymentAsync(BinaryData template, CancellationToken cancellationToken = default) { - using var scope = DeploymentsClientDiagnostics.CreateScope("TenantResourceExtensionClient.CalculateTemplateHashDeployment"); + Argument.AssertNotNull(template, nameof(template)); + + using var scope = DeploymentsClientDiagnostics.CreateScope("MockableMgmtMockAndSampleTenantResource.CalculateTemplateHashDeployment"); scope.Start(); try { @@ -142,9 +146,12 @@ public virtual async Task> CalculateTemplateHashDep /// /// The template provided to calculate hash. /// The cancellation token to use. + /// is null. public virtual Response CalculateTemplateHashDeployment(BinaryData template, CancellationToken cancellationToken = default) { - using var scope = DeploymentsClientDiagnostics.CreateScope("TenantResourceExtensionClient.CalculateTemplateHashDeployment"); + Argument.AssertNotNull(template, nameof(template)); + + using var scope = DeploymentsClientDiagnostics.CreateScope("MockableMgmtMockAndSampleTenantResource.CalculateTemplateHashDeployment"); scope.Start(); try { diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 17b08d03f7f..00000000000 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtMockAndSample -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of VaultResources in the ResourceGroupResource. - /// An object representing collection of VaultResources and their operations over a VaultResource. - public virtual VaultCollection GetVaults() - { - return GetCachedClient(Client => new VaultCollection(Client, Id)); - } - - /// Gets a collection of DiskEncryptionSetResources in the ResourceGroupResource. - /// An object representing collection of DiskEncryptionSetResources and their operations over a DiskEncryptionSetResource. - public virtual DiskEncryptionSetCollection GetDiskEncryptionSets() - { - return GetCachedClient(Client => new DiskEncryptionSetCollection(Client, Id)); - } - - /// Gets a collection of ManagedHsmResources in the ResourceGroupResource. - /// An object representing collection of ManagedHsmResources and their operations over a ManagedHsmResource. - public virtual ManagedHsmCollection GetManagedHsms() - { - return GetCachedClient(Client => new ManagedHsmCollection(Client, Id)); - } - - /// Gets a collection of FirewallPolicyResources in the ResourceGroupResource. - /// An object representing collection of FirewallPolicyResources and their operations over a FirewallPolicyResource. - public virtual FirewallPolicyCollection GetFirewallPolicies() - { - return GetCachedClient(Client => new FirewallPolicyCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyResource.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyResource.cs index d509ac0bd23..5ef68edf69a 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyResource.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyResource.cs @@ -95,7 +95,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of FirewallPolicyRuleCollectionGroupResources and their operations over a FirewallPolicyRuleCollectionGroupResource. public virtual FirewallPolicyRuleCollectionGroupCollection GetFirewallPolicyRuleCollectionGroups() { - return GetCachedClient(Client => new FirewallPolicyRuleCollectionGroupCollection(Client, Id)); + return GetCachedClient(client => new FirewallPolicyRuleCollectionGroupCollection(client, Id)); } /// @@ -113,8 +113,8 @@ public virtual FirewallPolicyRuleCollectionGroupCollection GetFirewallPolicyRule /// /// The name of the FirewallPolicyRuleCollectionGroup. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetFirewallPolicyRuleCollectionGroupAsync(string ruleCollectionGroupName, CancellationToken cancellationToken = default) { @@ -136,8 +136,8 @@ public virtual async Task> G /// /// The name of the FirewallPolicyRuleCollectionGroup. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetFirewallPolicyRuleCollectionGroup(string ruleCollectionGroupName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmResource.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmResource.cs index 67da265ada2..145a9682a58 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmResource.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of MhsmPrivateEndpointConnectionResources and their operations over a MhsmPrivateEndpointConnectionResource. public virtual MhsmPrivateEndpointConnectionCollection GetMhsmPrivateEndpointConnections() { - return GetCachedClient(Client => new MhsmPrivateEndpointConnectionCollection(Client, Id)); + return GetCachedClient(client => new MhsmPrivateEndpointConnectionCollection(client, Id)); } /// @@ -119,8 +119,8 @@ public virtual MhsmPrivateEndpointConnectionCollection GetMhsmPrivateEndpointCon /// /// Name of the private endpoint connection associated with the managed hsm pool. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetMhsmPrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) { @@ -142,8 +142,8 @@ public virtual async Task> GetMh /// /// Name of the private endpoint connection associated with the managed hsm pool. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetMhsmPrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/VaultResource.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/VaultResource.cs index 6f24e2b2f51..ea6b2c1cd4a 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/VaultResource.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/VaultResource.cs @@ -101,7 +101,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of MgmtMockAndSamplePrivateEndpointConnectionResources and their operations over a MgmtMockAndSamplePrivateEndpointConnectionResource. public virtual MgmtMockAndSamplePrivateEndpointConnectionCollection GetMgmtMockAndSamplePrivateEndpointConnections() { - return GetCachedClient(Client => new MgmtMockAndSamplePrivateEndpointConnectionCollection(Client, Id)); + return GetCachedClient(client => new MgmtMockAndSamplePrivateEndpointConnectionCollection(client, Id)); } /// @@ -119,8 +119,8 @@ public virtual MgmtMockAndSamplePrivateEndpointConnectionCollection GetMgmtMockA /// /// Name of the private endpoint connection associated with the key vault. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetMgmtMockAndSamplePrivateEndpointConnectionAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) { @@ -142,8 +142,8 @@ public virtual async Task /// Name of the private endpoint connection associated with the key vault. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetMgmtMockAndSamplePrivateEndpointConnection(string privateEndpointConnectionName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/AnotherParentResource.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/AnotherParentResource.cs index bc5346593a4..a72a4ece9a3 100644 --- a/test/TestProjects/MgmtMultipleParentResource/Generated/AnotherParentResource.cs +++ b/test/TestProjects/MgmtMultipleParentResource/Generated/AnotherParentResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of AnotherParentChildResources and their operations over a AnotherParentChildResource. public virtual AnotherParentChildCollection GetAnotherParentChildren() { - return GetCachedClient(Client => new AnotherParentChildCollection(Client, Id)); + return GetCachedClient(client => new AnotherParentChildCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual AnotherParentChildCollection GetAnotherParentChildren() /// The name of the virtual machine run command. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetAnotherParentChildAsync(string childName, string expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task> GetAnotherParent /// The name of the virtual machine run command. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetAnotherParentChild(string childName, string expand = null, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MgmtMultipleParentResourceExtensions.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MgmtMultipleParentResourceExtensions.cs index fe45241f113..1ff6762ada4 100644 --- a/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MgmtMultipleParentResourceExtensions.cs +++ b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MgmtMultipleParentResourceExtensions.cs @@ -12,128 +12,115 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtMultipleParentResource.Mocking; namespace MgmtMultipleParentResource { /// A class to add extension methods to MgmtMultipleParentResource. public static partial class MgmtMultipleParentResourceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtMultipleParentResourceArmClient GetMockableMgmtMultipleParentResourceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtMultipleParentResourceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtMultipleParentResourceResourceGroupResource GetMockableMgmtMultipleParentResourceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtMultipleParentResourceResourceGroupResource(client, resource.Id)); } - #region AnotherParentResource + /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AnotherParentResource GetAnotherParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AnotherParentResource.ValidateResourceId(id); - return new AnotherParentResource(client, id); - } - ); + return GetMockableMgmtMultipleParentResourceArmClient(client).GetAnotherParentResource(id); } - #endregion - #region AnotherParentChildResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AnotherParentChildResource GetAnotherParentChildResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AnotherParentChildResource.ValidateResourceId(id); - return new AnotherParentChildResource(client, id); - } - ); + return GetMockableMgmtMultipleParentResourceArmClient(client).GetAnotherParentChildResource(id); } - #endregion - #region TheParentSubParentChildResource /// /// 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. /// Returns a object. public static TheParentSubParentChildResource GetTheParentSubParentChildResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TheParentSubParentChildResource.ValidateResourceId(id); - return new TheParentSubParentChildResource(client, id); - } - ); + return GetMockableMgmtMultipleParentResourceArmClient(client).GetTheParentSubParentChildResource(id); } - #endregion - #region TheParentResource /// /// 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. /// Returns a object. public static TheParentResource GetTheParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TheParentResource.ValidateResourceId(id); - return new TheParentResource(client, id); - } - ); + return GetMockableMgmtMultipleParentResourceArmClient(client).GetTheParentResource(id); } - #endregion - #region SubParentResource /// /// 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. /// Returns a object. public static SubParentResource GetSubParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SubParentResource.ValidateResourceId(id); - return new SubParentResource(client, id); - } - ); + return GetMockableMgmtMultipleParentResourceArmClient(client).GetSubParentResource(id); } - #endregion - /// Gets a collection of AnotherParentResources in the ResourceGroupResource. + /// + /// Gets a collection of AnotherParentResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of AnotherParentResources and their operations over a AnotherParentResource. public static AnotherParentCollection GetAnotherParents(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAnotherParents(); + return GetMockableMgmtMultipleParentResourceResourceGroupResource(resourceGroupResource).GetAnotherParents(); } /// @@ -148,17 +135,21 @@ public static AnotherParentCollection GetAnotherParents(this ResourceGroupResour /// AnotherParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine containing the run command. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetAnotherParentAsync(this ResourceGroupResource resourceGroupResource, string anotherName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetAnotherParents().GetAsync(anotherName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMultipleParentResourceResourceGroupResource(resourceGroupResource).GetAnotherParentAsync(anotherName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -173,25 +164,35 @@ public static async Task> GetAnotherParentAsync( /// AnotherParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine containing the run command. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetAnotherParent(this ResourceGroupResource resourceGroupResource, string anotherName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetAnotherParents().Get(anotherName, expand, cancellationToken); + return GetMockableMgmtMultipleParentResourceResourceGroupResource(resourceGroupResource).GetAnotherParent(anotherName, expand, cancellationToken); } - /// Gets a collection of TheParentResources in the ResourceGroupResource. + /// + /// Gets a collection of TheParentResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TheParentResources and their operations over a TheParentResource. public static TheParentCollection GetTheParents(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTheParents(); + return GetMockableMgmtMultipleParentResourceResourceGroupResource(resourceGroupResource).GetTheParents(); } /// @@ -206,17 +207,21 @@ public static TheParentCollection GetTheParents(this ResourceGroupResource resou /// TheParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTheParentAsync(this ResourceGroupResource resourceGroupResource, string theParentName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetTheParents().GetAsync(theParentName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtMultipleParentResourceResourceGroupResource(resourceGroupResource).GetTheParentAsync(theParentName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -231,17 +236,21 @@ public static async Task> GetTheParentAsync(this Res /// TheParents_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTheParent(this ResourceGroupResource resourceGroupResource, string theParentName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetTheParents().Get(theParentName, expand, cancellationToken); + return GetMockableMgmtMultipleParentResourceResourceGroupResource(resourceGroupResource).GetTheParent(theParentName, expand, cancellationToken); } } } diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MockableMgmtMultipleParentResourceArmClient.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MockableMgmtMultipleParentResourceArmClient.cs new file mode 100644 index 00000000000..381b532b5fe --- /dev/null +++ b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MockableMgmtMultipleParentResourceArmClient.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtMultipleParentResource; + +namespace MgmtMultipleParentResource.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtMultipleParentResourceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMultipleParentResourceArmClient() + { + } + + /// 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 MockableMgmtMultipleParentResourceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtMultipleParentResourceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AnotherParentResource GetAnotherParentResource(ResourceIdentifier id) + { + AnotherParentResource.ValidateResourceId(id); + return new AnotherParentResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AnotherParentChildResource GetAnotherParentChildResource(ResourceIdentifier id) + { + AnotherParentChildResource.ValidateResourceId(id); + return new AnotherParentChildResource(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 TheParentSubParentChildResource GetTheParentSubParentChildResource(ResourceIdentifier id) + { + TheParentSubParentChildResource.ValidateResourceId(id); + return new TheParentSubParentChildResource(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 TheParentResource GetTheParentResource(ResourceIdentifier id) + { + TheParentResource.ValidateResourceId(id); + return new TheParentResource(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 SubParentResource GetSubParentResource(ResourceIdentifier id) + { + SubParentResource.ValidateResourceId(id); + return new SubParentResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MockableMgmtMultipleParentResourceResourceGroupResource.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MockableMgmtMultipleParentResourceResourceGroupResource.cs new file mode 100644 index 00000000000..69b1fa7a1af --- /dev/null +++ b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/MockableMgmtMultipleParentResourceResourceGroupResource.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtMultipleParentResource; + +namespace MgmtMultipleParentResource.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtMultipleParentResourceResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtMultipleParentResourceResourceGroupResource() + { + } + + /// 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 MockableMgmtMultipleParentResourceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of AnotherParentResources in the ResourceGroupResource. + /// An object representing collection of AnotherParentResources and their operations over a AnotherParentResource. + public virtual AnotherParentCollection GetAnotherParents() + { + return GetCachedClient(client => new AnotherParentCollection(client, Id)); + } + + /// + /// The operation to get the run command. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/anotherParents/{anotherName} + /// + /// + /// Operation Id + /// AnotherParents_Get + /// + /// + /// + /// The name of the virtual machine containing the run command. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAnotherParentAsync(string anotherName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetAnotherParents().GetAsync(anotherName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to get the run command. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/anotherParents/{anotherName} + /// + /// + /// Operation Id + /// AnotherParents_Get + /// + /// + /// + /// The name of the virtual machine containing the run command. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAnotherParent(string anotherName, string expand = null, CancellationToken cancellationToken = default) + { + return GetAnotherParents().Get(anotherName, expand, cancellationToken); + } + + /// Gets a collection of TheParentResources in the ResourceGroupResource. + /// An object representing collection of TheParentResources and their operations over a TheParentResource. + public virtual TheParentCollection GetTheParents() + { + return GetCachedClient(client => new TheParentCollection(client, Id)); + } + + /// + /// The operation to get the VMSS VM run command. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/theParents/{theParentName} + /// + /// + /// Operation Id + /// TheParents_Get + /// + /// + /// + /// The name of the VM scale set. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTheParentAsync(string theParentName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetTheParents().GetAsync(theParentName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to get the VMSS VM run command. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/theParents/{theParentName} + /// + /// + /// Operation Id + /// TheParents_Get + /// + /// + /// + /// The name of the VM scale set. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTheParent(string theParentName, string expand = null, CancellationToken cancellationToken = default) + { + return GetTheParents().Get(theParentName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 5b397d15ba9..00000000000 --- a/test/TestProjects/MgmtMultipleParentResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtMultipleParentResource -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of AnotherParentResources in the ResourceGroupResource. - /// An object representing collection of AnotherParentResources and their operations over a AnotherParentResource. - public virtual AnotherParentCollection GetAnotherParents() - { - return GetCachedClient(Client => new AnotherParentCollection(Client, Id)); - } - - /// Gets a collection of TheParentResources in the ResourceGroupResource. - /// An object representing collection of TheParentResources and their operations over a TheParentResource. - public virtual TheParentCollection GetTheParents() - { - return GetCachedClient(Client => new TheParentCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/SubParentResource.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/SubParentResource.cs index d5c36d736f8..2390ad21edd 100644 --- a/test/TestProjects/MgmtMultipleParentResource/Generated/SubParentResource.cs +++ b/test/TestProjects/MgmtMultipleParentResource/Generated/SubParentResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of TheParentSubParentChildResources and their operations over a TheParentSubParentChildResource. public virtual TheParentSubParentChildCollection GetTheParentSubParentChildren() { - return GetCachedClient(Client => new TheParentSubParentChildCollection(Client, Id)); + return GetCachedClient(client => new TheParentSubParentChildCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual TheParentSubParentChildCollection GetTheParentSubParentChildren() /// The name of the virtual machine run command. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetTheParentSubParentChildAsync(string childName, string expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task> GetTheParen /// The name of the virtual machine run command. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetTheParentSubParentChild(string childName, string expand = null, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtMultipleParentResource/Generated/TheParentResource.cs b/test/TestProjects/MgmtMultipleParentResource/Generated/TheParentResource.cs index 1984503407f..417362892a9 100644 --- a/test/TestProjects/MgmtMultipleParentResource/Generated/TheParentResource.cs +++ b/test/TestProjects/MgmtMultipleParentResource/Generated/TheParentResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of SubParentResources and their operations over a SubParentResource. public virtual SubParentCollection GetSubParents() { - return GetCachedClient(Client => new SubParentCollection(Client, Id)); + return GetCachedClient(client => new SubParentCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual SubParentCollection GetSubParents() /// The instance ID of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetSubParentAsync(string instanceId, string expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task> GetSubParentAsync(string /// The instance ID of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetSubParent(string instanceId, string expand = null, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MgmtNoTypeReplacementExtensions.cs b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MgmtNoTypeReplacementExtensions.cs index 2d6114b04d8..98ed1ded346 100644 --- a/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MgmtNoTypeReplacementExtensions.cs +++ b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MgmtNoTypeReplacementExtensions.cs @@ -12,90 +12,83 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtNoTypeReplacement.Mocking; namespace MgmtNoTypeReplacement { /// A class to add extension methods to MgmtNoTypeReplacement. public static partial class MgmtNoTypeReplacementExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtNoTypeReplacementArmClient GetMockableMgmtNoTypeReplacementArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtNoTypeReplacementArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtNoTypeReplacementResourceGroupResource GetMockableMgmtNoTypeReplacementResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtNoTypeReplacementResourceGroupResource(client, resource.Id)); } - #region NoTypeReplacementModel1Resource + /// /// 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. /// Returns a object. public static NoTypeReplacementModel1Resource GetNoTypeReplacementModel1Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - NoTypeReplacementModel1Resource.ValidateResourceId(id); - return new NoTypeReplacementModel1Resource(client, id); - } - ); + return GetMockableMgmtNoTypeReplacementArmClient(client).GetNoTypeReplacementModel1Resource(id); } - #endregion - #region NoTypeReplacementModel2Resource /// /// 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. /// Returns a object. public static NoTypeReplacementModel2Resource GetNoTypeReplacementModel2Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - NoTypeReplacementModel2Resource.ValidateResourceId(id); - return new NoTypeReplacementModel2Resource(client, id); - } - ); + return GetMockableMgmtNoTypeReplacementArmClient(client).GetNoTypeReplacementModel2Resource(id); } - #endregion - #region NoTypeReplacementModel3Resource /// /// 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. /// Returns a object. public static NoTypeReplacementModel3Resource GetNoTypeReplacementModel3Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - NoTypeReplacementModel3Resource.ValidateResourceId(id); - return new NoTypeReplacementModel3Resource(client, id); - } - ); + return GetMockableMgmtNoTypeReplacementArmClient(client).GetNoTypeReplacementModel3Resource(id); } - #endregion - /// Gets a collection of NoTypeReplacementModel1Resources in the ResourceGroupResource. + /// + /// Gets a collection of NoTypeReplacementModel1Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of NoTypeReplacementModel1Resources and their operations over a NoTypeReplacementModel1Resource. public static NoTypeReplacementModel1Collection GetNoTypeReplacementModel1s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetNoTypeReplacementModel1s(); + return GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel1s(); } /// @@ -109,16 +102,20 @@ public static NoTypeReplacementModel1Collection GetNoTypeReplacementModel1s(this /// NoTypeReplacementModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetNoTypeReplacementModel1Async(this ResourceGroupResource resourceGroupResource, string noTypeReplacementModel1SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetNoTypeReplacementModel1s().GetAsync(noTypeReplacementModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel1Async(noTypeReplacementModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -132,24 +129,34 @@ public static async Task> GetNoTypeRep /// NoTypeReplacementModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetNoTypeReplacementModel1(this ResourceGroupResource resourceGroupResource, string noTypeReplacementModel1SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetNoTypeReplacementModel1s().Get(noTypeReplacementModel1SName, cancellationToken); + return GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel1(noTypeReplacementModel1SName, cancellationToken); } - /// Gets a collection of NoTypeReplacementModel2Resources in the ResourceGroupResource. + /// + /// Gets a collection of NoTypeReplacementModel2Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of NoTypeReplacementModel2Resources and their operations over a NoTypeReplacementModel2Resource. public static NoTypeReplacementModel2Collection GetNoTypeReplacementModel2s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetNoTypeReplacementModel2s(); + return GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel2s(); } /// @@ -163,16 +170,20 @@ public static NoTypeReplacementModel2Collection GetNoTypeReplacementModel2s(this /// NoTypeReplacementModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetNoTypeReplacementModel2Async(this ResourceGroupResource resourceGroupResource, string noTypeReplacementModel2SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetNoTypeReplacementModel2s().GetAsync(noTypeReplacementModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel2Async(noTypeReplacementModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -186,24 +197,34 @@ public static async Task> GetNoTypeRep /// NoTypeReplacementModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetNoTypeReplacementModel2(this ResourceGroupResource resourceGroupResource, string noTypeReplacementModel2SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetNoTypeReplacementModel2s().Get(noTypeReplacementModel2SName, cancellationToken); + return GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel2(noTypeReplacementModel2SName, cancellationToken); } - /// Gets a collection of NoTypeReplacementModel3Resources in the ResourceGroupResource. + /// + /// Gets a collection of NoTypeReplacementModel3Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of NoTypeReplacementModel3Resources and their operations over a NoTypeReplacementModel3Resource. public static NoTypeReplacementModel3Collection GetNoTypeReplacementModel3s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetNoTypeReplacementModel3s(); + return GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel3s(); } /// @@ -217,16 +238,20 @@ public static NoTypeReplacementModel3Collection GetNoTypeReplacementModel3s(this /// NoTypeReplacementModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetNoTypeReplacementModel3Async(this ResourceGroupResource resourceGroupResource, string noTypeReplacementModel3SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetNoTypeReplacementModel3s().GetAsync(noTypeReplacementModel3SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel3Async(noTypeReplacementModel3SName, cancellationToken).ConfigureAwait(false); } /// @@ -240,16 +265,20 @@ public static async Task> GetNoTypeRep /// NoTypeReplacementModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetNoTypeReplacementModel3(this ResourceGroupResource resourceGroupResource, string noTypeReplacementModel3SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetNoTypeReplacementModel3s().Get(noTypeReplacementModel3SName, cancellationToken); + return GetMockableMgmtNoTypeReplacementResourceGroupResource(resourceGroupResource).GetNoTypeReplacementModel3(noTypeReplacementModel3SName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MockableMgmtNoTypeReplacementArmClient.cs b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MockableMgmtNoTypeReplacementArmClient.cs new file mode 100644 index 00000000000..263a6296b5b --- /dev/null +++ b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MockableMgmtNoTypeReplacementArmClient.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtNoTypeReplacement; + +namespace MgmtNoTypeReplacement.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtNoTypeReplacementArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtNoTypeReplacementArmClient() + { + } + + /// 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 MockableMgmtNoTypeReplacementArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtNoTypeReplacementArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 NoTypeReplacementModel1Resource GetNoTypeReplacementModel1Resource(ResourceIdentifier id) + { + NoTypeReplacementModel1Resource.ValidateResourceId(id); + return new NoTypeReplacementModel1Resource(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 NoTypeReplacementModel2Resource GetNoTypeReplacementModel2Resource(ResourceIdentifier id) + { + NoTypeReplacementModel2Resource.ValidateResourceId(id); + return new NoTypeReplacementModel2Resource(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 NoTypeReplacementModel3Resource GetNoTypeReplacementModel3Resource(ResourceIdentifier id) + { + NoTypeReplacementModel3Resource.ValidateResourceId(id); + return new NoTypeReplacementModel3Resource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MockableMgmtNoTypeReplacementResourceGroupResource.cs b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MockableMgmtNoTypeReplacementResourceGroupResource.cs new file mode 100644 index 00000000000..3cdc0a30816 --- /dev/null +++ b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/MockableMgmtNoTypeReplacementResourceGroupResource.cs @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtNoTypeReplacement; + +namespace MgmtNoTypeReplacement.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtNoTypeReplacementResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtNoTypeReplacementResourceGroupResource() + { + } + + /// 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 MockableMgmtNoTypeReplacementResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of NoTypeReplacementModel1Resources in the ResourceGroupResource. + /// An object representing collection of NoTypeReplacementModel1Resources and their operations over a NoTypeReplacementModel1Resource. + public virtual NoTypeReplacementModel1Collection GetNoTypeReplacementModel1s() + { + return GetCachedClient(client => new NoTypeReplacementModel1Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/noTypeReplacementModel1s/{noTypeReplacementModel1sName} + /// + /// + /// Operation Id + /// NoTypeReplacementModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNoTypeReplacementModel1Async(string noTypeReplacementModel1SName, CancellationToken cancellationToken = default) + { + return await GetNoTypeReplacementModel1s().GetAsync(noTypeReplacementModel1SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/noTypeReplacementModel1s/{noTypeReplacementModel1sName} + /// + /// + /// Operation Id + /// NoTypeReplacementModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNoTypeReplacementModel1(string noTypeReplacementModel1SName, CancellationToken cancellationToken = default) + { + return GetNoTypeReplacementModel1s().Get(noTypeReplacementModel1SName, cancellationToken); + } + + /// Gets a collection of NoTypeReplacementModel2Resources in the ResourceGroupResource. + /// An object representing collection of NoTypeReplacementModel2Resources and their operations over a NoTypeReplacementModel2Resource. + public virtual NoTypeReplacementModel2Collection GetNoTypeReplacementModel2s() + { + return GetCachedClient(client => new NoTypeReplacementModel2Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/noTypeReplacementModel2s/{noTypeReplacementModel2sName} + /// + /// + /// Operation Id + /// NoTypeReplacementModel2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNoTypeReplacementModel2Async(string noTypeReplacementModel2SName, CancellationToken cancellationToken = default) + { + return await GetNoTypeReplacementModel2s().GetAsync(noTypeReplacementModel2SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/noTypeReplacementModel2s/{noTypeReplacementModel2sName} + /// + /// + /// Operation Id + /// NoTypeReplacementModel2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNoTypeReplacementModel2(string noTypeReplacementModel2SName, CancellationToken cancellationToken = default) + { + return GetNoTypeReplacementModel2s().Get(noTypeReplacementModel2SName, cancellationToken); + } + + /// Gets a collection of NoTypeReplacementModel3Resources in the ResourceGroupResource. + /// An object representing collection of NoTypeReplacementModel3Resources and their operations over a NoTypeReplacementModel3Resource. + public virtual NoTypeReplacementModel3Collection GetNoTypeReplacementModel3s() + { + return GetCachedClient(client => new NoTypeReplacementModel3Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/noTypeReplacementModel3s/{noTypeReplacementModel3sName} + /// + /// + /// Operation Id + /// NoTypeReplacementModel3s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNoTypeReplacementModel3Async(string noTypeReplacementModel3SName, CancellationToken cancellationToken = default) + { + return await GetNoTypeReplacementModel3s().GetAsync(noTypeReplacementModel3SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/noTypeReplacementModel3s/{noTypeReplacementModel3sName} + /// + /// + /// Operation Id + /// NoTypeReplacementModel3s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNoTypeReplacementModel3(string noTypeReplacementModel3SName, CancellationToken cancellationToken = default) + { + return GetNoTypeReplacementModel3s().Get(noTypeReplacementModel3SName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index d8c84aca87f..00000000000 --- a/test/TestProjects/MgmtNoTypeReplacement/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtNoTypeReplacement -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of NoTypeReplacementModel1Resources in the ResourceGroupResource. - /// An object representing collection of NoTypeReplacementModel1Resources and their operations over a NoTypeReplacementModel1Resource. - public virtual NoTypeReplacementModel1Collection GetNoTypeReplacementModel1s() - { - return GetCachedClient(Client => new NoTypeReplacementModel1Collection(Client, Id)); - } - - /// Gets a collection of NoTypeReplacementModel2Resources in the ResourceGroupResource. - /// An object representing collection of NoTypeReplacementModel2Resources and their operations over a NoTypeReplacementModel2Resource. - public virtual NoTypeReplacementModel2Collection GetNoTypeReplacementModel2s() - { - return GetCachedClient(Client => new NoTypeReplacementModel2Collection(Client, Id)); - } - - /// Gets a collection of NoTypeReplacementModel3Resources in the ResourceGroupResource. - /// An object representing collection of NoTypeReplacementModel3Resources and their operations over a NoTypeReplacementModel3Resource. - public virtual NoTypeReplacementModel3Collection GetNoTypeReplacementModel3s() - { - return GetCachedClient(Client => new NoTypeReplacementModel3Collection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MgmtNonStringPathVariableExtensions.cs b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MgmtNonStringPathVariableExtensions.cs index 4d48b8da280..04da0367ce5 100644 --- a/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MgmtNonStringPathVariableExtensions.cs +++ b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MgmtNonStringPathVariableExtensions.cs @@ -11,6 +11,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtNonStringPathVariable.Mocking; using MgmtNonStringPathVariable.Models; namespace MgmtNonStringPathVariable @@ -18,65 +19,60 @@ namespace MgmtNonStringPathVariable /// A class to add extension methods to MgmtNonStringPathVariable. public static partial class MgmtNonStringPathVariableExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtNonStringPathVariableArmClient GetMockableMgmtNonStringPathVariableArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtNonStringPathVariableArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtNonStringPathVariableResourceGroupResource GetMockableMgmtNonStringPathVariableResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtNonStringPathVariableResourceGroupResource(client, resource.Id)); } - #region FakeResource + /// /// 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. /// Returns a object. public static FakeResource GetFakeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FakeResource.ValidateResourceId(id); - return new FakeResource(client, id); - } - ); + return GetMockableMgmtNonStringPathVariableArmClient(client).GetFakeResource(id); } - #endregion - #region BarResource /// /// 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. /// Returns a object. public static BarResource GetBarResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BarResource.ValidateResourceId(id); - return new BarResource(client, id); - } - ); + return GetMockableMgmtNonStringPathVariableArmClient(client).GetBarResource(id); } - #endregion - /// Gets a collection of FakeResources in the ResourceGroupResource. + /// + /// Gets a collection of FakeResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of FakeResources and their operations over a FakeResource. public static FakeCollection GetFakes(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetFakes(); + return GetMockableMgmtNonStringPathVariableResourceGroupResource(resourceGroupResource).GetFakes(); } /// @@ -91,6 +87,10 @@ public static FakeCollection GetFakes(this ResourceGroupResource resourceGroupRe /// Fakes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. @@ -99,7 +99,7 @@ public static FakeCollection GetFakes(this ResourceGroupResource resourceGroupRe [ForwardsClientCalls] public static async Task> GetFakeAsync(this ResourceGroupResource resourceGroupResource, FakeNameAsEnum fakeName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetFakes().GetAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtNonStringPathVariableResourceGroupResource(resourceGroupResource).GetFakeAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -114,6 +114,10 @@ public static async Task> GetFakeAsync(this ResourceGroup /// Fakes_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. @@ -122,15 +126,21 @@ public static async Task> GetFakeAsync(this ResourceGroup [ForwardsClientCalls] public static Response GetFake(this ResourceGroupResource resourceGroupResource, FakeNameAsEnum fakeName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetFakes().Get(fakeName, expand, cancellationToken); + return GetMockableMgmtNonStringPathVariableResourceGroupResource(resourceGroupResource).GetFake(fakeName, expand, cancellationToken); } - /// Gets a collection of BarResources in the ResourceGroupResource. + /// + /// Gets a collection of BarResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of BarResources and their operations over a BarResource. public static BarCollection GetBars(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetBars(); + return GetMockableMgmtNonStringPathVariableResourceGroupResource(resourceGroupResource).GetBars(); } /// @@ -145,6 +155,10 @@ public static BarCollection GetBars(this ResourceGroupResource resourceGroupReso /// Bars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. @@ -152,7 +166,7 @@ public static BarCollection GetBars(this ResourceGroupResource resourceGroupReso [ForwardsClientCalls] public static async Task> GetBarAsync(this ResourceGroupResource resourceGroupResource, int barName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetBars().GetAsync(barName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtNonStringPathVariableResourceGroupResource(resourceGroupResource).GetBarAsync(barName, cancellationToken).ConfigureAwait(false); } /// @@ -167,6 +181,10 @@ public static async Task> GetBarAsync(this ResourceGroupRe /// Bars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the fake. @@ -174,7 +192,7 @@ public static async Task> GetBarAsync(this ResourceGroupRe [ForwardsClientCalls] public static Response GetBar(this ResourceGroupResource resourceGroupResource, int barName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetBars().Get(barName, cancellationToken); + return GetMockableMgmtNonStringPathVariableResourceGroupResource(resourceGroupResource).GetBar(barName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MockableMgmtNonStringPathVariableArmClient.cs b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MockableMgmtNonStringPathVariableArmClient.cs new file mode 100644 index 00000000000..f79c8760ce9 --- /dev/null +++ b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MockableMgmtNonStringPathVariableArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtNonStringPathVariable; + +namespace MgmtNonStringPathVariable.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtNonStringPathVariableArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtNonStringPathVariableArmClient() + { + } + + /// 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 MockableMgmtNonStringPathVariableArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtNonStringPathVariableArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 FakeResource GetFakeResource(ResourceIdentifier id) + { + FakeResource.ValidateResourceId(id); + return new FakeResource(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 BarResource GetBarResource(ResourceIdentifier id) + { + BarResource.ValidateResourceId(id); + return new BarResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MockableMgmtNonStringPathVariableResourceGroupResource.cs b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MockableMgmtNonStringPathVariableResourceGroupResource.cs new file mode 100644 index 00000000000..51f9218ef7b --- /dev/null +++ b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/MockableMgmtNonStringPathVariableResourceGroupResource.cs @@ -0,0 +1,139 @@ +// 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.ResourceManager; +using MgmtNonStringPathVariable; +using MgmtNonStringPathVariable.Models; + +namespace MgmtNonStringPathVariable.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtNonStringPathVariableResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtNonStringPathVariableResourceGroupResource() + { + } + + /// 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 MockableMgmtNonStringPathVariableResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of FakeResources in the ResourceGroupResource. + /// An object representing collection of FakeResources and their operations over a FakeResource. + public virtual FakeCollection GetFakes() + { + return GetCachedClient(client => new FakeCollection(client, Id)); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/fakes/{fakeName} + /// + /// + /// Operation Id + /// Fakes_Get + /// + /// + /// + /// The name of the fake. + /// May be used to expand the participants. + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual async Task> GetFakeAsync(FakeNameAsEnum fakeName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetFakes().GetAsync(fakeName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/fakes/{fakeName} + /// + /// + /// Operation Id + /// Fakes_Get + /// + /// + /// + /// The name of the fake. + /// May be used to expand the participants. + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual Response GetFake(FakeNameAsEnum fakeName, string expand = null, CancellationToken cancellationToken = default) + { + return GetFakes().Get(fakeName, expand, cancellationToken); + } + + /// Gets a collection of BarResources in the ResourceGroupResource. + /// An object representing collection of BarResources and their operations over a BarResource. + public virtual BarCollection GetBars() + { + return GetCachedClient(client => new BarCollection(client, Id)); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName} + /// + /// + /// Operation Id + /// Bars_Get + /// + /// + /// + /// The name of the fake. + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual async Task> GetBarAsync(int barName, CancellationToken cancellationToken = default) + { + return await GetBars().GetAsync(barName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an fake. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName} + /// + /// + /// Operation Id + /// Bars_Get + /// + /// + /// + /// The name of the fake. + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual Response GetBar(int barName, CancellationToken cancellationToken = default) + { + return GetBars().Get(barName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 0b3e6071d7e..00000000000 --- a/test/TestProjects/MgmtNonStringPathVariable/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtNonStringPathVariable -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of FakeResources in the ResourceGroupResource. - /// An object representing collection of FakeResources and their operations over a FakeResource. - public virtual FakeCollection GetFakes() - { - return GetCachedClient(Client => new FakeCollection(Client, Id)); - } - - /// Gets a collection of BarResources in the ResourceGroupResource. - /// An object representing collection of BarResources and their operations over a BarResource. - public virtual BarCollection GetBars() - { - return GetCachedClient(Client => new BarCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MgmtOmitOperationGroupsExtensions.cs b/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MgmtOmitOperationGroupsExtensions.cs index 20326c9148c..6b06c2eb4ac 100644 --- a/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MgmtOmitOperationGroupsExtensions.cs +++ b/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MgmtOmitOperationGroupsExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtOmitOperationGroups.Mocking; using MgmtOmitOperationGroups.Models; namespace MgmtOmitOperationGroups @@ -19,46 +20,44 @@ namespace MgmtOmitOperationGroups /// A class to add extension methods to MgmtOmitOperationGroups. public static partial class MgmtOmitOperationGroupsExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtOmitOperationGroupsArmClient GetMockableMgmtOmitOperationGroupsArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtOmitOperationGroupsArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtOmitOperationGroupsResourceGroupResource GetMockableMgmtOmitOperationGroupsResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtOmitOperationGroupsResourceGroupResource(client, resource.Id)); } - #region Model2Resource + /// /// 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. /// Returns a object. public static Model2Resource GetModel2Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - Model2Resource.ValidateResourceId(id); - return new Model2Resource(client, id); - } - ); + return GetMockableMgmtOmitOperationGroupsArmClient(client).GetModel2Resource(id); } - #endregion - /// Gets a collection of Model2Resources in the ResourceGroupResource. + /// + /// Gets a collection of Model2Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of Model2Resources and their operations over a Model2Resource. public static Model2Collection GetModel2s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetModel2s(); + return GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel2s(); } /// @@ -72,16 +71,20 @@ public static Model2Collection GetModel2s(this ResourceGroupResource resourceGro /// Model2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetModel2Async(this ResourceGroupResource resourceGroupResource, string model2SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetModel2s().GetAsync(model2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel2Async(model2SName, cancellationToken).ConfigureAwait(false); } /// @@ -95,16 +98,20 @@ public static async Task> GetModel2Async(this ResourceG /// Model2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetModel2(this ResourceGroupResource resourceGroupResource, string model2SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetModel2s().Get(model2SName, cancellationToken); + return GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel2(model2SName, cancellationToken); } /// @@ -118,13 +125,17 @@ public static Response GetModel2(this ResourceGroupResource reso /// Model5s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetModel5sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetModel5sAsync(cancellationToken); + return GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel5sAsync(cancellationToken); } /// @@ -138,13 +149,17 @@ public static AsyncPageable GetModel5sAsync(this ResourceGroupResource r /// Model5s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetModel5s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetModel5s(cancellationToken); + return GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel5s(cancellationToken); } /// @@ -158,6 +173,10 @@ public static Pageable GetModel5s(this ResourceGroupResource resourceGro /// Model5s_CreateOrUpdate /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -167,10 +186,7 @@ public static Pageable GetModel5s(this ResourceGroupResource resourceGro /// or is null. public static async Task> CreateOrUpdateModel5Async(this ResourceGroupResource resourceGroupResource, string model5SName, Model5 model5, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); - Argument.AssertNotNull(model5, nameof(model5)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).CreateOrUpdateModel5Async(model5SName, model5, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).CreateOrUpdateModel5Async(model5SName, model5, cancellationToken).ConfigureAwait(false); } /// @@ -184,6 +200,10 @@ public static async Task> CreateOrUpdateModel5Async(this Resour /// Model5s_CreateOrUpdate /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -193,10 +213,7 @@ public static async Task> CreateOrUpdateModel5Async(this Resour /// or is null. public static Response CreateOrUpdateModel5(this ResourceGroupResource resourceGroupResource, string model5SName, Model5 model5, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); - Argument.AssertNotNull(model5, nameof(model5)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).CreateOrUpdateModel5(model5SName, model5, cancellationToken); + return GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).CreateOrUpdateModel5(model5SName, model5, cancellationToken); } /// @@ -210,6 +227,10 @@ public static Response CreateOrUpdateModel5(this ResourceGroupResource r /// Model5s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -218,9 +239,7 @@ public static Response CreateOrUpdateModel5(this ResourceGroupResource r /// is null. public static async Task> GetModel5Async(this ResourceGroupResource resourceGroupResource, string model5SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetModel5Async(model5SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel5Async(model5SName, cancellationToken).ConfigureAwait(false); } /// @@ -234,6 +253,10 @@ public static async Task> GetModel5Async(this ResourceGroupReso /// Model5s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -242,9 +265,7 @@ public static async Task> GetModel5Async(this ResourceGroupReso /// is null. public static Response GetModel5(this ResourceGroupResource resourceGroupResource, string model5SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetModel5(model5SName, cancellationToken); + return GetMockableMgmtOmitOperationGroupsResourceGroupResource(resourceGroupResource).GetModel5(model5SName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MockableMgmtOmitOperationGroupsArmClient.cs b/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MockableMgmtOmitOperationGroupsArmClient.cs new file mode 100644 index 00000000000..d9b2fddbc1c --- /dev/null +++ b/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MockableMgmtOmitOperationGroupsArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtOmitOperationGroups; + +namespace MgmtOmitOperationGroups.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtOmitOperationGroupsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtOmitOperationGroupsArmClient() + { + } + + /// 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 MockableMgmtOmitOperationGroupsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtOmitOperationGroupsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 Model2Resource GetModel2Resource(ResourceIdentifier id) + { + Model2Resource.ValidateResourceId(id); + return new Model2Resource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MockableMgmtOmitOperationGroupsResourceGroupResource.cs similarity index 64% rename from test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/ResourceGroupResourceExtensionClient.cs rename to test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MockableMgmtOmitOperationGroupsResourceGroupResource.cs index 4568e921392..42ae54f04f6 100644 --- a/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ b/test/TestProjects/MgmtOmitOperationGroups/Generated/Extensions/MockableMgmtOmitOperationGroupsResourceGroupResource.cs @@ -13,25 +13,26 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtOmitOperationGroups; using MgmtOmitOperationGroups.Models; -namespace MgmtOmitOperationGroups +namespace MgmtOmitOperationGroups.Mocking { /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource + public partial class MockableMgmtOmitOperationGroupsResourceGroupResource : ArmResource { private ClientDiagnostics _model5sClientDiagnostics; private Model5SRestOperations _model5sRestClient; - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtOmitOperationGroupsResourceGroupResource() { } - /// Initializes a new instance of the class. + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtOmitOperationGroupsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -48,7 +49,51 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of Model2Resources and their operations over a Model2Resource. public virtual Model2Collection GetModel2s() { - return GetCachedClient(Client => new Model2Collection(Client, Id)); + return GetCachedClient(client => new Model2Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/model2s/{model2sName} + /// + /// + /// Operation Id + /// Model2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetModel2Async(string model2SName, CancellationToken cancellationToken = default) + { + return await GetModel2s().GetAsync(model2SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/model2s/{model2sName} + /// + /// + /// Operation Id + /// Model2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetModel2(string model2SName, CancellationToken cancellationToken = default) + { + return GetModel2s().Get(model2SName, cancellationToken); } /// @@ -68,7 +113,7 @@ public virtual Model2Collection GetModel2s() public virtual AsyncPageable GetModel5sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => Model5sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, Model5.DeserializeModel5, Model5sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetModel5s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, Model5.DeserializeModel5, Model5sClientDiagnostics, Pipeline, "MockableMgmtOmitOperationGroupsResourceGroupResource.GetModel5s", "value", null, cancellationToken); } /// @@ -88,7 +133,7 @@ public virtual AsyncPageable GetModel5sAsync(CancellationToken cancellat public virtual Pageable GetModel5s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => Model5sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, Model5.DeserializeModel5, Model5sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetModel5s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, Model5.DeserializeModel5, Model5sClientDiagnostics, Pipeline, "MockableMgmtOmitOperationGroupsResourceGroupResource.GetModel5s", "value", null, cancellationToken); } /// @@ -106,9 +151,14 @@ public virtual Pageable GetModel5s(CancellationToken cancellationToken = /// The String to use. /// The Model5 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> CreateOrUpdateModel5Async(string model5SName, Model5 model5, CancellationToken cancellationToken = default) { - using var scope = Model5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.CreateOrUpdateModel5"); + Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); + Argument.AssertNotNull(model5, nameof(model5)); + + using var scope = Model5sClientDiagnostics.CreateScope("MockableMgmtOmitOperationGroupsResourceGroupResource.CreateOrUpdateModel5"); scope.Start(); try { @@ -137,9 +187,14 @@ public virtual async Task> CreateOrUpdateModel5Async(string mod /// The String to use. /// The Model5 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response CreateOrUpdateModel5(string model5SName, Model5 model5, CancellationToken cancellationToken = default) { - using var scope = Model5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.CreateOrUpdateModel5"); + Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); + Argument.AssertNotNull(model5, nameof(model5)); + + using var scope = Model5sClientDiagnostics.CreateScope("MockableMgmtOmitOperationGroupsResourceGroupResource.CreateOrUpdateModel5"); scope.Start(); try { @@ -167,9 +222,13 @@ public virtual Response CreateOrUpdateModel5(string model5SName, Model5 /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetModel5Async(string model5SName, CancellationToken cancellationToken = default) { - using var scope = Model5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetModel5"); + Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); + + using var scope = Model5sClientDiagnostics.CreateScope("MockableMgmtOmitOperationGroupsResourceGroupResource.GetModel5"); scope.Start(); try { @@ -197,9 +256,13 @@ public virtual async Task> GetModel5Async(string model5SName, C /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetModel5(string model5SName, CancellationToken cancellationToken = default) { - using var scope = Model5sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetModel5"); + Argument.AssertNotNullOrEmpty(model5SName, nameof(model5SName)); + + using var scope = Model5sClientDiagnostics.CreateScope("MockableMgmtOmitOperationGroupsResourceGroupResource.GetModel5"); scope.Start(); try { diff --git a/test/TestProjects/MgmtOperations/Generated/AvailabilitySetChildResource.cs b/test/TestProjects/MgmtOperations/Generated/AvailabilitySetChildResource.cs index d8a0e57914c..1a61c1f7066 100644 --- a/test/TestProjects/MgmtOperations/Generated/AvailabilitySetChildResource.cs +++ b/test/TestProjects/MgmtOperations/Generated/AvailabilitySetChildResource.cs @@ -95,7 +95,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of AvailabilitySetGrandChildResources and their operations over a AvailabilitySetGrandChildResource. public virtual AvailabilitySetGrandChildCollection GetAvailabilitySetGrandChildren() { - return GetCachedClient(Client => new AvailabilitySetGrandChildCollection(Client, Id)); + return GetCachedClient(client => new AvailabilitySetGrandChildCollection(client, Id)); } /// @@ -113,8 +113,8 @@ public virtual AvailabilitySetGrandChildCollection GetAvailabilitySetGrandChildr /// /// The name of the availability set grand child. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetAvailabilitySetGrandChildAsync(string availabilitySetGrandChildName, CancellationToken cancellationToken = default) { @@ -136,8 +136,8 @@ public virtual async Task> GetAvaila /// /// The name of the availability set grand child. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetAvailabilitySetGrandChild(string availabilitySetGrandChildName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtOperations/Generated/AvailabilitySetResource.cs b/test/TestProjects/MgmtOperations/Generated/AvailabilitySetResource.cs index 7b35b486941..e6aee20f304 100644 --- a/test/TestProjects/MgmtOperations/Generated/AvailabilitySetResource.cs +++ b/test/TestProjects/MgmtOperations/Generated/AvailabilitySetResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of AvailabilitySetChildResources and their operations over a AvailabilitySetChildResource. public virtual AvailabilitySetChildCollection GetAvailabilitySetChildren() { - return GetCachedClient(Client => new AvailabilitySetChildCollection(Client, Id)); + return GetCachedClient(client => new AvailabilitySetChildCollection(client, Id)); } /// @@ -114,8 +114,8 @@ public virtual AvailabilitySetChildCollection GetAvailabilitySetChildren() /// /// The name of the availability set child. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetAvailabilitySetChildAsync(string availabilitySetChildName, CancellationToken cancellationToken = default) { @@ -137,8 +137,8 @@ public virtual async Task> GetAvailabilit /// /// The name of the availability set child. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetAvailabilitySetChild(string availabilitySetChildName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtOperations/Generated/Extensions/MgmtOperationsExtensions.cs b/test/TestProjects/MgmtOperations/Generated/Extensions/MgmtOperationsExtensions.cs index 556fa015204..68383d7e9dc 100644 --- a/test/TestProjects/MgmtOperations/Generated/Extensions/MgmtOperationsExtensions.cs +++ b/test/TestProjects/MgmtOperations/Generated/Extensions/MgmtOperationsExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtOperations.Mocking; using MgmtOperations.Models; namespace MgmtOperations @@ -19,103 +20,92 @@ namespace MgmtOperations /// A class to add extension methods to MgmtOperations. public static partial class MgmtOperationsExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtOperationsArmClient GetMockableMgmtOperationsArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtOperationsArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtOperationsResourceGroupResource GetMockableMgmtOperationsResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtOperationsResourceGroupResource(client, resource.Id)); } - #region AvailabilitySetResource + /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AvailabilitySetResource GetAvailabilitySetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AvailabilitySetResource.ValidateResourceId(id); - return new AvailabilitySetResource(client, id); - } - ); + return GetMockableMgmtOperationsArmClient(client).GetAvailabilitySetResource(id); } - #endregion - #region AvailabilitySetChildResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AvailabilitySetChildResource GetAvailabilitySetChildResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AvailabilitySetChildResource.ValidateResourceId(id); - return new AvailabilitySetChildResource(client, id); - } - ); + return GetMockableMgmtOperationsArmClient(client).GetAvailabilitySetChildResource(id); } - #endregion - #region AvailabilitySetGrandChildResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AvailabilitySetGrandChildResource GetAvailabilitySetGrandChildResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AvailabilitySetGrandChildResource.ValidateResourceId(id); - return new AvailabilitySetGrandChildResource(client, id); - } - ); + return GetMockableMgmtOperationsArmClient(client).GetAvailabilitySetGrandChildResource(id); } - #endregion - #region UnpatchableResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static UnpatchableResource GetUnpatchableResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - UnpatchableResource.ValidateResourceId(id); - return new UnpatchableResource(client, id); - } - ); + return GetMockableMgmtOperationsArmClient(client).GetUnpatchableResource(id); } - #endregion - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAvailabilitySets(); + return GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).GetAvailabilitySets(); } /// @@ -130,17 +120,21 @@ public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupRe /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetAvailabilitySetAsync(this ResourceGroupResource resourceGroupResource, string availabilitySetName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetAvailabilitySets().GetAsync(availabilitySetName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).GetAvailabilitySetAsync(availabilitySetName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -155,25 +149,35 @@ public static async Task> GetAvailabilitySetAs /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetAvailabilitySet(this ResourceGroupResource resourceGroupResource, string availabilitySetName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetAvailabilitySets().Get(availabilitySetName, expand, cancellationToken); + return GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).GetAvailabilitySet(availabilitySetName, expand, cancellationToken); } - /// Gets a collection of UnpatchableResources in the ResourceGroupResource. + /// + /// Gets a collection of UnpatchableResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of UnpatchableResources and their operations over a UnpatchableResource. public static UnpatchableResourceCollection GetUnpatchableResources(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetUnpatchableResources(); + return GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).GetUnpatchableResources(); } /// @@ -188,17 +192,21 @@ public static UnpatchableResourceCollection GetUnpatchableResources(this Resourc /// UnpatchableResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the UnpatchableResource. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetUnpatchableResourceAsync(this ResourceGroupResource resourceGroupResource, string name, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetUnpatchableResources().GetAsync(name, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).GetUnpatchableResourceAsync(name, expand, cancellationToken).ConfigureAwait(false); } /// @@ -213,17 +221,21 @@ public static async Task> GetUnpatchableResourceAs /// UnpatchableResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the UnpatchableResource. /// May be used to expand the participants. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetUnpatchableResource(this ResourceGroupResource resourceGroupResource, string name, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetUnpatchableResources().Get(name, expand, cancellationToken); + return GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).GetUnpatchableResource(name, expand, cancellationToken); } /// @@ -238,6 +250,10 @@ public static Response GetUnpatchableResource(this Resource /// AvailabilitySets_TestLROMethod /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -246,9 +262,7 @@ public static Response GetUnpatchableResource(this Resource /// is null. public static async Task> TestLROMethodAvailabilitySetAsync(this ResourceGroupResource resourceGroupResource, WaitUntil waitUntil, AvailabilitySetUpdate availabilitySetUpdate, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(availabilitySetUpdate, nameof(availabilitySetUpdate)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).TestLROMethodAvailabilitySetAsync(waitUntil, availabilitySetUpdate, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).TestLROMethodAvailabilitySetAsync(waitUntil, availabilitySetUpdate, cancellationToken).ConfigureAwait(false); } /// @@ -263,6 +277,10 @@ public static async Task> TestLROMethodAvailab /// AvailabilitySets_TestLROMethod /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// 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. @@ -271,9 +289,7 @@ public static async Task> TestLROMethodAvailab /// is null. public static ArmOperation TestLROMethodAvailabilitySet(this ResourceGroupResource resourceGroupResource, WaitUntil waitUntil, AvailabilitySetUpdate availabilitySetUpdate, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(availabilitySetUpdate, nameof(availabilitySetUpdate)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).TestLROMethodAvailabilitySet(waitUntil, availabilitySetUpdate, cancellationToken); + return GetMockableMgmtOperationsResourceGroupResource(resourceGroupResource).TestLROMethodAvailabilitySet(waitUntil, availabilitySetUpdate, cancellationToken); } } } diff --git a/test/TestProjects/MgmtOperations/Generated/Extensions/MockableMgmtOperationsArmClient.cs b/test/TestProjects/MgmtOperations/Generated/Extensions/MockableMgmtOperationsArmClient.cs new file mode 100644 index 00000000000..286387bd37b --- /dev/null +++ b/test/TestProjects/MgmtOperations/Generated/Extensions/MockableMgmtOperationsArmClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtOperations; + +namespace MgmtOperations.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtOperationsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtOperationsArmClient() + { + } + + /// 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 MockableMgmtOperationsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtOperationsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AvailabilitySetResource GetAvailabilitySetResource(ResourceIdentifier id) + { + AvailabilitySetResource.ValidateResourceId(id); + return new AvailabilitySetResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AvailabilitySetChildResource GetAvailabilitySetChildResource(ResourceIdentifier id) + { + AvailabilitySetChildResource.ValidateResourceId(id); + return new AvailabilitySetChildResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AvailabilitySetGrandChildResource GetAvailabilitySetGrandChildResource(ResourceIdentifier id) + { + AvailabilitySetGrandChildResource.ValidateResourceId(id); + return new AvailabilitySetGrandChildResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual UnpatchableResource GetUnpatchableResource(ResourceIdentifier id) + { + UnpatchableResource.ValidateResourceId(id); + return new UnpatchableResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtOperations/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtOperations/Generated/Extensions/MockableMgmtOperationsResourceGroupResource.cs similarity index 50% rename from test/TestProjects/MgmtOperations/Generated/Extensions/ResourceGroupResourceExtensionClient.cs rename to test/TestProjects/MgmtOperations/Generated/Extensions/MockableMgmtOperationsResourceGroupResource.cs index 0a71b2269e8..10e6c2d25a9 100644 --- a/test/TestProjects/MgmtOperations/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ b/test/TestProjects/MgmtOperations/Generated/Extensions/MockableMgmtOperationsResourceGroupResource.cs @@ -12,25 +12,26 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtOperations; using MgmtOperations.Models; -namespace MgmtOperations +namespace MgmtOperations.Mocking { /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource + public partial class MockableMgmtOperationsResourceGroupResource : ArmResource { private ClientDiagnostics _availabilitySetClientDiagnostics; private AvailabilitySetsRestOperations _availabilitySetRestClient; - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtOperationsResourceGroupResource() { } - /// Initializes a new instance of the class. + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtOperationsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -47,14 +48,110 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. public virtual AvailabilitySetCollection GetAvailabilitySets() { - return GetCachedClient(Client => new AvailabilitySetCollection(Client, Id)); + return GetCachedClient(client => new AvailabilitySetCollection(client, Id)); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAvailabilitySetAsync(string availabilitySetName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetAvailabilitySets().GetAsync(availabilitySetName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAvailabilitySet(string availabilitySetName, string expand = null, CancellationToken cancellationToken = default) + { + return GetAvailabilitySets().Get(availabilitySetName, expand, cancellationToken); } /// Gets a collection of UnpatchableResources in the ResourceGroupResource. /// An object representing collection of UnpatchableResources and their operations over a UnpatchableResource. public virtual UnpatchableResourceCollection GetUnpatchableResources() { - return GetCachedClient(Client => new UnpatchableResourceCollection(Client, Id)); + return GetCachedClient(client => new UnpatchableResourceCollection(client, Id)); + } + + /// + /// Retrieves information about an UnpatchableResource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/unpatchableResources/{name} + /// + /// + /// Operation Id + /// UnpatchableResources_Get + /// + /// + /// + /// The name of the UnpatchableResource. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetUnpatchableResourceAsync(string name, string expand = null, CancellationToken cancellationToken = default) + { + return await GetUnpatchableResources().GetAsync(name, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an UnpatchableResource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/unpatchableResources/{name} + /// + /// + /// Operation Id + /// UnpatchableResources_Get + /// + /// + /// + /// The name of the UnpatchableResource. + /// May be used to expand the participants. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetUnpatchableResource(string name, string expand = null, CancellationToken cancellationToken = default) + { + return GetUnpatchableResources().Get(name, expand, cancellationToken); } /// @@ -73,9 +170,12 @@ public virtual UnpatchableResourceCollection GetUnpatchableResources() /// 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. /// Parameters supplied to the Update Availability Set operation. /// The cancellation token to use. + /// is null. public virtual async Task> TestLROMethodAvailabilitySetAsync(WaitUntil waitUntil, AvailabilitySetUpdate availabilitySetUpdate, CancellationToken cancellationToken = default) { - using var scope = AvailabilitySetClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.TestLROMethodAvailabilitySet"); + Argument.AssertNotNull(availabilitySetUpdate, nameof(availabilitySetUpdate)); + + using var scope = AvailabilitySetClientDiagnostics.CreateScope("MockableMgmtOperationsResourceGroupResource.TestLROMethodAvailabilitySet"); scope.Start(); try { @@ -108,9 +208,12 @@ public virtual async Task> TestLROMethodAvaila /// 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. /// Parameters supplied to the Update Availability Set operation. /// The cancellation token to use. + /// is null. public virtual ArmOperation TestLROMethodAvailabilitySet(WaitUntil waitUntil, AvailabilitySetUpdate availabilitySetUpdate, CancellationToken cancellationToken = default) { - using var scope = AvailabilitySetClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.TestLROMethodAvailabilitySet"); + Argument.AssertNotNull(availabilitySetUpdate, nameof(availabilitySetUpdate)); + + using var scope = AvailabilitySetClientDiagnostics.CreateScope("MockableMgmtOperationsResourceGroupResource.TestLROMethodAvailabilitySet"); scope.Start(); try { diff --git a/test/TestProjects/MgmtPagination/Generated/Extensions/MgmtPaginationExtensions.cs b/test/TestProjects/MgmtPagination/Generated/Extensions/MgmtPaginationExtensions.cs index bf190273828..6ac7fbb5f2f 100644 --- a/test/TestProjects/MgmtPagination/Generated/Extensions/MgmtPaginationExtensions.cs +++ b/test/TestProjects/MgmtPagination/Generated/Extensions/MgmtPaginationExtensions.cs @@ -12,185 +12,163 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtPagination.Mocking; namespace MgmtPagination { /// A class to add extension methods to MgmtPagination. public static partial class MgmtPaginationExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtPaginationArmClient GetMockableMgmtPaginationArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtPaginationArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtPaginationResourceGroupResource GetMockableMgmtPaginationResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtPaginationResourceGroupResource(client, resource.Id)); } - #region PageSizeIntegerModelResource + /// /// 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. /// Returns a object. public static PageSizeIntegerModelResource GetPageSizeIntegerModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeIntegerModelResource.ValidateResourceId(id); - return new PageSizeIntegerModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeIntegerModelResource(id); } - #endregion - #region PageSizeInt64ModelResource /// /// 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. /// Returns a object. public static PageSizeInt64ModelResource GetPageSizeInt64ModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeInt64ModelResource.ValidateResourceId(id); - return new PageSizeInt64ModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeInt64ModelResource(id); } - #endregion - #region PageSizeInt32ModelResource /// /// 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. /// Returns a object. public static PageSizeInt32ModelResource GetPageSizeInt32ModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeInt32ModelResource.ValidateResourceId(id); - return new PageSizeInt32ModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeInt32ModelResource(id); } - #endregion - #region PageSizeNumericModelResource /// /// 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. /// Returns a object. public static PageSizeNumericModelResource GetPageSizeNumericModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeNumericModelResource.ValidateResourceId(id); - return new PageSizeNumericModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeNumericModelResource(id); } - #endregion - #region PageSizeFloatModelResource /// /// 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. /// Returns a object. public static PageSizeFloatModelResource GetPageSizeFloatModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeFloatModelResource.ValidateResourceId(id); - return new PageSizeFloatModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeFloatModelResource(id); } - #endregion - #region PageSizeDoubleModelResource /// /// 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. /// Returns a object. public static PageSizeDoubleModelResource GetPageSizeDoubleModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeDoubleModelResource.ValidateResourceId(id); - return new PageSizeDoubleModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeDoubleModelResource(id); } - #endregion - #region PageSizeDecimalModelResource /// /// 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. /// Returns a object. public static PageSizeDecimalModelResource GetPageSizeDecimalModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeDecimalModelResource.ValidateResourceId(id); - return new PageSizeDecimalModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeDecimalModelResource(id); } - #endregion - #region PageSizeStringModelResource /// /// 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. /// Returns a object. public static PageSizeStringModelResource GetPageSizeStringModelResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PageSizeStringModelResource.ValidateResourceId(id); - return new PageSizeStringModelResource(client, id); - } - ); + return GetMockableMgmtPaginationArmClient(client).GetPageSizeStringModelResource(id); } - #endregion - /// Gets a collection of PageSizeIntegerModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeIntegerModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeIntegerModelResources and their operations over a PageSizeIntegerModelResource. public static PageSizeIntegerModelCollection GetPageSizeIntegerModels(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeIntegerModels(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeIntegerModels(); } /// @@ -204,16 +182,20 @@ public static PageSizeIntegerModelCollection GetPageSizeIntegerModels(this Resou /// PageSizeIntegerModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeIntegerModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeIntegerModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeIntegerModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -227,24 +209,34 @@ public static async Task> GetPageSizeInte /// PageSizeIntegerModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeIntegerModel(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeIntegerModels().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeIntegerModel(name, cancellationToken); } - /// Gets a collection of PageSizeInt64ModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeInt64ModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeInt64ModelResources and their operations over a PageSizeInt64ModelResource. public static PageSizeInt64ModelCollection GetPageSizeInt64Models(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeInt64Models(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeInt64Models(); } /// @@ -258,16 +250,20 @@ public static PageSizeInt64ModelCollection GetPageSizeInt64Models(this ResourceG /// PageSizeInt64Models_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeInt64ModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeInt64Models().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeInt64ModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -281,24 +277,34 @@ public static async Task> GetPageSizeInt64M /// PageSizeInt64Models_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeInt64Model(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeInt64Models().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeInt64Model(name, cancellationToken); } - /// Gets a collection of PageSizeInt32ModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeInt32ModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeInt32ModelResources and their operations over a PageSizeInt32ModelResource. public static PageSizeInt32ModelCollection GetPageSizeInt32Models(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeInt32Models(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeInt32Models(); } /// @@ -312,16 +318,20 @@ public static PageSizeInt32ModelCollection GetPageSizeInt32Models(this ResourceG /// PageSizeInt32Models_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeInt32ModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeInt32Models().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeInt32ModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -335,24 +345,34 @@ public static async Task> GetPageSizeInt32M /// PageSizeInt32Models_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeInt32Model(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeInt32Models().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeInt32Model(name, cancellationToken); } - /// Gets a collection of PageSizeNumericModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeNumericModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeNumericModelResources and their operations over a PageSizeNumericModelResource. public static PageSizeNumericModelCollection GetPageSizeNumericModels(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeNumericModels(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeNumericModels(); } /// @@ -366,16 +386,20 @@ public static PageSizeNumericModelCollection GetPageSizeNumericModels(this Resou /// PageSizeNumericModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeNumericModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeNumericModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeNumericModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -389,24 +413,34 @@ public static async Task> GetPageSizeNume /// PageSizeNumericModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeNumericModel(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeNumericModels().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeNumericModel(name, cancellationToken); } - /// Gets a collection of PageSizeFloatModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeFloatModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeFloatModelResources and their operations over a PageSizeFloatModelResource. public static PageSizeFloatModelCollection GetPageSizeFloatModels(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeFloatModels(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeFloatModels(); } /// @@ -420,16 +454,20 @@ public static PageSizeFloatModelCollection GetPageSizeFloatModels(this ResourceG /// PageSizeFloatModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeFloatModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeFloatModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeFloatModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -443,24 +481,34 @@ public static async Task> GetPageSizeFloatM /// PageSizeFloatModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeFloatModel(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeFloatModels().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeFloatModel(name, cancellationToken); } - /// Gets a collection of PageSizeDoubleModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeDoubleModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeDoubleModelResources and their operations over a PageSizeDoubleModelResource. public static PageSizeDoubleModelCollection GetPageSizeDoubleModels(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeDoubleModels(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeDoubleModels(); } /// @@ -474,16 +522,20 @@ public static PageSizeDoubleModelCollection GetPageSizeDoubleModels(this Resourc /// PageSizeDoubleModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeDoubleModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeDoubleModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeDoubleModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -497,24 +549,34 @@ public static async Task> GetPageSizeDoubl /// PageSizeDoubleModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeDoubleModel(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeDoubleModels().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeDoubleModel(name, cancellationToken); } - /// Gets a collection of PageSizeDecimalModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeDecimalModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeDecimalModelResources and their operations over a PageSizeDecimalModelResource. public static PageSizeDecimalModelCollection GetPageSizeDecimalModels(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeDecimalModels(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeDecimalModels(); } /// @@ -528,16 +590,20 @@ public static PageSizeDecimalModelCollection GetPageSizeDecimalModels(this Resou /// PageSizeDecimalModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeDecimalModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeDecimalModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeDecimalModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -551,24 +617,34 @@ public static async Task> GetPageSizeDeci /// PageSizeDecimalModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeDecimalModel(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeDecimalModels().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeDecimalModel(name, cancellationToken); } - /// Gets a collection of PageSizeStringModelResources in the ResourceGroupResource. + /// + /// Gets a collection of PageSizeStringModelResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PageSizeStringModelResources and their operations over a PageSizeStringModelResource. public static PageSizeStringModelCollection GetPageSizeStringModels(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPageSizeStringModels(); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeStringModels(); } /// @@ -582,16 +658,20 @@ public static PageSizeStringModelCollection GetPageSizeStringModels(this Resourc /// PageSizeStringModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPageSizeStringModelAsync(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPageSizeStringModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeStringModelAsync(name, cancellationToken).ConfigureAwait(false); } /// @@ -605,16 +685,20 @@ public static async Task> GetPageSizeStrin /// PageSizeStringModels_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPageSizeStringModel(this ResourceGroupResource resourceGroupResource, string name, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPageSizeStringModels().Get(name, cancellationToken); + return GetMockableMgmtPaginationResourceGroupResource(resourceGroupResource).GetPageSizeStringModel(name, cancellationToken); } } } diff --git a/test/TestProjects/MgmtPagination/Generated/Extensions/MockableMgmtPaginationArmClient.cs b/test/TestProjects/MgmtPagination/Generated/Extensions/MockableMgmtPaginationArmClient.cs new file mode 100644 index 00000000000..957fecae3df --- /dev/null +++ b/test/TestProjects/MgmtPagination/Generated/Extensions/MockableMgmtPaginationArmClient.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtPagination; + +namespace MgmtPagination.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtPaginationArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPaginationArmClient() + { + } + + /// 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 MockableMgmtPaginationArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtPaginationArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 PageSizeIntegerModelResource GetPageSizeIntegerModelResource(ResourceIdentifier id) + { + PageSizeIntegerModelResource.ValidateResourceId(id); + return new PageSizeIntegerModelResource(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 PageSizeInt64ModelResource GetPageSizeInt64ModelResource(ResourceIdentifier id) + { + PageSizeInt64ModelResource.ValidateResourceId(id); + return new PageSizeInt64ModelResource(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 PageSizeInt32ModelResource GetPageSizeInt32ModelResource(ResourceIdentifier id) + { + PageSizeInt32ModelResource.ValidateResourceId(id); + return new PageSizeInt32ModelResource(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 PageSizeNumericModelResource GetPageSizeNumericModelResource(ResourceIdentifier id) + { + PageSizeNumericModelResource.ValidateResourceId(id); + return new PageSizeNumericModelResource(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 PageSizeFloatModelResource GetPageSizeFloatModelResource(ResourceIdentifier id) + { + PageSizeFloatModelResource.ValidateResourceId(id); + return new PageSizeFloatModelResource(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 PageSizeDoubleModelResource GetPageSizeDoubleModelResource(ResourceIdentifier id) + { + PageSizeDoubleModelResource.ValidateResourceId(id); + return new PageSizeDoubleModelResource(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 PageSizeDecimalModelResource GetPageSizeDecimalModelResource(ResourceIdentifier id) + { + PageSizeDecimalModelResource.ValidateResourceId(id); + return new PageSizeDecimalModelResource(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 PageSizeStringModelResource GetPageSizeStringModelResource(ResourceIdentifier id) + { + PageSizeStringModelResource.ValidateResourceId(id); + return new PageSizeStringModelResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtPagination/Generated/Extensions/MockableMgmtPaginationResourceGroupResource.cs b/test/TestProjects/MgmtPagination/Generated/Extensions/MockableMgmtPaginationResourceGroupResource.cs new file mode 100644 index 00000000000..9f6f6bb5281 --- /dev/null +++ b/test/TestProjects/MgmtPagination/Generated/Extensions/MockableMgmtPaginationResourceGroupResource.cs @@ -0,0 +1,447 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtPagination; + +namespace MgmtPagination.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtPaginationResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPaginationResourceGroupResource() + { + } + + /// 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 MockableMgmtPaginationResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of PageSizeIntegerModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeIntegerModelResources and their operations over a PageSizeIntegerModelResource. + public virtual PageSizeIntegerModelCollection GetPageSizeIntegerModels() + { + return GetCachedClient(client => new PageSizeIntegerModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeIntegerModel/{name} + /// + /// + /// Operation Id + /// PageSizeIntegerModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeIntegerModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeIntegerModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeIntegerModel/{name} + /// + /// + /// Operation Id + /// PageSizeIntegerModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeIntegerModel(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeIntegerModels().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeInt64ModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeInt64ModelResources and their operations over a PageSizeInt64ModelResource. + public virtual PageSizeInt64ModelCollection GetPageSizeInt64Models() + { + return GetCachedClient(client => new PageSizeInt64ModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeInt64Model/{name} + /// + /// + /// Operation Id + /// PageSizeInt64Models_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeInt64ModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeInt64Models().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeInt64Model/{name} + /// + /// + /// Operation Id + /// PageSizeInt64Models_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeInt64Model(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeInt64Models().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeInt32ModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeInt32ModelResources and their operations over a PageSizeInt32ModelResource. + public virtual PageSizeInt32ModelCollection GetPageSizeInt32Models() + { + return GetCachedClient(client => new PageSizeInt32ModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeInt32Model/{name} + /// + /// + /// Operation Id + /// PageSizeInt32Models_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeInt32ModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeInt32Models().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeInt32Model/{name} + /// + /// + /// Operation Id + /// PageSizeInt32Models_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeInt32Model(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeInt32Models().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeNumericModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeNumericModelResources and their operations over a PageSizeNumericModelResource. + public virtual PageSizeNumericModelCollection GetPageSizeNumericModels() + { + return GetCachedClient(client => new PageSizeNumericModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeNumericModel/{name} + /// + /// + /// Operation Id + /// PageSizeNumericModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeNumericModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeNumericModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeNumericModel/{name} + /// + /// + /// Operation Id + /// PageSizeNumericModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeNumericModel(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeNumericModels().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeFloatModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeFloatModelResources and their operations over a PageSizeFloatModelResource. + public virtual PageSizeFloatModelCollection GetPageSizeFloatModels() + { + return GetCachedClient(client => new PageSizeFloatModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeFloatModel/{name} + /// + /// + /// Operation Id + /// PageSizeFloatModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeFloatModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeFloatModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeFloatModel/{name} + /// + /// + /// Operation Id + /// PageSizeFloatModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeFloatModel(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeFloatModels().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeDoubleModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeDoubleModelResources and their operations over a PageSizeDoubleModelResource. + public virtual PageSizeDoubleModelCollection GetPageSizeDoubleModels() + { + return GetCachedClient(client => new PageSizeDoubleModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeDoubleModel/{name} + /// + /// + /// Operation Id + /// PageSizeDoubleModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeDoubleModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeDoubleModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeDoubleModel/{name} + /// + /// + /// Operation Id + /// PageSizeDoubleModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeDoubleModel(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeDoubleModels().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeDecimalModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeDecimalModelResources and their operations over a PageSizeDecimalModelResource. + public virtual PageSizeDecimalModelCollection GetPageSizeDecimalModels() + { + return GetCachedClient(client => new PageSizeDecimalModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeDecimalModel/{name} + /// + /// + /// Operation Id + /// PageSizeDecimalModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeDecimalModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeDecimalModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeDecimalModel/{name} + /// + /// + /// Operation Id + /// PageSizeDecimalModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeDecimalModel(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeDecimalModels().Get(name, cancellationToken); + } + + /// Gets a collection of PageSizeStringModelResources in the ResourceGroupResource. + /// An object representing collection of PageSizeStringModelResources and their operations over a PageSizeStringModelResource. + public virtual PageSizeStringModelCollection GetPageSizeStringModels() + { + return GetCachedClient(client => new PageSizeStringModelCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeStringModel/{name} + /// + /// + /// Operation Id + /// PageSizeStringModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPageSizeStringModelAsync(string name, CancellationToken cancellationToken = default) + { + return await GetPageSizeStringModels().GetAsync(name, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/pageSizeStringModel/{name} + /// + /// + /// Operation Id + /// PageSizeStringModels_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPageSizeStringModel(string name, CancellationToken cancellationToken = default) + { + return GetPageSizeStringModels().Get(name, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtPagination/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtPagination/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 7b6d56eb8b2..00000000000 --- a/test/TestProjects/MgmtPagination/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtPagination -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of PageSizeIntegerModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeIntegerModelResources and their operations over a PageSizeIntegerModelResource. - public virtual PageSizeIntegerModelCollection GetPageSizeIntegerModels() - { - return GetCachedClient(Client => new PageSizeIntegerModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeInt64ModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeInt64ModelResources and their operations over a PageSizeInt64ModelResource. - public virtual PageSizeInt64ModelCollection GetPageSizeInt64Models() - { - return GetCachedClient(Client => new PageSizeInt64ModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeInt32ModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeInt32ModelResources and their operations over a PageSizeInt32ModelResource. - public virtual PageSizeInt32ModelCollection GetPageSizeInt32Models() - { - return GetCachedClient(Client => new PageSizeInt32ModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeNumericModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeNumericModelResources and their operations over a PageSizeNumericModelResource. - public virtual PageSizeNumericModelCollection GetPageSizeNumericModels() - { - return GetCachedClient(Client => new PageSizeNumericModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeFloatModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeFloatModelResources and their operations over a PageSizeFloatModelResource. - public virtual PageSizeFloatModelCollection GetPageSizeFloatModels() - { - return GetCachedClient(Client => new PageSizeFloatModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeDoubleModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeDoubleModelResources and their operations over a PageSizeDoubleModelResource. - public virtual PageSizeDoubleModelCollection GetPageSizeDoubleModels() - { - return GetCachedClient(Client => new PageSizeDoubleModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeDecimalModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeDecimalModelResources and their operations over a PageSizeDecimalModelResource. - public virtual PageSizeDecimalModelCollection GetPageSizeDecimalModels() - { - return GetCachedClient(Client => new PageSizeDecimalModelCollection(Client, Id)); - } - - /// Gets a collection of PageSizeStringModelResources in the ResourceGroupResource. - /// An object representing collection of PageSizeStringModelResources and their operations over a PageSizeStringModelResource. - public virtual PageSizeStringModelCollection GetPageSizeStringModels() - { - return GetCachedClient(Client => new PageSizeStringModelCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtParamOrdering/Generated/DedicatedHostGroupResource.cs b/test/TestProjects/MgmtParamOrdering/Generated/DedicatedHostGroupResource.cs index 7f89128293c..e42b6e87bbb 100644 --- a/test/TestProjects/MgmtParamOrdering/Generated/DedicatedHostGroupResource.cs +++ b/test/TestProjects/MgmtParamOrdering/Generated/DedicatedHostGroupResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of DedicatedHostResources and their operations over a DedicatedHostResource. public virtual DedicatedHostCollection GetDedicatedHosts() { - return GetCachedClient(Client => new DedicatedHostCollection(Client, Id)); + return GetCachedClient(client => new DedicatedHostCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual DedicatedHostCollection GetDedicatedHosts() /// The name of the dedicated host. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetDedicatedHostAsync(string hostName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task> GetDedicatedHostAsync /// The name of the dedicated host. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetDedicatedHost(string hostName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MgmtParamOrderingExtensions.cs b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MgmtParamOrderingExtensions.cs index 913d0e418b1..cb982d64a3d 100644 --- a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MgmtParamOrderingExtensions.cs +++ b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MgmtParamOrderingExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtParamOrdering.Mocking; using MgmtParamOrdering.Models; namespace MgmtParamOrdering @@ -19,176 +20,145 @@ namespace MgmtParamOrdering /// A class to add extension methods to MgmtParamOrdering. public static partial class MgmtParamOrderingExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtParamOrderingArmClient GetMockableMgmtParamOrderingArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtParamOrderingArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtParamOrderingResourceGroupResource GetMockableMgmtParamOrderingResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtParamOrderingResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtParamOrderingSubscriptionResource GetMockableMgmtParamOrderingSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtParamOrderingSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region AvailabilitySetResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AvailabilitySetResource GetAvailabilitySetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AvailabilitySetResource.ValidateResourceId(id); - return new AvailabilitySetResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetAvailabilitySetResource(id); } - #endregion - #region DedicatedHostGroupResource /// /// 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. /// Returns a object. public static DedicatedHostGroupResource GetDedicatedHostGroupResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DedicatedHostGroupResource.ValidateResourceId(id); - return new DedicatedHostGroupResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetDedicatedHostGroupResource(id); } - #endregion - #region DedicatedHostResource /// /// 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. /// Returns a object. public static DedicatedHostResource GetDedicatedHostResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DedicatedHostResource.ValidateResourceId(id); - return new DedicatedHostResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetDedicatedHostResource(id); } - #endregion - #region VirtualMachineExtensionImageResource /// /// 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. /// Returns a object. public static VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineExtensionImageResource.ValidateResourceId(id); - return new VirtualMachineExtensionImageResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetVirtualMachineExtensionImageResource(id); } - #endregion - #region EnvironmentContainerResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static EnvironmentContainerResource GetEnvironmentContainerResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - EnvironmentContainerResource.ValidateResourceId(id); - return new EnvironmentContainerResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetEnvironmentContainerResource(id); } - #endregion - #region WorkspaceResource /// /// 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. /// Returns a object. public static WorkspaceResource GetWorkspaceResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - WorkspaceResource.ValidateResourceId(id); - return new WorkspaceResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetWorkspaceResource(id); } - #endregion - #region VirtualMachineScaleSetResource /// /// 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. /// Returns a object. public static VirtualMachineScaleSetResource GetVirtualMachineScaleSetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineScaleSetResource.ValidateResourceId(id); - return new VirtualMachineScaleSetResource(client, id); - } - ); + return GetMockableMgmtParamOrderingArmClient(client).GetVirtualMachineScaleSetResource(id); } - #endregion - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAvailabilitySets(); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetAvailabilitySets(); } /// @@ -203,16 +173,20 @@ public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupRe /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetAvailabilitySetAsync(this ResourceGroupResource resourceGroupResource, string availabilitySetName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetAvailabilitySets().GetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetAvailabilitySetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); } /// @@ -227,24 +201,34 @@ public static async Task> GetAvailabilitySetAs /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetAvailabilitySet(this ResourceGroupResource resourceGroupResource, string availabilitySetName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetAvailabilitySets().Get(availabilitySetName, cancellationToken); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetAvailabilitySet(availabilitySetName, cancellationToken); } - /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// + /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. public static DedicatedHostGroupCollection GetDedicatedHostGroups(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDedicatedHostGroups(); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetDedicatedHostGroups(); } /// @@ -259,17 +243,21 @@ public static DedicatedHostGroupCollection GetDedicatedHostGroups(this ResourceG /// DedicatedHostGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the dedicated host group. /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDedicatedHostGroupAsync(this ResourceGroupResource resourceGroupResource, string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDedicatedHostGroups().GetAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetDedicatedHostGroupAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -284,25 +272,35 @@ public static async Task> GetDedicatedHostG /// DedicatedHostGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the dedicated host group. /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDedicatedHostGroup(this ResourceGroupResource resourceGroupResource, string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDedicatedHostGroups().Get(hostGroupName, expand, cancellationToken); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetDedicatedHostGroup(hostGroupName, expand, cancellationToken); } - /// Gets a collection of WorkspaceResources in the ResourceGroupResource. + /// + /// Gets a collection of WorkspaceResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of WorkspaceResources and their operations over a WorkspaceResource. public static WorkspaceCollection GetWorkspaces(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWorkspaces(); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetWorkspaces(); } /// @@ -317,16 +315,20 @@ public static WorkspaceCollection GetWorkspaces(this ResourceGroupResource resou /// Workspaces_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name of Azure Machine Learning workspace. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetWorkspaceAsync(this ResourceGroupResource resourceGroupResource, string workspaceName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetWorkspaces().GetAsync(workspaceName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetWorkspaceAsync(workspaceName, cancellationToken).ConfigureAwait(false); } /// @@ -341,24 +343,34 @@ public static async Task> GetWorkspaceAsync(this Res /// Workspaces_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// Name of Azure Machine Learning workspace. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetWorkspace(this ResourceGroupResource resourceGroupResource, string workspaceName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetWorkspaces().Get(workspaceName, cancellationToken); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetWorkspace(workspaceName, cancellationToken); } - /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// + /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. public static VirtualMachineScaleSetCollection GetVirtualMachineScaleSets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVirtualMachineScaleSets(); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSets(); } /// @@ -373,17 +385,21 @@ public static VirtualMachineScaleSetCollection GetVirtualMachineScaleSets(this R /// VirtualMachineScaleSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The expand expression to apply on the operation. 'UserData' retrieves the UserData property of the VM scale set that was provided by the user during the VM scale set Create/Update operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineScaleSetAsync(this ResourceGroupResource resourceGroupResource, string vmScaleSetName, ExpandTypesForGetVMScaleSet? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVirtualMachineScaleSets().GetAsync(vmScaleSetName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSetAsync(vmScaleSetName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -398,31 +414,39 @@ public static async Task> GetVirtualMac /// VirtualMachineScaleSets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the VM scale set. /// The expand expression to apply on the operation. 'UserData' retrieves the UserData property of the VM scale set that was provided by the user during the VM scale set Create/Update operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineScaleSet(this ResourceGroupResource resourceGroupResource, string vmScaleSetName, ExpandTypesForGetVMScaleSet? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVirtualMachineScaleSets().Get(vmScaleSetName, expand, cancellationToken); + return GetMockableMgmtParamOrderingResourceGroupResource(resourceGroupResource).GetVirtualMachineScaleSet(vmScaleSetName, expand, cancellationToken); } - /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// The name of a supported Azure region. /// The String to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName) { - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); + return GetMockableMgmtParamOrderingSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); } /// @@ -437,6 +461,10 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -444,12 +472,12 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// The String to use. /// The String to use. /// The cancellation token to use. - /// , or is an empty string, and was expected to be non-empty. /// , or is null. + /// , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineExtensionImageAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParamOrderingSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImageAsync(location, publisherName, type, version, cancellationToken).ConfigureAwait(false); } /// @@ -464,6 +492,10 @@ public static async Task> GetVirt /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -471,12 +503,12 @@ public static async Task> GetVirt /// The String to use. /// The String to use. /// The cancellation token to use. - /// , or is an empty string, and was expected to be non-empty. /// , or is null. + /// , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineExtensionImage(this SubscriptionResource subscriptionResource, AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + return GetMockableMgmtParamOrderingSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImage(location, publisherName, type, version, cancellationToken); } /// @@ -491,6 +523,10 @@ public static Response GetVirtualMachineEx /// AvailabilitySets_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -498,7 +534,7 @@ public static Response GetVirtualMachineEx /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAvailabilitySetsAsync(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetAvailabilitySetsAsync(expand, cancellationToken); + return GetMockableMgmtParamOrderingSubscriptionResource(subscriptionResource).GetAvailabilitySetsAsync(expand, cancellationToken); } /// @@ -513,6 +549,10 @@ public static AsyncPageable GetAvailabilitySetsAsync(th /// AvailabilitySets_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -520,7 +560,7 @@ public static AsyncPageable GetAvailabilitySetsAsync(th /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAvailabilitySets(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetAvailabilitySets(expand, cancellationToken); + return GetMockableMgmtParamOrderingSubscriptionResource(subscriptionResource).GetAvailabilitySets(expand, cancellationToken); } } } diff --git a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingArmClient.cs b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingArmClient.cs new file mode 100644 index 00000000000..b1cdaaa75c6 --- /dev/null +++ b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingArmClient.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtParamOrdering; + +namespace MgmtParamOrdering.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtParamOrderingArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtParamOrderingArmClient() + { + } + + /// 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 MockableMgmtParamOrderingArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtParamOrderingArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AvailabilitySetResource GetAvailabilitySetResource(ResourceIdentifier id) + { + AvailabilitySetResource.ValidateResourceId(id); + return new AvailabilitySetResource(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 DedicatedHostGroupResource GetDedicatedHostGroupResource(ResourceIdentifier id) + { + DedicatedHostGroupResource.ValidateResourceId(id); + return new DedicatedHostGroupResource(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 DedicatedHostResource GetDedicatedHostResource(ResourceIdentifier id) + { + DedicatedHostResource.ValidateResourceId(id); + return new DedicatedHostResource(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 VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(ResourceIdentifier id) + { + VirtualMachineExtensionImageResource.ValidateResourceId(id); + return new VirtualMachineExtensionImageResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual EnvironmentContainerResource GetEnvironmentContainerResource(ResourceIdentifier id) + { + EnvironmentContainerResource.ValidateResourceId(id); + return new EnvironmentContainerResource(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 WorkspaceResource GetWorkspaceResource(ResourceIdentifier id) + { + WorkspaceResource.ValidateResourceId(id); + return new WorkspaceResource(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 VirtualMachineScaleSetResource GetVirtualMachineScaleSetResource(ResourceIdentifier id) + { + VirtualMachineScaleSetResource.ValidateResourceId(id); + return new VirtualMachineScaleSetResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingResourceGroupResource.cs b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingResourceGroupResource.cs new file mode 100644 index 00000000000..5a82bbca9f1 --- /dev/null +++ b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingResourceGroupResource.cs @@ -0,0 +1,256 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtParamOrdering; +using MgmtParamOrdering.Models; + +namespace MgmtParamOrdering.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtParamOrderingResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtParamOrderingResourceGroupResource() + { + } + + /// 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 MockableMgmtParamOrderingResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. + public virtual AvailabilitySetCollection GetAvailabilitySets() + { + return GetCachedClient(client => new AvailabilitySetCollection(client, Id)); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAvailabilitySetAsync(string availabilitySetName, CancellationToken cancellationToken = default) + { + return await GetAvailabilitySets().GetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAvailabilitySet(string availabilitySetName, CancellationToken cancellationToken = default) + { + return GetAvailabilitySets().Get(availabilitySetName, cancellationToken); + } + + /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. + public virtual DedicatedHostGroupCollection GetDedicatedHostGroups() + { + return GetCachedClient(client => new DedicatedHostGroupCollection(client, Id)); + } + + /// + /// Retrieves information about a dedicated host group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName} + /// + /// + /// Operation Id + /// DedicatedHostGroups_Get + /// + /// + /// + /// The name of the dedicated host group. + /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDedicatedHostGroupAsync(string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return await GetDedicatedHostGroups().GetAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about a dedicated host group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName} + /// + /// + /// Operation Id + /// DedicatedHostGroups_Get + /// + /// + /// + /// The name of the dedicated host group. + /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDedicatedHostGroup(string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return GetDedicatedHostGroups().Get(hostGroupName, expand, cancellationToken); + } + + /// Gets a collection of WorkspaceResources in the ResourceGroupResource. + /// An object representing collection of WorkspaceResources and their operations over a WorkspaceResource. + public virtual WorkspaceCollection GetWorkspaces() + { + return GetCachedClient(client => new WorkspaceCollection(client, Id)); + } + + /// + /// Gets the properties of the specified machine learning workspace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName} + /// + /// + /// Operation Id + /// Workspaces_Get + /// + /// + /// + /// Name of Azure Machine Learning workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWorkspaceAsync(string workspaceName, CancellationToken cancellationToken = default) + { + return await GetWorkspaces().GetAsync(workspaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the properties of the specified machine learning workspace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName} + /// + /// + /// Operation Id + /// Workspaces_Get + /// + /// + /// + /// Name of Azure Machine Learning workspace. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWorkspace(string workspaceName, CancellationToken cancellationToken = default) + { + return GetWorkspaces().Get(workspaceName, cancellationToken); + } + + /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. + /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. + public virtual VirtualMachineScaleSetCollection GetVirtualMachineScaleSets() + { + return GetCachedClient(client => new VirtualMachineScaleSetCollection(client, Id)); + } + + /// + /// Display information about a virtual machine scale set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSets_Get + /// + /// + /// + /// The name of the VM scale set. + /// The expand expression to apply on the operation. 'UserData' retrieves the UserData property of the VM scale set that was provided by the user during the VM scale set Create/Update operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineScaleSetAsync(string vmScaleSetName, ExpandTypesForGetVMScaleSet? expand = null, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineScaleSets().GetAsync(vmScaleSetName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Display information about a virtual machine scale set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSets_Get + /// + /// + /// + /// The name of the VM scale set. + /// The expand expression to apply on the operation. 'UserData' retrieves the UserData property of the VM scale set that was provided by the user during the VM scale set Create/Update operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineScaleSet(string vmScaleSetName, ExpandTypesForGetVMScaleSet? expand = null, CancellationToken cancellationToken = default) + { + return GetVirtualMachineScaleSets().Get(vmScaleSetName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingSubscriptionResource.cs similarity index 54% rename from test/TestProjects/MgmtParamOrdering/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingSubscriptionResource.cs index a813f1fdb24..57f22c18fec 100644 --- a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/MockableMgmtParamOrderingSubscriptionResource.cs @@ -5,30 +5,33 @@ #nullable disable +using System; using System.Threading; +using System.Threading.Tasks; using Autorest.CSharp.Core; using Azure; using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtParamOrdering; -namespace MgmtParamOrdering +namespace MgmtParamOrdering.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtParamOrderingSubscriptionResource : ArmResource { private ClientDiagnostics _availabilitySetClientDiagnostics; private AvailabilitySetsRestOperations _availabilitySetRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtParamOrderingSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtParamOrderingSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -44,12 +47,66 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. /// The name of a supported Azure region. /// The String to use. + /// is null. + /// is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public virtual VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(AzureLocation location, string publisherName) { return new VirtualMachineExtensionImageCollection(Client, Id, location, publisherName); } + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineExtensionImageAsync(AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineExtensionImage(AzureLocation location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + } + /// /// Lists all availability sets in a subscription. /// @@ -70,7 +127,7 @@ public virtual AsyncPageable GetAvailabilitySetsAsync(s { HttpMessage FirstPageRequest(int? pageSizeHint) => AvailabilitySetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => AvailabilitySetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetAvailabilitySets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "MockableMgmtParamOrderingSubscriptionResource.GetAvailabilitySets", "value", "nextLink", cancellationToken); } /// @@ -93,7 +150,7 @@ public virtual Pageable GetAvailabilitySets(string expa { HttpMessage FirstPageRequest(int? pageSizeHint) => AvailabilitySetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => AvailabilitySetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetAvailabilitySets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "MockableMgmtParamOrderingSubscriptionResource.GetAvailabilitySets", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtParamOrdering/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index da5b230f2b6..00000000000 --- a/test/TestProjects/MgmtParamOrdering/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtParamOrdering -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. - /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. - public virtual AvailabilitySetCollection GetAvailabilitySets() - { - return GetCachedClient(Client => new AvailabilitySetCollection(Client, Id)); - } - - /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. - /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. - public virtual DedicatedHostGroupCollection GetDedicatedHostGroups() - { - return GetCachedClient(Client => new DedicatedHostGroupCollection(Client, Id)); - } - - /// Gets a collection of WorkspaceResources in the ResourceGroupResource. - /// An object representing collection of WorkspaceResources and their operations over a WorkspaceResource. - public virtual WorkspaceCollection GetWorkspaces() - { - return GetCachedClient(Client => new WorkspaceCollection(Client, Id)); - } - - /// Gets a collection of VirtualMachineScaleSetResources in the ResourceGroupResource. - /// An object representing collection of VirtualMachineScaleSetResources and their operations over a VirtualMachineScaleSetResource. - public virtual VirtualMachineScaleSetCollection GetVirtualMachineScaleSets() - { - return GetCachedClient(Client => new VirtualMachineScaleSetCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtParamOrdering/Generated/WorkspaceResource.cs b/test/TestProjects/MgmtParamOrdering/Generated/WorkspaceResource.cs index 5bd8ffce79b..5665e5589a4 100644 --- a/test/TestProjects/MgmtParamOrdering/Generated/WorkspaceResource.cs +++ b/test/TestProjects/MgmtParamOrdering/Generated/WorkspaceResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of EnvironmentContainerResources and their operations over a EnvironmentContainerResource. public virtual EnvironmentContainerResourceCollection GetEnvironmentContainerResources() { - return GetCachedClient(Client => new EnvironmentContainerResourceCollection(Client, Id)); + return GetCachedClient(client => new EnvironmentContainerResourceCollection(client, Id)); } /// @@ -114,8 +114,8 @@ public virtual EnvironmentContainerResourceCollection GetEnvironmentContainerRes /// /// Container name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetEnvironmentContainerResourceAsync(string name, CancellationToken cancellationToken = default) { @@ -137,8 +137,8 @@ public virtual async Task> GetEnvironment /// /// Container name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetEnvironmentContainerResource(string name, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtParent/Generated/DedicatedHostGroupResource.cs b/test/TestProjects/MgmtParent/Generated/DedicatedHostGroupResource.cs index f25f86ac117..39a5fcde675 100644 --- a/test/TestProjects/MgmtParent/Generated/DedicatedHostGroupResource.cs +++ b/test/TestProjects/MgmtParent/Generated/DedicatedHostGroupResource.cs @@ -96,7 +96,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of DedicatedHostResources and their operations over a DedicatedHostResource. public virtual DedicatedHostCollection GetDedicatedHosts() { - return GetCachedClient(Client => new DedicatedHostCollection(Client, Id)); + return GetCachedClient(client => new DedicatedHostCollection(client, Id)); } /// @@ -115,8 +115,8 @@ public virtual DedicatedHostCollection GetDedicatedHosts() /// The name of the dedicated host. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetDedicatedHostAsync(string hostName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { @@ -139,8 +139,8 @@ public virtual async Task> GetDedicatedHostAsync /// The name of the dedicated host. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetDedicatedHost(string hostName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtParent/Generated/Extensions/MgmtParentExtensions.cs b/test/TestProjects/MgmtParent/Generated/Extensions/MgmtParentExtensions.cs index d062eb12d1e..2ca75b87cf3 100644 --- a/test/TestProjects/MgmtParent/Generated/Extensions/MgmtParentExtensions.cs +++ b/test/TestProjects/MgmtParent/Generated/Extensions/MgmtParentExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtParent.Mocking; using MgmtParent.Models; namespace MgmtParent @@ -19,119 +20,97 @@ namespace MgmtParent /// A class to add extension methods to MgmtParent. public static partial class MgmtParentExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtParentArmClient GetMockableMgmtParentArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtParentArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtParentResourceGroupResource GetMockableMgmtParentResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtParentResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtParentSubscriptionResource GetMockableMgmtParentSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtParentSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region AvailabilitySetResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static AvailabilitySetResource GetAvailabilitySetResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - AvailabilitySetResource.ValidateResourceId(id); - return new AvailabilitySetResource(client, id); - } - ); + return GetMockableMgmtParentArmClient(client).GetAvailabilitySetResource(id); } - #endregion - #region DedicatedHostGroupResource /// /// 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. /// Returns a object. public static DedicatedHostGroupResource GetDedicatedHostGroupResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DedicatedHostGroupResource.ValidateResourceId(id); - return new DedicatedHostGroupResource(client, id); - } - ); + return GetMockableMgmtParentArmClient(client).GetDedicatedHostGroupResource(id); } - #endregion - #region DedicatedHostResource /// /// 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. /// Returns a object. public static DedicatedHostResource GetDedicatedHostResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DedicatedHostResource.ValidateResourceId(id); - return new DedicatedHostResource(client, id); - } - ); + return GetMockableMgmtParentArmClient(client).GetDedicatedHostResource(id); } - #endregion - #region VirtualMachineExtensionImageResource /// /// 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. /// Returns a object. public static VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineExtensionImageResource.ValidateResourceId(id); - return new VirtualMachineExtensionImageResource(client, id); - } - ); + return GetMockableMgmtParentArmClient(client).GetVirtualMachineExtensionImageResource(id); } - #endregion - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetAvailabilitySets(); + return GetMockableMgmtParentResourceGroupResource(resourceGroupResource).GetAvailabilitySets(); } /// @@ -146,16 +125,20 @@ public static AvailabilitySetCollection GetAvailabilitySets(this ResourceGroupRe /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetAvailabilitySetAsync(this ResourceGroupResource resourceGroupResource, string availabilitySetName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetAvailabilitySets().GetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParentResourceGroupResource(resourceGroupResource).GetAvailabilitySetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); } /// @@ -170,24 +153,34 @@ public static async Task> GetAvailabilitySetAs /// AvailabilitySets_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the availability set. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetAvailabilitySet(this ResourceGroupResource resourceGroupResource, string availabilitySetName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetAvailabilitySets().Get(availabilitySetName, cancellationToken); + return GetMockableMgmtParentResourceGroupResource(resourceGroupResource).GetAvailabilitySet(availabilitySetName, cancellationToken); } - /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// + /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. public static DedicatedHostGroupCollection GetDedicatedHostGroups(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDedicatedHostGroups(); + return GetMockableMgmtParentResourceGroupResource(resourceGroupResource).GetDedicatedHostGroups(); } /// @@ -202,17 +195,21 @@ public static DedicatedHostGroupCollection GetDedicatedHostGroups(this ResourceG /// DedicatedHostGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the dedicated host group. /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDedicatedHostGroupAsync(this ResourceGroupResource resourceGroupResource, string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDedicatedHostGroups().GetAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParentResourceGroupResource(resourceGroupResource).GetDedicatedHostGroupAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -227,32 +224,39 @@ public static async Task> GetDedicatedHostG /// DedicatedHostGroups_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the dedicated host group. /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDedicatedHostGroup(this ResourceGroupResource resourceGroupResource, string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDedicatedHostGroups().Get(hostGroupName, expand, cancellationToken); + return GetMockableMgmtParentResourceGroupResource(resourceGroupResource).GetDedicatedHostGroup(hostGroupName, expand, cancellationToken); } - /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// The name of a supported Azure region. /// The String to use. - /// or is an empty string, and was expected to be non-empty. /// or is null. + /// or is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(this SubscriptionResource subscriptionResource, string location, string publisherName) { - Argument.AssertNotNullOrEmpty(location, nameof(location)); - Argument.AssertNotNullOrEmpty(publisherName, nameof(publisherName)); - - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); + return GetMockableMgmtParentSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImages(location, publisherName); } /// @@ -267,6 +271,10 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -274,12 +282,12 @@ public static VirtualMachineExtensionImageCollection GetVirtualMachineExtensionI /// The String to use. /// The String to use. /// The cancellation token to use. - /// , , or is an empty string, and was expected to be non-empty. /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineExtensionImageAsync(this SubscriptionResource subscriptionResource, string location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtParentSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImageAsync(location, publisherName, type, version, cancellationToken).ConfigureAwait(false); } /// @@ -294,6 +302,10 @@ public static async Task> GetVirt /// VirtualMachineExtensionImages_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of a supported Azure region. @@ -301,12 +313,12 @@ public static async Task> GetVirt /// The String to use. /// The String to use. /// The cancellation token to use. - /// , , or is an empty string, and was expected to be non-empty. /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachineExtensionImage(this SubscriptionResource subscriptionResource, string location, string publisherName, string type, string version, CancellationToken cancellationToken = default) { - return subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + return GetMockableMgmtParentSubscriptionResource(subscriptionResource).GetVirtualMachineExtensionImage(location, publisherName, type, version, cancellationToken); } /// @@ -321,6 +333,10 @@ public static Response GetVirtualMachineEx /// AvailabilitySets_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -328,7 +344,7 @@ public static Response GetVirtualMachineEx /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetAvailabilitySetsAsync(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetAvailabilitySetsAsync(expand, cancellationToken); + return GetMockableMgmtParentSubscriptionResource(subscriptionResource).GetAvailabilitySetsAsync(expand, cancellationToken); } /// @@ -343,6 +359,10 @@ public static AsyncPageable GetAvailabilitySetsAsync(th /// AvailabilitySets_ListBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The expand expression to apply to the operation. Allowed values are 'instanceView'. @@ -350,7 +370,7 @@ public static AsyncPageable GetAvailabilitySetsAsync(th /// A collection of that may take multiple service requests to iterate over. public static Pageable GetAvailabilitySets(this SubscriptionResource subscriptionResource, string expand = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetAvailabilitySets(expand, cancellationToken); + return GetMockableMgmtParentSubscriptionResource(subscriptionResource).GetAvailabilitySets(expand, cancellationToken); } } } diff --git a/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentArmClient.cs b/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentArmClient.cs new file mode 100644 index 00000000000..f079db618c8 --- /dev/null +++ b/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentArmClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtParent; + +namespace MgmtParent.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtParentArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtParentArmClient() + { + } + + /// 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 MockableMgmtParentArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtParentArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AvailabilitySetResource GetAvailabilitySetResource(ResourceIdentifier id) + { + AvailabilitySetResource.ValidateResourceId(id); + return new AvailabilitySetResource(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 DedicatedHostGroupResource GetDedicatedHostGroupResource(ResourceIdentifier id) + { + DedicatedHostGroupResource.ValidateResourceId(id); + return new DedicatedHostGroupResource(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 DedicatedHostResource GetDedicatedHostResource(ResourceIdentifier id) + { + DedicatedHostResource.ValidateResourceId(id); + return new DedicatedHostResource(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 VirtualMachineExtensionImageResource GetVirtualMachineExtensionImageResource(ResourceIdentifier id) + { + VirtualMachineExtensionImageResource.ValidateResourceId(id); + return new VirtualMachineExtensionImageResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentResourceGroupResource.cs b/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentResourceGroupResource.cs new file mode 100644 index 00000000000..df55e1c70af --- /dev/null +++ b/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentResourceGroupResource.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtParent; +using MgmtParent.Models; + +namespace MgmtParent.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtParentResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtParentResourceGroupResource() + { + } + + /// 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 MockableMgmtParentResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. + /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. + public virtual AvailabilitySetCollection GetAvailabilitySets() + { + return GetCachedClient(client => new AvailabilitySetCollection(client, Id)); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAvailabilitySetAsync(string availabilitySetName, CancellationToken cancellationToken = default) + { + return await GetAvailabilitySets().GetAsync(availabilitySetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about an availability set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName} + /// + /// + /// Operation Id + /// AvailabilitySets_Get + /// + /// + /// + /// The name of the availability set. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAvailabilitySet(string availabilitySetName, CancellationToken cancellationToken = default) + { + return GetAvailabilitySets().Get(availabilitySetName, cancellationToken); + } + + /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. + /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. + public virtual DedicatedHostGroupCollection GetDedicatedHostGroups() + { + return GetCachedClient(client => new DedicatedHostGroupCollection(client, Id)); + } + + /// + /// Retrieves information about a dedicated host group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName} + /// + /// + /// Operation Id + /// DedicatedHostGroups_Get + /// + /// + /// + /// The name of the dedicated host group. + /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDedicatedHostGroupAsync(string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return await GetDedicatedHostGroups().GetAsync(hostGroupName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about a dedicated host group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName} + /// + /// + /// Operation Id + /// DedicatedHostGroups_Get + /// + /// + /// + /// The name of the dedicated host group. + /// The expand expression to apply on the operation. The response shows the list of instance view of the dedicated hosts under the dedicated host group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDedicatedHostGroup(string hostGroupName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return GetDedicatedHostGroups().Get(hostGroupName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtParent/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentSubscriptionResource.cs similarity index 53% rename from test/TestProjects/MgmtParent/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentSubscriptionResource.cs index 7ec98d84573..12510599c6a 100644 --- a/test/TestProjects/MgmtParent/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtParent/Generated/Extensions/MockableMgmtParentSubscriptionResource.cs @@ -5,30 +5,33 @@ #nullable disable +using System; using System.Threading; +using System.Threading.Tasks; using Autorest.CSharp.Core; using Azure; using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtParent; -namespace MgmtParent +namespace MgmtParent.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtParentSubscriptionResource : ArmResource { private ClientDiagnostics _availabilitySetClientDiagnostics; private AvailabilitySetsRestOperations _availabilitySetRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtParentSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtParentSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -44,12 +47,66 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// Gets a collection of VirtualMachineExtensionImageResources in the SubscriptionResource. /// The name of a supported Azure region. /// The String to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// An object representing collection of VirtualMachineExtensionImageResources and their operations over a VirtualMachineExtensionImageResource. public virtual VirtualMachineExtensionImageCollection GetVirtualMachineExtensionImages(string location, string publisherName) { return new VirtualMachineExtensionImageCollection(Client, Id, location, publisherName); } + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineExtensionImageAsync(string location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return await GetVirtualMachineExtensionImages(location, publisherName).GetAsync(type, version, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual machine extension image. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version} + /// + /// + /// Operation Id + /// VirtualMachineExtensionImages_Get + /// + /// + /// + /// The name of a supported Azure region. + /// The String to use. + /// The String to use. + /// The String to use. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachineExtensionImage(string location, string publisherName, string type, string version, CancellationToken cancellationToken = default) + { + return GetVirtualMachineExtensionImages(location, publisherName).Get(type, version, cancellationToken); + } + /// /// Lists all availability sets in a subscription. /// @@ -70,7 +127,7 @@ public virtual AsyncPageable GetAvailabilitySetsAsync(s { HttpMessage FirstPageRequest(int? pageSizeHint) => AvailabilitySetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => AvailabilitySetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetAvailabilitySets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "MockableMgmtParentSubscriptionResource.GetAvailabilitySets", "value", "nextLink", cancellationToken); } /// @@ -93,7 +150,7 @@ public virtual Pageable GetAvailabilitySets(string expa { HttpMessage FirstPageRequest(int? pageSizeHint) => AvailabilitySetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, expand); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => AvailabilitySetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, expand); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetAvailabilitySets", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AvailabilitySetResource(Client, AvailabilitySetData.DeserializeAvailabilitySetData(e)), AvailabilitySetClientDiagnostics, Pipeline, "MockableMgmtParentSubscriptionResource.GetAvailabilitySets", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtParent/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtParent/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 4447c50b117..00000000000 --- a/test/TestProjects/MgmtParent/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtParent -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of AvailabilitySetResources in the ResourceGroupResource. - /// An object representing collection of AvailabilitySetResources and their operations over a AvailabilitySetResource. - public virtual AvailabilitySetCollection GetAvailabilitySets() - { - return GetCachedClient(Client => new AvailabilitySetCollection(Client, Id)); - } - - /// Gets a collection of DedicatedHostGroupResources in the ResourceGroupResource. - /// An object representing collection of DedicatedHostGroupResources and their operations over a DedicatedHostGroupResource. - public virtual DedicatedHostGroupCollection GetDedicatedHostGroups() - { - return GetCachedClient(Client => new DedicatedHostGroupCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtPartialResource/Generated/Extensions/MgmtPartialResourceExtensions.cs b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MgmtPartialResourceExtensions.cs index ed723a247ab..87730861c03 100644 --- a/test/TestProjects/MgmtPartialResource/Generated/Extensions/MgmtPartialResourceExtensions.cs +++ b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MgmtPartialResourceExtensions.cs @@ -12,125 +12,104 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtPartialResource.Mocking; namespace MgmtPartialResource { /// A class to add extension methods to MgmtPartialResource. public static partial class MgmtPartialResourceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtPartialResourceArmClient GetMockableMgmtPartialResourceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtPartialResourceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtPartialResourceResourceGroupResource GetMockableMgmtPartialResourceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtPartialResourceResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtPartialResourceSubscriptionResource GetMockableMgmtPartialResourceSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtPartialResourceSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region PublicIPAddressResource /// /// 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. /// Returns a object. public static PublicIPAddressResource GetPublicIPAddressResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PublicIPAddressResource.ValidateResourceId(id); - return new PublicIPAddressResource(client, id); - } - ); + return GetMockableMgmtPartialResourceArmClient(client).GetPublicIPAddressResource(id); } - #endregion - #region ConfigurationProfileAssignmentResource /// /// 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. /// Returns a object. public static ConfigurationProfileAssignmentResource GetConfigurationProfileAssignmentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ConfigurationProfileAssignmentResource.ValidateResourceId(id); - return new ConfigurationProfileAssignmentResource(client, id); - } - ); + return GetMockableMgmtPartialResourceArmClient(client).GetConfigurationProfileAssignmentResource(id); } - #endregion - #region PartialVmssResource /// /// 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. /// Returns a object. public static PartialVmssResource GetPartialVmssResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - PartialVmssResource.ValidateResourceId(id); - return new PartialVmssResource(client, id); - } - ); + return GetMockableMgmtPartialResourceArmClient(client).GetPartialVmssResource(id); } - #endregion - #region VirtualMachineMgmtPartialResource /// /// 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. /// Returns a object. public static VirtualMachineMgmtPartialResource GetVirtualMachineMgmtPartialResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineMgmtPartialResource.ValidateResourceId(id); - return new VirtualMachineMgmtPartialResource(client, id); - } - ); + return GetMockableMgmtPartialResourceArmClient(client).GetVirtualMachineMgmtPartialResource(id); } - #endregion - /// Gets a collection of PublicIPAddressResources in the ResourceGroupResource. + /// + /// Gets a collection of PublicIPAddressResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of PublicIPAddressResources and their operations over a PublicIPAddressResource. public static PublicIPAddressCollection GetPublicIPAddresses(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetPublicIPAddresses(); + return GetMockableMgmtPartialResourceResourceGroupResource(resourceGroupResource).GetPublicIPAddresses(); } /// @@ -145,17 +124,21 @@ public static PublicIPAddressCollection GetPublicIPAddresses(this ResourceGroupR /// PublicIPAddresses_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the public IP address. /// Expands referenced resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetPublicIPAddressAsync(this ResourceGroupResource resourceGroupResource, string publicIpAddressName, string expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetPublicIPAddresses().GetAsync(publicIpAddressName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPartialResourceResourceGroupResource(resourceGroupResource).GetPublicIPAddressAsync(publicIpAddressName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -170,17 +153,21 @@ public static async Task> GetPublicIPAddressAs /// PublicIPAddresses_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the public IP address. /// Expands referenced resources. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetPublicIPAddress(this ResourceGroupResource resourceGroupResource, string publicIpAddressName, string expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetPublicIPAddresses().Get(publicIpAddressName, expand, cancellationToken); + return GetMockableMgmtPartialResourceResourceGroupResource(resourceGroupResource).GetPublicIPAddress(publicIpAddressName, expand, cancellationToken); } /// @@ -195,13 +182,17 @@ public static Response GetPublicIPAddress(this Resource /// PublicIPAddresses_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetPublicIPAddressesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetPublicIPAddressesAsync(cancellationToken); + return GetMockableMgmtPartialResourceSubscriptionResource(subscriptionResource).GetPublicIPAddressesAsync(cancellationToken); } /// @@ -216,13 +207,17 @@ public static AsyncPageable GetPublicIPAddressesAsync(t /// PublicIPAddresses_ListAll /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetPublicIPAddresses(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetPublicIPAddresses(cancellationToken); + return GetMockableMgmtPartialResourceSubscriptionResource(subscriptionResource).GetPublicIPAddresses(cancellationToken); } } } diff --git a/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceArmClient.cs b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceArmClient.cs new file mode 100644 index 00000000000..3cfa3b7b046 --- /dev/null +++ b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceArmClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtPartialResource; + +namespace MgmtPartialResource.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtPartialResourceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPartialResourceArmClient() + { + } + + /// 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 MockableMgmtPartialResourceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtPartialResourceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 PublicIPAddressResource GetPublicIPAddressResource(ResourceIdentifier id) + { + PublicIPAddressResource.ValidateResourceId(id); + return new PublicIPAddressResource(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 ConfigurationProfileAssignmentResource GetConfigurationProfileAssignmentResource(ResourceIdentifier id) + { + ConfigurationProfileAssignmentResource.ValidateResourceId(id); + return new ConfigurationProfileAssignmentResource(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 PartialVmssResource GetPartialVmssResource(ResourceIdentifier id) + { + PartialVmssResource.ValidateResourceId(id); + return new PartialVmssResource(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 VirtualMachineMgmtPartialResource GetVirtualMachineMgmtPartialResource(ResourceIdentifier id) + { + VirtualMachineMgmtPartialResource.ValidateResourceId(id); + return new VirtualMachineMgmtPartialResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceResourceGroupResource.cs b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceResourceGroupResource.cs new file mode 100644 index 00000000000..1c3fc7d1012 --- /dev/null +++ b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceResourceGroupResource.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtPartialResource; + +namespace MgmtPartialResource.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtPartialResourceResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPartialResourceResourceGroupResource() + { + } + + /// 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 MockableMgmtPartialResourceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of PublicIPAddressResources in the ResourceGroupResource. + /// An object representing collection of PublicIPAddressResources and their operations over a PublicIPAddressResource. + public virtual PublicIPAddressCollection GetPublicIPAddresses() + { + return GetCachedClient(client => new PublicIPAddressCollection(client, Id)); + } + + /// + /// Gets the specified public IP address in a specified resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName} + /// + /// + /// Operation Id + /// PublicIPAddresses_Get + /// + /// + /// + /// The name of the public IP address. + /// Expands referenced resources. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPublicIPAddressAsync(string publicIpAddressName, string expand = null, CancellationToken cancellationToken = default) + { + return await GetPublicIPAddresses().GetAsync(publicIpAddressName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified public IP address in a specified resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName} + /// + /// + /// Operation Id + /// PublicIPAddresses_Get + /// + /// + /// + /// The name of the public IP address. + /// Expands referenced resources. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPublicIPAddress(string publicIpAddressName, string expand = null, CancellationToken cancellationToken = default) + { + return GetPublicIPAddresses().Get(publicIpAddressName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtPartialResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceSubscriptionResource.cs similarity index 84% rename from test/TestProjects/MgmtPartialResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceSubscriptionResource.cs index 8101ab93511..e8c7fc92fed 100644 --- a/test/TestProjects/MgmtPartialResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtPartialResource/Generated/Extensions/MockableMgmtPartialResourceSubscriptionResource.cs @@ -11,24 +11,25 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtPartialResource; -namespace MgmtPartialResource +namespace MgmtPartialResource.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtPartialResourceSubscriptionResource : ArmResource { private ClientDiagnostics _publicIPAddressClientDiagnostics; private PublicIPAddressesRestOperations _publicIPAddressRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPartialResourceSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtPartialResourceSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -60,7 +61,7 @@ public virtual AsyncPageable GetPublicIPAddressesAsync( { HttpMessage FirstPageRequest(int? pageSizeHint) => PublicIPAddressRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => PublicIPAddressRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new PublicIPAddressResource(Client, PublicIPAddressData.DeserializePublicIPAddressData(e)), PublicIPAddressClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetPublicIPAddresses", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new PublicIPAddressResource(Client, PublicIPAddressData.DeserializePublicIPAddressData(e)), PublicIPAddressClientDiagnostics, Pipeline, "MockableMgmtPartialResourceSubscriptionResource.GetPublicIPAddresses", "value", "nextLink", cancellationToken); } /// @@ -82,7 +83,7 @@ public virtual Pageable GetPublicIPAddresses(Cancellati { HttpMessage FirstPageRequest(int? pageSizeHint) => PublicIPAddressRestClient.CreateListAllRequest(Id.SubscriptionId); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => PublicIPAddressRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new PublicIPAddressResource(Client, PublicIPAddressData.DeserializePublicIPAddressData(e)), PublicIPAddressClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetPublicIPAddresses", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new PublicIPAddressResource(Client, PublicIPAddressData.DeserializePublicIPAddressData(e)), PublicIPAddressClientDiagnostics, Pipeline, "MockableMgmtPartialResourceSubscriptionResource.GetPublicIPAddresses", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtPartialResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtPartialResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 68209c48a8b..00000000000 --- a/test/TestProjects/MgmtPartialResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtPartialResource -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of PublicIPAddressResources in the ResourceGroupResource. - /// An object representing collection of PublicIPAddressResources and their operations over a PublicIPAddressResource. - public virtual PublicIPAddressCollection GetPublicIPAddresses() - { - return GetCachedClient(Client => new PublicIPAddressCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtPartialResource/Generated/VirtualMachineMgmtPartialResource.cs b/test/TestProjects/MgmtPartialResource/Generated/VirtualMachineMgmtPartialResource.cs index b1b68ffa2d7..8653d797fbe 100644 --- a/test/TestProjects/MgmtPartialResource/Generated/VirtualMachineMgmtPartialResource.cs +++ b/test/TestProjects/MgmtPartialResource/Generated/VirtualMachineMgmtPartialResource.cs @@ -59,7 +59,7 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// An object representing collection of ConfigurationProfileAssignmentResources and their operations over a ConfigurationProfileAssignmentResource. public virtual ConfigurationProfileAssignmentCollection GetConfigurationProfileAssignments() { - return GetCachedClient(Client => new ConfigurationProfileAssignmentCollection(Client, Id)); + return GetCachedClient(client => new ConfigurationProfileAssignmentCollection(client, Id)); } /// @@ -77,8 +77,8 @@ public virtual ConfigurationProfileAssignmentCollection GetConfigurationProfileA /// /// The configuration profile assignment name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual async Task> GetConfigurationProfileAssignmentAsync(string configurationProfileAssignmentName, CancellationToken cancellationToken = default) { @@ -100,8 +100,8 @@ public virtual async Task> GetC /// /// The configuration profile assignment name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public virtual Response GetConfigurationProfileAssignment(string configurationProfileAssignmentName, CancellationToken cancellationToken = default) { diff --git a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MgmtPropertyBagExtensions.cs b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MgmtPropertyBagExtensions.cs index 14db96621d9..bdad5d66f3b 100644 --- a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MgmtPropertyBagExtensions.cs +++ b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MgmtPropertyBagExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtPropertyBag.Mocking; using MgmtPropertyBag.Models; namespace MgmtPropertyBag @@ -19,81 +20,65 @@ namespace MgmtPropertyBag /// A class to add extension methods to MgmtPropertyBag. public static partial class MgmtPropertyBagExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtPropertyBagArmClient GetMockableMgmtPropertyBagArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtPropertyBagArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtPropertyBagResourceGroupResource GetMockableMgmtPropertyBagResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtPropertyBagResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtPropertyBagSubscriptionResource GetMockableMgmtPropertyBagSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtPropertyBagSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region FooResource /// /// 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. /// Returns a object. public static FooResource GetFooResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - FooResource.ValidateResourceId(id); - return new FooResource(client, id); - } - ); + return GetMockableMgmtPropertyBagArmClient(client).GetFooResource(id); } - #endregion - #region BarResource /// /// 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. /// Returns a object. public static BarResource GetBarResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BarResource.ValidateResourceId(id); - return new BarResource(client, id); - } - ); + return GetMockableMgmtPropertyBagArmClient(client).GetBarResource(id); } - #endregion - /// Gets a collection of FooResources in the ResourceGroupResource. + /// + /// Gets a collection of FooResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of FooResources and their operations over a FooResource. public static FooCollection GetFoos(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetFoos(); + return GetMockableMgmtPropertyBagResourceGroupResource(resourceGroupResource).GetFoos(); } /// @@ -108,6 +93,10 @@ public static FooCollection GetFoos(this ResourceGroupResource resourceGroupReso /// Foos_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. @@ -116,7 +105,7 @@ public static FooCollection GetFoos(this ResourceGroupResource resourceGroupReso [ForwardsClientCalls] public static async Task> GetFooAsync(this ResourceGroupResource resourceGroupResource, FooCollectionGetOptions options, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetFoos().GetAsync(options, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPropertyBagResourceGroupResource(resourceGroupResource).GetFooAsync(options, cancellationToken).ConfigureAwait(false); } /// @@ -131,6 +120,10 @@ public static async Task> GetFooAsync(this ResourceGroupRe /// Foos_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. @@ -139,15 +132,21 @@ public static async Task> GetFooAsync(this ResourceGroupRe [ForwardsClientCalls] public static Response GetFoo(this ResourceGroupResource resourceGroupResource, FooCollectionGetOptions options, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetFoos().Get(options, cancellationToken); + return GetMockableMgmtPropertyBagResourceGroupResource(resourceGroupResource).GetFoo(options, cancellationToken); } - /// Gets a collection of BarResources in the ResourceGroupResource. + /// + /// Gets a collection of BarResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of BarResources and their operations over a BarResource. public static BarCollection GetBars(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetBars(); + return GetMockableMgmtPropertyBagResourceGroupResource(resourceGroupResource).GetBars(); } /// @@ -162,6 +161,10 @@ public static BarCollection GetBars(this ResourceGroupResource resourceGroupReso /// Bars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. @@ -170,7 +173,7 @@ public static BarCollection GetBars(this ResourceGroupResource resourceGroupReso [ForwardsClientCalls] public static async Task> GetBarAsync(this ResourceGroupResource resourceGroupResource, BarCollectionGetOptions options, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetBars().GetAsync(options, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPropertyBagResourceGroupResource(resourceGroupResource).GetBarAsync(options, cancellationToken).ConfigureAwait(false); } /// @@ -185,6 +188,10 @@ public static async Task> GetBarAsync(this ResourceGroupRe /// Bars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. @@ -193,7 +200,7 @@ public static async Task> GetBarAsync(this ResourceGroupRe [ForwardsClientCalls] public static Response GetBar(this ResourceGroupResource resourceGroupResource, BarCollectionGetOptions options, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetBars().Get(options, cancellationToken); + return GetMockableMgmtPropertyBagResourceGroupResource(resourceGroupResource).GetBar(options, cancellationToken); } /// @@ -208,6 +215,10 @@ public static Response GetBar(this ResourceGroupResource resourceGr /// Foos_ListWithSubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The filter to apply on the operation. @@ -216,7 +227,7 @@ public static Response GetBar(this ResourceGroupResource resourceGr /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetFoosAsync(this SubscriptionResource subscriptionResource, string filter = null, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFoosAsync(filter, top, cancellationToken); + return GetMockableMgmtPropertyBagSubscriptionResource(subscriptionResource).GetFoosAsync(filter, top, cancellationToken); } /// @@ -231,6 +242,10 @@ public static AsyncPageable GetFoosAsync(this SubscriptionResource /// Foos_ListWithSubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The filter to apply on the operation. @@ -239,7 +254,7 @@ public static AsyncPageable GetFoosAsync(this SubscriptionResource /// A collection of that may take multiple service requests to iterate over. public static Pageable GetFoos(this SubscriptionResource subscriptionResource, string filter = null, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetFoos(filter, top, cancellationToken); + return GetMockableMgmtPropertyBagSubscriptionResource(subscriptionResource).GetFoos(filter, top, cancellationToken); } /// @@ -254,6 +269,10 @@ public static Pageable GetFoos(this SubscriptionResource subscripti /// Bars_ListWithSubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The entity state (Etag) version. A value of "*" can be used for If-Match to unconditionally apply the operation. @@ -262,7 +281,7 @@ public static Pageable GetFoos(this SubscriptionResource subscripti /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetBarsAsync(this SubscriptionResource subscriptionResource, ETag? ifMatch = null, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetBarsAsync(ifMatch, top, cancellationToken); + return GetMockableMgmtPropertyBagSubscriptionResource(subscriptionResource).GetBarsAsync(ifMatch, top, cancellationToken); } /// @@ -277,6 +296,10 @@ public static AsyncPageable GetBarsAsync(this SubscriptionResource /// Bars_ListWithSubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The entity state (Etag) version. A value of "*" can be used for If-Match to unconditionally apply the operation. @@ -285,7 +308,7 @@ public static AsyncPageable GetBarsAsync(this SubscriptionResource /// A collection of that may take multiple service requests to iterate over. public static Pageable GetBars(this SubscriptionResource subscriptionResource, ETag? ifMatch = null, int? top = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetBars(ifMatch, top, cancellationToken); + return GetMockableMgmtPropertyBagSubscriptionResource(subscriptionResource).GetBars(ifMatch, top, cancellationToken); } } } diff --git a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagArmClient.cs b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagArmClient.cs new file mode 100644 index 00000000000..fc0c746041a --- /dev/null +++ b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtPropertyBag; + +namespace MgmtPropertyBag.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtPropertyBagArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPropertyBagArmClient() + { + } + + /// 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 MockableMgmtPropertyBagArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtPropertyBagArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 FooResource GetFooResource(ResourceIdentifier id) + { + FooResource.ValidateResourceId(id); + return new FooResource(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 BarResource GetBarResource(ResourceIdentifier id) + { + BarResource.ValidateResourceId(id); + return new BarResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagResourceGroupResource.cs b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagResourceGroupResource.cs new file mode 100644 index 00000000000..84426dcb26c --- /dev/null +++ b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagResourceGroupResource.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtPropertyBag; +using MgmtPropertyBag.Models; + +namespace MgmtPropertyBag.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtPropertyBagResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPropertyBagResourceGroupResource() + { + } + + /// 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 MockableMgmtPropertyBagResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of FooResources in the ResourceGroupResource. + /// An object representing collection of FooResources and their operations over a FooResource. + public virtual FooCollection GetFoos() + { + return GetCachedClient(client => new FooCollection(client, Id)); + } + + /// + /// Gets a specific foo with five optional query parameters. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/foos/{fooName} + /// + /// + /// Operation Id + /// Foos_Get + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetFooAsync(FooCollectionGetOptions options, CancellationToken cancellationToken = default) + { + return await GetFoos().GetAsync(options, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a specific foo with five optional query parameters. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/foos/{fooName} + /// + /// + /// Operation Id + /// Foos_Get + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public virtual Response GetFoo(FooCollectionGetOptions options, CancellationToken cancellationToken = default) + { + return GetFoos().Get(options, cancellationToken); + } + + /// Gets a collection of BarResources in the ResourceGroupResource. + /// An object representing collection of BarResources and their operations over a BarResource. + public virtual BarCollection GetBars() + { + return GetCachedClient(client => new BarCollection(client, Id)); + } + + /// + /// Gets a specific bar with one required header parameter and four optional query parameters. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName} + /// + /// + /// Operation Id + /// Bars_Get + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetBarAsync(BarCollectionGetOptions options, CancellationToken cancellationToken = default) + { + return await GetBars().GetAsync(options, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a specific bar with one required header parameter and four optional query parameters. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName} + /// + /// + /// Operation Id + /// Bars_Get + /// + /// + /// + /// A property bag which contains all the parameters of this method except the LRO qualifier and request context parameter. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public virtual Response GetBar(BarCollectionGetOptions options, CancellationToken cancellationToken = default) + { + return GetBars().Get(options, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagSubscriptionResource.cs similarity index 88% rename from test/TestProjects/MgmtPropertyBag/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagSubscriptionResource.cs index 630268bee2b..e7a479434fa 100644 --- a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/MockableMgmtPropertyBagSubscriptionResource.cs @@ -11,26 +11,27 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtPropertyBag; -namespace MgmtPropertyBag +namespace MgmtPropertyBag.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtPropertyBagSubscriptionResource : ArmResource { private ClientDiagnostics _fooClientDiagnostics; private FoosRestOperations _fooRestClient; private ClientDiagnostics _barClientDiagnostics; private BarsRestOperations _barRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPropertyBagSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtPropertyBagSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -65,7 +66,7 @@ private string GetApiVersionOrNull(ResourceType resourceType) public virtual AsyncPageable GetFoosAsync(string filter = null, int? top = null, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => FooRestClient.CreateListWithSubscriptionRequest(Id.SubscriptionId, filter, top); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new FooResource(Client, FooData.DeserializeFooData(e)), FooClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFoos", "", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new FooResource(Client, FooData.DeserializeFooData(e)), FooClientDiagnostics, Pipeline, "MockableMgmtPropertyBagSubscriptionResource.GetFoos", "", null, cancellationToken); } /// @@ -88,7 +89,7 @@ public virtual AsyncPageable GetFoosAsync(string filter = null, int public virtual Pageable GetFoos(string filter = null, int? top = null, CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => FooRestClient.CreateListWithSubscriptionRequest(Id.SubscriptionId, filter, top); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new FooResource(Client, FooData.DeserializeFooData(e)), FooClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetFoos", "", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new FooResource(Client, FooData.DeserializeFooData(e)), FooClientDiagnostics, Pipeline, "MockableMgmtPropertyBagSubscriptionResource.GetFoos", "", null, cancellationToken); } /// @@ -112,7 +113,7 @@ public virtual AsyncPageable GetBarsAsync(ETag? ifMatch = null, int { HttpMessage FirstPageRequest(int? pageSizeHint) => BarRestClient.CreateListWithSubscriptionRequest(Id.SubscriptionId, ifMatch, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => BarRestClient.CreateListWithSubscriptionNextPageRequest(nextLink, Id.SubscriptionId, ifMatch, top); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new BarResource(Client, BarData.DeserializeBarData(e)), BarClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetBars", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new BarResource(Client, BarData.DeserializeBarData(e)), BarClientDiagnostics, Pipeline, "MockableMgmtPropertyBagSubscriptionResource.GetBars", "value", "nextLink", cancellationToken); } /// @@ -136,7 +137,7 @@ public virtual Pageable GetBars(ETag? ifMatch = null, int? top = nu { HttpMessage FirstPageRequest(int? pageSizeHint) => BarRestClient.CreateListWithSubscriptionRequest(Id.SubscriptionId, ifMatch, top); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => BarRestClient.CreateListWithSubscriptionNextPageRequest(nextLink, Id.SubscriptionId, ifMatch, top); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new BarResource(Client, BarData.DeserializeBarData(e)), BarClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetBars", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new BarResource(Client, BarData.DeserializeBarData(e)), BarClientDiagnostics, Pipeline, "MockableMgmtPropertyBagSubscriptionResource.GetBars", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtPropertyBag/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index f02c7356dd1..00000000000 --- a/test/TestProjects/MgmtPropertyBag/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtPropertyBag -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of FooResources in the ResourceGroupResource. - /// An object representing collection of FooResources and their operations over a FooResource. - public virtual FooCollection GetFoos() - { - return GetCachedClient(Client => new FooCollection(Client, Id)); - } - - /// Gets a collection of BarResources in the ResourceGroupResource. - /// An object representing collection of BarResources and their operations over a BarResource. - public virtual BarCollection GetBars() - { - return GetCachedClient(Client => new BarCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MgmtPropertyChooserExtensions.cs b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MgmtPropertyChooserExtensions.cs index 1ffbdf682aa..988f426f6a8 100644 --- a/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MgmtPropertyChooserExtensions.cs +++ b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MgmtPropertyChooserExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtPropertyChooser.Mocking; using MgmtPropertyChooser.Models; namespace MgmtPropertyChooser @@ -19,46 +20,44 @@ namespace MgmtPropertyChooser /// A class to add extension methods to MgmtPropertyChooser. public static partial class MgmtPropertyChooserExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtPropertyChooserArmClient GetMockableMgmtPropertyChooserArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtPropertyChooserArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtPropertyChooserResourceGroupResource GetMockableMgmtPropertyChooserResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtPropertyChooserResourceGroupResource(client, resource.Id)); } - #region VirtualMachineResource + /// /// 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. /// Returns a object. public static VirtualMachineResource GetVirtualMachineResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - VirtualMachineResource.ValidateResourceId(id); - return new VirtualMachineResource(client, id); - } - ); + return GetMockableMgmtPropertyChooserArmClient(client).GetVirtualMachineResource(id); } - #endregion - /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// + /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. public static VirtualMachineCollection GetVirtualMachines(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetVirtualMachines(); + return GetMockableMgmtPropertyChooserResourceGroupResource(resourceGroupResource).GetVirtualMachines(); } /// @@ -73,17 +72,21 @@ public static VirtualMachineCollection GetVirtualMachines(this ResourceGroupReso /// VirtualMachines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetVirtualMachineAsync(this ResourceGroupResource resourceGroupResource, string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetVirtualMachines().GetAsync(vmName, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtPropertyChooserResourceGroupResource(resourceGroupResource).GetVirtualMachineAsync(vmName, expand, cancellationToken).ConfigureAwait(false); } /// @@ -98,17 +101,21 @@ public static async Task> GetVirtualMachineAsyn /// VirtualMachines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the virtual machine. /// The expand expression to apply on the operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetVirtualMachine(this ResourceGroupResource resourceGroupResource, string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetVirtualMachines().Get(vmName, expand, cancellationToken); + return GetMockableMgmtPropertyChooserResourceGroupResource(resourceGroupResource).GetVirtualMachine(vmName, expand, cancellationToken); } } } diff --git a/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MockableMgmtPropertyChooserArmClient.cs b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MockableMgmtPropertyChooserArmClient.cs new file mode 100644 index 00000000000..e5df4f7a7ba --- /dev/null +++ b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MockableMgmtPropertyChooserArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtPropertyChooser; + +namespace MgmtPropertyChooser.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtPropertyChooserArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPropertyChooserArmClient() + { + } + + /// 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 MockableMgmtPropertyChooserArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtPropertyChooserArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 VirtualMachineResource GetVirtualMachineResource(ResourceIdentifier id) + { + VirtualMachineResource.ValidateResourceId(id); + return new VirtualMachineResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MockableMgmtPropertyChooserResourceGroupResource.cs b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MockableMgmtPropertyChooserResourceGroupResource.cs new file mode 100644 index 00000000000..b424fc53b69 --- /dev/null +++ b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/MockableMgmtPropertyChooserResourceGroupResource.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtPropertyChooser; +using MgmtPropertyChooser.Models; + +namespace MgmtPropertyChooser.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtPropertyChooserResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtPropertyChooserResourceGroupResource() + { + } + + /// 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 MockableMgmtPropertyChooserResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. + /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. + public virtual VirtualMachineCollection GetVirtualMachines() + { + return GetCachedClient(client => new VirtualMachineCollection(client, Id)); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName} + /// + /// + /// Operation Id + /// VirtualMachines_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetVirtualMachineAsync(string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return await GetVirtualMachines().GetAsync(vmName, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves information about the model view or the instance view of a virtual machine. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName} + /// + /// + /// Operation Id + /// VirtualMachines_Get + /// + /// + /// + /// The name of the virtual machine. + /// The expand expression to apply on the operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetVirtualMachine(string vmName, InstanceViewType? expand = null, CancellationToken cancellationToken = default) + { + return GetVirtualMachines().Get(vmName, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 7cbaac79aa2..00000000000 --- a/test/TestProjects/MgmtPropertyChooser/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtPropertyChooser -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of VirtualMachineResources in the ResourceGroupResource. - /// An object representing collection of VirtualMachineResources and their operations over a VirtualMachineResource. - public virtual VirtualMachineCollection GetVirtualMachines() - { - return GetCachedClient(Client => new VirtualMachineCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtResourceName/Generated/Extensions/MgmtResourceNameExtensions.cs b/test/TestProjects/MgmtResourceName/Generated/Extensions/MgmtResourceNameExtensions.cs index e1523356799..c6b439e4965 100644 --- a/test/TestProjects/MgmtResourceName/Generated/Extensions/MgmtResourceNameExtensions.cs +++ b/test/TestProjects/MgmtResourceName/Generated/Extensions/MgmtResourceNameExtensions.cs @@ -12,163 +12,136 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtResourceName.Mocking; namespace MgmtResourceName { /// A class to add extension methods to MgmtResourceName. public static partial class MgmtResourceNameExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtResourceNameArmClient GetMockableMgmtResourceNameArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtResourceNameArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtResourceNameResourceGroupResource GetMockableMgmtResourceNameResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtResourceNameResourceGroupResource(client, resource.Id)); } - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmResource resource) + private static MockableMgmtResourceNameTenantResource GetMockableMgmtResourceNameTenantResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new TenantResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtResourceNameTenantResource(client, resource.Id)); } - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new TenantResourceExtensionClient(client, scope); - }); - } - #region MachineResource /// /// 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. /// Returns a object. public static MachineResource GetMachineResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - MachineResource.ValidateResourceId(id); - return new MachineResource(client, id); - } - ); + return GetMockableMgmtResourceNameArmClient(client).GetMachineResource(id); } - #endregion - #region Disk /// /// 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. /// Returns a object. public static Disk GetDisk(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - Disk.ValidateResourceId(id); - return new Disk(client, id); - } - ); + return GetMockableMgmtResourceNameArmClient(client).GetDisk(id); } - #endregion - #region Memory /// /// 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. /// Returns a object. public static Memory GetMemory(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - Memory.ValidateResourceId(id); - return new Memory(client, id); - } - ); + return GetMockableMgmtResourceNameArmClient(client).GetMemory(id); } - #endregion - #region NetworkResource /// /// 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. /// Returns a object. public static NetworkResource GetNetworkResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - NetworkResource.ValidateResourceId(id); - return new NetworkResource(client, id); - } - ); + return GetMockableMgmtResourceNameArmClient(client).GetNetworkResource(id); } - #endregion - #region DisplayResource /// /// 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. /// Returns a object. public static DisplayResource GetDisplayResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - DisplayResource.ValidateResourceId(id); - return new DisplayResource(client, id); - } - ); + return GetMockableMgmtResourceNameArmClient(client).GetDisplayResource(id); } - #endregion - #region ProviderOperationResource /// /// 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. /// Returns a object. public static ProviderOperationResource GetProviderOperationResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ProviderOperationResource.ValidateResourceId(id); - return new ProviderOperationResource(client, id); - } - ); + return GetMockableMgmtResourceNameArmClient(client).GetProviderOperationResource(id); } - #endregion - /// Gets a collection of MachineResources in the ResourceGroupResource. + /// + /// Gets a collection of MachineResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of MachineResources and their operations over a MachineResource. public static MachineCollection GetMachines(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetMachines(); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetMachines(); } /// @@ -182,16 +155,20 @@ public static MachineCollection GetMachines(this ResourceGroupResource resourceG /// Machines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetMachineAsync(this ResourceGroupResource resourceGroupResource, string machineName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetMachines().GetAsync(machineName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetMachineAsync(machineName, cancellationToken).ConfigureAwait(false); } /// @@ -205,24 +182,34 @@ public static async Task> GetMachineAsync(this Resourc /// Machines_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetMachine(this ResourceGroupResource resourceGroupResource, string machineName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetMachines().Get(machineName, cancellationToken); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetMachine(machineName, cancellationToken); } - /// Gets a collection of Disks in the ResourceGroupResource. + /// + /// Gets a collection of Disks in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of Disks and their operations over a Disk. public static DiskCollection GetDisks(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDisks(); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetDisks(); } /// @@ -236,16 +223,20 @@ public static DiskCollection GetDisks(this ResourceGroupResource resourceGroupRe /// Disks_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDiskAsync(this ResourceGroupResource resourceGroupResource, string diskResourceName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDisks().GetAsync(diskResourceName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetDiskAsync(diskResourceName, cancellationToken).ConfigureAwait(false); } /// @@ -259,24 +250,34 @@ public static async Task> GetDiskAsync(this ResourceGroupResource /// Disks_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDisk(this ResourceGroupResource resourceGroupResource, string diskResourceName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDisks().Get(diskResourceName, cancellationToken); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetDisk(diskResourceName, cancellationToken); } - /// Gets a collection of Memories in the ResourceGroupResource. + /// + /// Gets a collection of Memories in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of Memories and their operations over a Memory. public static MemoryCollection GetMemories(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetMemories(); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetMemories(); } /// @@ -290,16 +291,20 @@ public static MemoryCollection GetMemories(this ResourceGroupResource resourceGr /// MemoryResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetMemoryAsync(this ResourceGroupResource resourceGroupResource, string memoryResourceName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetMemories().GetAsync(memoryResourceName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetMemoryAsync(memoryResourceName, cancellationToken).ConfigureAwait(false); } /// @@ -313,24 +318,34 @@ public static async Task> GetMemoryAsync(this ResourceGroupReso /// MemoryResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetMemory(this ResourceGroupResource resourceGroupResource, string memoryResourceName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetMemories().Get(memoryResourceName, cancellationToken); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetMemory(memoryResourceName, cancellationToken); } - /// Gets a collection of NetworkResources in the ResourceGroupResource. + /// + /// Gets a collection of NetworkResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of NetworkResources and their operations over a NetworkResource. public static NetworkCollection GetNetworks(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetNetworks(); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetNetworks(); } /// @@ -344,16 +359,20 @@ public static NetworkCollection GetNetworks(this ResourceGroupResource resourceG /// networkResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetNetworkAsync(this ResourceGroupResource resourceGroupResource, string networkResourceName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetNetworks().GetAsync(networkResourceName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetNetworkAsync(networkResourceName, cancellationToken).ConfigureAwait(false); } /// @@ -367,24 +386,34 @@ public static async Task> GetNetworkAsync(this Resourc /// networkResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetNetwork(this ResourceGroupResource resourceGroupResource, string networkResourceName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetNetworks().Get(networkResourceName, cancellationToken); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetNetwork(networkResourceName, cancellationToken); } - /// Gets a collection of DisplayResources in the ResourceGroupResource. + /// + /// Gets a collection of DisplayResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DisplayResources and their operations over a DisplayResource. public static DisplayResourceCollection GetDisplayResources(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDisplayResources(); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetDisplayResources(); } /// @@ -398,16 +427,20 @@ public static DisplayResourceCollection GetDisplayResources(this ResourceGroupRe /// displayResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDisplayResourceAsync(this ResourceGroupResource resourceGroupResource, string displayResourceName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDisplayResources().GetAsync(displayResourceName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetDisplayResourceAsync(displayResourceName, cancellationToken).ConfigureAwait(false); } /// @@ -421,24 +454,34 @@ public static async Task> GetDisplayResourceAsync(this /// displayResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDisplayResource(this ResourceGroupResource resourceGroupResource, string displayResourceName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDisplayResources().Get(displayResourceName, cancellationToken); + return GetMockableMgmtResourceNameResourceGroupResource(resourceGroupResource).GetDisplayResource(displayResourceName, cancellationToken); } - /// Gets a collection of ProviderOperationResources in the TenantResource. + /// + /// Gets a collection of ProviderOperationResources in the TenantResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ProviderOperationResources and their operations over a ProviderOperationResource. public static ProviderOperationCollection GetProviderOperations(this TenantResource tenantResource) { - return GetTenantResourceExtensionClient(tenantResource).GetProviderOperations(); + return GetMockableMgmtResourceNameTenantResource(tenantResource).GetProviderOperations(); } /// @@ -453,17 +496,21 @@ public static ProviderOperationCollection GetProviderOperations(this TenantResou /// ProviderOperations_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The namespace of the resource provider. /// Specifies whether to expand the values. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetProviderOperationAsync(this TenantResource tenantResource, string resourceProviderNamespace, string expand = null, CancellationToken cancellationToken = default) { - return await tenantResource.GetProviderOperations().GetAsync(resourceProviderNamespace, expand, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtResourceNameTenantResource(tenantResource).GetProviderOperationAsync(resourceProviderNamespace, expand, cancellationToken).ConfigureAwait(false); } /// @@ -478,17 +525,21 @@ public static async Task> GetProviderOperati /// ProviderOperations_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The namespace of the resource provider. /// Specifies whether to expand the values. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetProviderOperation(this TenantResource tenantResource, string resourceProviderNamespace, string expand = null, CancellationToken cancellationToken = default) { - return tenantResource.GetProviderOperations().Get(resourceProviderNamespace, expand, cancellationToken); + return GetMockableMgmtResourceNameTenantResource(tenantResource).GetProviderOperation(resourceProviderNamespace, expand, cancellationToken); } } } diff --git a/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameArmClient.cs b/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameArmClient.cs new file mode 100644 index 00000000000..3a56ed6089f --- /dev/null +++ b/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameArmClient.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtResourceName; + +namespace MgmtResourceName.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtResourceNameArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtResourceNameArmClient() + { + } + + /// 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 MockableMgmtResourceNameArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtResourceNameArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 MachineResource GetMachineResource(ResourceIdentifier id) + { + MachineResource.ValidateResourceId(id); + return new MachineResource(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 Disk GetDisk(ResourceIdentifier id) + { + Disk.ValidateResourceId(id); + return new Disk(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 Memory GetMemory(ResourceIdentifier id) + { + Memory.ValidateResourceId(id); + return new Memory(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 NetworkResource GetNetworkResource(ResourceIdentifier id) + { + NetworkResource.ValidateResourceId(id); + return new NetworkResource(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 DisplayResource GetDisplayResource(ResourceIdentifier id) + { + DisplayResource.ValidateResourceId(id); + return new DisplayResource(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 ProviderOperationResource GetProviderOperationResource(ResourceIdentifier id) + { + ProviderOperationResource.ValidateResourceId(id); + return new ProviderOperationResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameResourceGroupResource.cs b/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameResourceGroupResource.cs new file mode 100644 index 00000000000..f3fe3b5f9da --- /dev/null +++ b/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameResourceGroupResource.cs @@ -0,0 +1,294 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtResourceName; + +namespace MgmtResourceName.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtResourceNameResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtResourceNameResourceGroupResource() + { + } + + /// 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 MockableMgmtResourceNameResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of MachineResources in the ResourceGroupResource. + /// An object representing collection of MachineResources and their operations over a MachineResource. + public virtual MachineCollection GetMachines() + { + return GetCachedClient(client => new MachineCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/machines/{machineName} + /// + /// + /// Operation Id + /// Machines_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMachineAsync(string machineName, CancellationToken cancellationToken = default) + { + return await GetMachines().GetAsync(machineName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/machines/{machineName} + /// + /// + /// Operation Id + /// Machines_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMachine(string machineName, CancellationToken cancellationToken = default) + { + return GetMachines().Get(machineName, cancellationToken); + } + + /// Gets a collection of Disks in the ResourceGroupResource. + /// An object representing collection of Disks and their operations over a Disk. + public virtual DiskCollection GetDisks() + { + return GetCachedClient(client => new DiskCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskResources/{diskResourceName} + /// + /// + /// Operation Id + /// Disks_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDiskAsync(string diskResourceName, CancellationToken cancellationToken = default) + { + return await GetDisks().GetAsync(diskResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskResources/{diskResourceName} + /// + /// + /// Operation Id + /// Disks_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDisk(string diskResourceName, CancellationToken cancellationToken = default) + { + return GetDisks().Get(diskResourceName, cancellationToken); + } + + /// Gets a collection of Memories in the ResourceGroupResource. + /// An object representing collection of Memories and their operations over a Memory. + public virtual MemoryCollection GetMemories() + { + return GetCachedClient(client => new MemoryCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/memoryResources/{memoryResourceName} + /// + /// + /// Operation Id + /// MemoryResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMemoryAsync(string memoryResourceName, CancellationToken cancellationToken = default) + { + return await GetMemories().GetAsync(memoryResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/memoryResources/{memoryResourceName} + /// + /// + /// Operation Id + /// MemoryResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMemory(string memoryResourceName, CancellationToken cancellationToken = default) + { + return GetMemories().Get(memoryResourceName, cancellationToken); + } + + /// Gets a collection of NetworkResources in the ResourceGroupResource. + /// An object representing collection of NetworkResources and their operations over a NetworkResource. + public virtual NetworkCollection GetNetworks() + { + return GetCachedClient(client => new NetworkCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/networkResources/{networkResourceName} + /// + /// + /// Operation Id + /// networkResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNetworkAsync(string networkResourceName, CancellationToken cancellationToken = default) + { + return await GetNetworks().GetAsync(networkResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/networkResources/{networkResourceName} + /// + /// + /// Operation Id + /// networkResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNetwork(string networkResourceName, CancellationToken cancellationToken = default) + { + return GetNetworks().Get(networkResourceName, cancellationToken); + } + + /// Gets a collection of DisplayResources in the ResourceGroupResource. + /// An object representing collection of DisplayResources and their operations over a DisplayResource. + public virtual DisplayResourceCollection GetDisplayResources() + { + return GetCachedClient(client => new DisplayResourceCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/displayResources/{displayResourceName} + /// + /// + /// Operation Id + /// displayResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDisplayResourceAsync(string displayResourceName, CancellationToken cancellationToken = default) + { + return await GetDisplayResources().GetAsync(displayResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/displayResources/{displayResourceName} + /// + /// + /// Operation Id + /// displayResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDisplayResource(string displayResourceName, CancellationToken cancellationToken = default) + { + return GetDisplayResources().Get(displayResourceName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameTenantResource.cs b/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameTenantResource.cs new file mode 100644 index 00000000000..0711ef60d6e --- /dev/null +++ b/test/TestProjects/MgmtResourceName/Generated/Extensions/MockableMgmtResourceNameTenantResource.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtResourceName; + +namespace MgmtResourceName.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableMgmtResourceNameTenantResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtResourceNameTenantResource() + { + } + + /// 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 MockableMgmtResourceNameTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ProviderOperationResources in the TenantResource. + /// An object representing collection of ProviderOperationResources and their operations over a ProviderOperationResource. + public virtual ProviderOperationCollection GetProviderOperations() + { + return GetCachedClient(client => new ProviderOperationCollection(client, Id)); + } + + /// + /// Gets provider operations metadata for the specified resource provider. + /// + /// + /// Request Path + /// /providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace} + /// + /// + /// Operation Id + /// ProviderOperations_Get + /// + /// + /// + /// The namespace of the resource provider. + /// Specifies whether to expand the values. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetProviderOperationAsync(string resourceProviderNamespace, string expand = null, CancellationToken cancellationToken = default) + { + return await GetProviderOperations().GetAsync(resourceProviderNamespace, expand, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets provider operations metadata for the specified resource provider. + /// + /// + /// Request Path + /// /providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace} + /// + /// + /// Operation Id + /// ProviderOperations_Get + /// + /// + /// + /// The namespace of the resource provider. + /// Specifies whether to expand the values. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetProviderOperation(string resourceProviderNamespace, string expand = null, CancellationToken cancellationToken = default) + { + return GetProviderOperations().Get(resourceProviderNamespace, expand, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtResourceName/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtResourceName/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index a38460ffc84..00000000000 --- a/test/TestProjects/MgmtResourceName/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtResourceName -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of MachineResources in the ResourceGroupResource. - /// An object representing collection of MachineResources and their operations over a MachineResource. - public virtual MachineCollection GetMachines() - { - return GetCachedClient(Client => new MachineCollection(Client, Id)); - } - - /// Gets a collection of Disks in the ResourceGroupResource. - /// An object representing collection of Disks and their operations over a Disk. - public virtual DiskCollection GetDisks() - { - return GetCachedClient(Client => new DiskCollection(Client, Id)); - } - - /// Gets a collection of Memories in the ResourceGroupResource. - /// An object representing collection of Memories and their operations over a Memory. - public virtual MemoryCollection GetMemories() - { - return GetCachedClient(Client => new MemoryCollection(Client, Id)); - } - - /// Gets a collection of NetworkResources in the ResourceGroupResource. - /// An object representing collection of NetworkResources and their operations over a NetworkResource. - public virtual NetworkCollection GetNetworks() - { - return GetCachedClient(Client => new NetworkCollection(Client, Id)); - } - - /// Gets a collection of DisplayResources in the ResourceGroupResource. - /// An object representing collection of DisplayResources and their operations over a DisplayResource. - public virtual DisplayResourceCollection GetDisplayResources() - { - return GetCachedClient(Client => new DisplayResourceCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtResourceName/Generated/Extensions/TenantResourceExtensionClient.cs b/test/TestProjects/MgmtResourceName/Generated/Extensions/TenantResourceExtensionClient.cs deleted file mode 100644 index 90cb8d0d5c3..00000000000 --- a/test/TestProjects/MgmtResourceName/Generated/Extensions/TenantResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtResourceName -{ - /// A class to add extension methods to TenantResource. - internal partial class TenantResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected TenantResourceExtensionClient() - { - } - - /// 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 TenantResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of ProviderOperationResources in the TenantResource. - /// An object representing collection of ProviderOperationResources and their operations over a ProviderOperationResource. - public virtual ProviderOperationCollection GetProviderOperations() - { - return GetCachedClient(Client => new ProviderOperationCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MgmtSafeFlattenExtensions.cs b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MgmtSafeFlattenExtensions.cs index 29b33344b5d..1f754287575 100644 --- a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MgmtSafeFlattenExtensions.cs +++ b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MgmtSafeFlattenExtensions.cs @@ -12,87 +12,72 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtSafeFlatten.Mocking; namespace MgmtSafeFlatten { /// A class to add extension methods to MgmtSafeFlatten. public static partial class MgmtSafeFlattenExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtSafeFlattenArmClient GetMockableMgmtSafeFlattenArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtSafeFlattenArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtSafeFlattenResourceGroupResource GetMockableMgmtSafeFlattenResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtSafeFlattenResourceGroupResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + private static MockableMgmtSafeFlattenSubscriptionResource GetMockableMgmtSafeFlattenSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtSafeFlattenSubscriptionResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - #region TypeOneResource /// /// 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. /// Returns a object. public static TypeOneResource GetTypeOneResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TypeOneResource.ValidateResourceId(id); - return new TypeOneResource(client, id); - } - ); + return GetMockableMgmtSafeFlattenArmClient(client).GetTypeOneResource(id); } - #endregion - #region TypeTwoResource /// /// 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. /// Returns a object. public static TypeTwoResource GetTypeTwoResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TypeTwoResource.ValidateResourceId(id); - return new TypeTwoResource(client, id); - } - ); + return GetMockableMgmtSafeFlattenArmClient(client).GetTypeTwoResource(id); } - #endregion - /// Gets a collection of TypeOneResources in the ResourceGroupResource. + /// + /// Gets a collection of TypeOneResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TypeOneResources and their operations over a TypeOneResource. public static TypeOneCollection GetTypeOnes(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTypeOnes(); + return GetMockableMgmtSafeFlattenResourceGroupResource(resourceGroupResource).GetTypeOnes(); } /// @@ -107,16 +92,20 @@ public static TypeOneCollection GetTypeOnes(this ResourceGroupResource resourceG /// Common_GetTypeOne /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTypeOneAsync(this ResourceGroupResource resourceGroupResource, string typeOneName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetTypeOnes().GetAsync(typeOneName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSafeFlattenResourceGroupResource(resourceGroupResource).GetTypeOneAsync(typeOneName, cancellationToken).ConfigureAwait(false); } /// @@ -131,24 +120,34 @@ public static async Task> GetTypeOneAsync(this Resourc /// Common_GetTypeOne /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTypeOne(this ResourceGroupResource resourceGroupResource, string typeOneName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetTypeOnes().Get(typeOneName, cancellationToken); + return GetMockableMgmtSafeFlattenResourceGroupResource(resourceGroupResource).GetTypeOne(typeOneName, cancellationToken); } - /// Gets a collection of TypeTwoResources in the ResourceGroupResource. + /// + /// Gets a collection of TypeTwoResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TypeTwoResources and their operations over a TypeTwoResource. public static TypeTwoCollection GetTypeTwos(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTypeTwos(); + return GetMockableMgmtSafeFlattenResourceGroupResource(resourceGroupResource).GetTypeTwos(); } /// @@ -163,16 +162,20 @@ public static TypeTwoCollection GetTypeTwos(this ResourceGroupResource resourceG /// Common_GetTypeTwo /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTypeTwoAsync(this ResourceGroupResource resourceGroupResource, string typeTwoName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetTypeTwos().GetAsync(typeTwoName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSafeFlattenResourceGroupResource(resourceGroupResource).GetTypeTwoAsync(typeTwoName, cancellationToken).ConfigureAwait(false); } /// @@ -187,16 +190,20 @@ public static async Task> GetTypeTwoAsync(this Resourc /// Common_GetTypeTwo /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTypeTwo(this ResourceGroupResource resourceGroupResource, string typeTwoName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetTypeTwos().Get(typeTwoName, cancellationToken); + return GetMockableMgmtSafeFlattenResourceGroupResource(resourceGroupResource).GetTypeTwo(typeTwoName, cancellationToken); } /// @@ -211,13 +218,17 @@ public static Response GetTypeTwo(this ResourceGroupResource re /// Common_ListTypeOnesBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTypeOnesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeOnesAsync(cancellationToken); + return GetMockableMgmtSafeFlattenSubscriptionResource(subscriptionResource).GetTypeOnesAsync(cancellationToken); } /// @@ -232,13 +243,17 @@ public static AsyncPageable GetTypeOnesAsync(this SubscriptionR /// Common_ListTypeOnesBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTypeOnes(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeOnes(cancellationToken); + return GetMockableMgmtSafeFlattenSubscriptionResource(subscriptionResource).GetTypeOnes(cancellationToken); } /// @@ -253,13 +268,17 @@ public static Pageable GetTypeOnes(this SubscriptionResource su /// Common_ListTypeTwosBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTypeTwosAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeTwosAsync(cancellationToken); + return GetMockableMgmtSafeFlattenSubscriptionResource(subscriptionResource).GetTypeTwosAsync(cancellationToken); } /// @@ -274,13 +293,17 @@ public static AsyncPageable GetTypeTwosAsync(this SubscriptionR /// Common_ListTypeTwosBySubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTypeTwos(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetTypeTwos(cancellationToken); + return GetMockableMgmtSafeFlattenSubscriptionResource(subscriptionResource).GetTypeTwos(cancellationToken); } } } diff --git a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenArmClient.cs b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenArmClient.cs new file mode 100644 index 00000000000..8456c0115b0 --- /dev/null +++ b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtSafeFlatten; + +namespace MgmtSafeFlatten.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtSafeFlattenArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSafeFlattenArmClient() + { + } + + /// 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 MockableMgmtSafeFlattenArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtSafeFlattenArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 TypeOneResource GetTypeOneResource(ResourceIdentifier id) + { + TypeOneResource.ValidateResourceId(id); + return new TypeOneResource(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 TypeTwoResource GetTypeTwoResource(ResourceIdentifier id) + { + TypeTwoResource.ValidateResourceId(id); + return new TypeTwoResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenResourceGroupResource.cs b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenResourceGroupResource.cs new file mode 100644 index 00000000000..3fc088900db --- /dev/null +++ b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenResourceGroupResource.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtSafeFlatten; + +namespace MgmtSafeFlatten.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtSafeFlattenResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSafeFlattenResourceGroupResource() + { + } + + /// 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 MockableMgmtSafeFlattenResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of TypeOneResources in the ResourceGroupResource. + /// An object representing collection of TypeOneResources and their operations over a TypeOneResource. + public virtual TypeOneCollection GetTypeOnes() + { + return GetCachedClient(client => new TypeOneCollection(client, Id)); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeOne/typeOnes/{typeOneName} + /// + /// + /// Operation Id + /// Common_GetTypeOne + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTypeOneAsync(string typeOneName, CancellationToken cancellationToken = default) + { + return await GetTypeOnes().GetAsync(typeOneName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeOne/typeOnes/{typeOneName} + /// + /// + /// Operation Id + /// Common_GetTypeOne + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTypeOne(string typeOneName, CancellationToken cancellationToken = default) + { + return GetTypeOnes().Get(typeOneName, cancellationToken); + } + + /// Gets a collection of TypeTwoResources in the ResourceGroupResource. + /// An object representing collection of TypeTwoResources and their operations over a TypeTwoResource. + public virtual TypeTwoCollection GetTypeTwos() + { + return GetCachedClient(client => new TypeTwoCollection(client, Id)); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeTwo/typeTwos/{typeTwoName} + /// + /// + /// Operation Id + /// Common_GetTypeTwo + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTypeTwoAsync(string typeTwoName, CancellationToken cancellationToken = default) + { + return await GetTypeTwos().GetAsync(typeTwoName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Description for Validate information for a certificate order. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TypeTwo/typeTwos/{typeTwoName} + /// + /// + /// Operation Id + /// Common_GetTypeTwo + /// + /// + /// + /// The name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTypeTwo(string typeTwoName, CancellationToken cancellationToken = default) + { + return GetTypeTwos().Get(typeTwoName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenSubscriptionResource.cs similarity index 88% rename from test/TestProjects/MgmtSafeFlatten/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenSubscriptionResource.cs index d8442c3ebd9..9b041f46558 100644 --- a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/MockableMgmtSafeFlattenSubscriptionResource.cs @@ -11,26 +11,27 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtSafeFlatten; -namespace MgmtSafeFlatten +namespace MgmtSafeFlatten.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtSafeFlattenSubscriptionResource : ArmResource { private ClientDiagnostics _typeOneCommonClientDiagnostics; private CommonRestOperations _typeOneCommonRestClient; private ClientDiagnostics _typeTwoCommonClientDiagnostics; private CommonRestOperations _typeTwoCommonRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSafeFlattenSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtSafeFlattenSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -63,7 +64,7 @@ private string GetApiVersionOrNull(ResourceType resourceType) public virtual AsyncPageable GetTypeOnesAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeOneCommonRestClient.CreateListTypeOnesBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeOnes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "MockableMgmtSafeFlattenSubscriptionResource.GetTypeOnes", "value", null, cancellationToken); } /// @@ -84,7 +85,7 @@ public virtual AsyncPageable GetTypeOnesAsync(CancellationToken public virtual Pageable GetTypeOnes(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeOneCommonRestClient.CreateListTypeOnesBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeOnes", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeOneResource(Client, TypeOneData.DeserializeTypeOneData(e)), TypeOneCommonClientDiagnostics, Pipeline, "MockableMgmtSafeFlattenSubscriptionResource.GetTypeOnes", "value", null, cancellationToken); } /// @@ -105,7 +106,7 @@ public virtual Pageable GetTypeOnes(CancellationToken cancellat public virtual AsyncPageable GetTypeTwosAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeTwoCommonRestClient.CreateListTypeTwosBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeTwos", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "MockableMgmtSafeFlattenSubscriptionResource.GetTypeTwos", "value", null, cancellationToken); } /// @@ -126,7 +127,7 @@ public virtual AsyncPageable GetTypeTwosAsync(CancellationToken public virtual Pageable GetTypeTwos(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TypeTwoCommonRestClient.CreateListTypeTwosBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetTypeTwos", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TypeTwoResource(Client, TypeTwoData.DeserializeTypeTwoData(e)), TypeTwoCommonClientDiagnostics, Pipeline, "MockableMgmtSafeFlattenSubscriptionResource.GetTypeTwos", "value", null, cancellationToken); } } } diff --git a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 90f90fc45cf..00000000000 --- a/test/TestProjects/MgmtSafeFlatten/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtSafeFlatten -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of TypeOneResources in the ResourceGroupResource. - /// An object representing collection of TypeOneResources and their operations over a TypeOneResource. - public virtual TypeOneCollection GetTypeOnes() - { - return GetCachedClient(Client => new TypeOneCollection(Client, Id)); - } - - /// Gets a collection of TypeTwoResources in the ResourceGroupResource. - /// An object representing collection of TypeTwoResources and their operations over a TypeTwoResource. - public virtual TypeTwoCollection GetTypeTwos() - { - return GetCachedClient(Client => new TypeTwoCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/ArmResourceExtensionClient.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/ArmResourceExtensionClient.cs deleted file mode 100644 index 2cb272a0042..00000000000 --- a/test/TestProjects/MgmtScopeResource/Generated/Extensions/ArmResourceExtensionClient.cs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Threading; -using Autorest.CSharp.Core; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager; -using MgmtScopeResource.Models; - -namespace MgmtScopeResource -{ - /// A class to add extension methods to ArmResource. - internal partial class ArmResourceExtensionClient : ArmResource - { - private ClientDiagnostics _resourceLinkClientDiagnostics; - private ResourceLinksRestOperations _resourceLinkRestClient; - private ClientDiagnostics _marketplacesClientDiagnostics; - private MarketplacesRestOperations _marketplacesRestClient; - - /// Initializes a new instance of the class for mocking. - protected ArmResourceExtensionClient() - { - } - - /// 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 ArmResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private ClientDiagnostics ResourceLinkClientDiagnostics => _resourceLinkClientDiagnostics ??= new ClientDiagnostics("MgmtScopeResource", ResourceLinkResource.ResourceType.Namespace, Diagnostics); - private ResourceLinksRestOperations ResourceLinkRestClient => _resourceLinkRestClient ??= new ResourceLinksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(ResourceLinkResource.ResourceType)); - private ClientDiagnostics MarketplacesClientDiagnostics => _marketplacesClientDiagnostics ??= new ClientDiagnostics("MgmtScopeResource", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private MarketplacesRestOperations MarketplacesRestClient => _marketplacesRestClient ??= new MarketplacesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of FakePolicyAssignmentResources in the ArmResource. - /// An object representing collection of FakePolicyAssignmentResources and their operations over a FakePolicyAssignmentResource. - public virtual FakePolicyAssignmentCollection GetFakePolicyAssignments() - { - return GetCachedClient(Client => new FakePolicyAssignmentCollection(Client, Id)); - } - - /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it in the ArmResource. - /// Returns a object. - public virtual VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatus() - { - return new VMInsightsOnboardingStatusResource(Client, Id.AppendProviderResource("Microsoft.Insights", "vmInsightsOnboardingStatuses", "default")); - } - - /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. - /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. - public virtual GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments() - { - return GetCachedClient(Client => new GuestConfigurationAssignmentCollection(Client, Id)); - } - - /// - /// Gets a list of resource links at and below the specified source scope. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Resources/links - /// - /// - /// Operation Id - /// ResourceLinks_ListAtSourceScope - /// - /// - /// - /// The filter to apply when getting resource links. To get links only at the specified scope (not below the scope), use Filter.atScope(). - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetAllAsync(Filter? filter = null, CancellationToken cancellationToken = default) - { - Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceLinkRestClient.CreateListAtSourceScopeRequest(Id, filter); - Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResourceLinkRestClient.CreateListAtSourceScopeNextPageRequest(nextLink, Id, filter); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "ArmResourceExtensionClient.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Gets a list of resource links at and below the specified source scope. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Resources/links - /// - /// - /// Operation Id - /// ResourceLinks_ListAtSourceScope - /// - /// - /// - /// The filter to apply when getting resource links. To get links only at the specified scope (not below the scope), use Filter.atScope(). - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetAll(Filter? filter = null, CancellationToken cancellationToken = default) - { - Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceLinkRestClient.CreateListAtSourceScopeRequest(Id, filter); - Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResourceLinkRestClient.CreateListAtSourceScopeNextPageRequest(nextLink, Id, filter); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "ArmResourceExtensionClient.GetAll", "value", "nextLink", cancellationToken); - } - - /// - /// Lists the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Consumption/marketplaces - /// - /// - /// Operation Id - /// Marketplaces_List - /// - /// - /// - /// May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. - /// May be used to limit the number of results to the most recent N marketplaces. - /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetMarketplacesAsync(string filter = null, int? top = null, string skiptoken = null, CancellationToken cancellationToken = default) - { - Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => MarketplacesRestClient.CreateListRequest(Id, filter, top, skiptoken); - Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => MarketplacesRestClient.CreateListNextPageRequest(nextLink, Id, filter, top, skiptoken); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, Marketplace.DeserializeMarketplace, MarketplacesClientDiagnostics, Pipeline, "ArmResourceExtensionClient.GetMarketplaces", "value", "nextLink", cancellationToken); - } - - /// - /// Lists the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. - /// - /// - /// Request Path - /// /{scope}/providers/Microsoft.Consumption/marketplaces - /// - /// - /// Operation Id - /// Marketplaces_List - /// - /// - /// - /// May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. - /// May be used to limit the number of results to the most recent N marketplaces. - /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetMarketplaces(string filter = null, int? top = null, string skiptoken = null, CancellationToken cancellationToken = default) - { - Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => MarketplacesRestClient.CreateListRequest(Id, filter, top, skiptoken); - Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => MarketplacesRestClient.CreateListNextPageRequest(nextLink, Id, filter, top, skiptoken); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, Marketplace.DeserializeMarketplace, MarketplacesClientDiagnostics, Pipeline, "ArmResourceExtensionClient.GetMarketplaces", "value", "nextLink", cancellationToken); - } - } -} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/ManagementGroupResourceExtensionClient.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/ManagementGroupResourceExtensionClient.cs deleted file mode 100644 index 177368d9d36..00000000000 --- a/test/TestProjects/MgmtScopeResource/Generated/Extensions/ManagementGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtScopeResource -{ - /// A class to add extension methods to ManagementGroupResource. - internal partial class ManagementGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ManagementGroupResourceExtensionClient() - { - } - - /// 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 ManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of DeploymentExtendedResources in the ManagementGroupResource. - /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. - public virtual DeploymentExtendedCollection GetDeploymentExtendeds() - { - return GetCachedClient(Client => new DeploymentExtendedCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MgmtScopeResourceExtensions.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MgmtScopeResourceExtensions.cs index 6030c066e3f..e8e82222a56 100644 --- a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MgmtScopeResourceExtensions.cs +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MgmtScopeResourceExtensions.cs @@ -13,6 +13,7 @@ using Azure.ResourceManager; using Azure.ResourceManager.ManagementGroups; using Azure.ResourceManager.Resources; +using MgmtScopeResource.Mocking; using MgmtScopeResource.Models; namespace MgmtScopeResource @@ -20,195 +21,49 @@ namespace MgmtScopeResource /// A class to add extension methods to MgmtScopeResource. public static partial class MgmtScopeResourceExtensions { - private static ArmResourceExtensionClient GetArmResourceExtensionClient(ArmResource resource) + private static MockableMgmtScopeResourceArmClient GetMockableMgmtScopeResourceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ArmResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtScopeResourceArmClient(client0)); } - private static ArmResourceExtensionClient GetArmResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtScopeResourceArmResource GetMockableMgmtScopeResourceArmResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ArmResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtScopeResourceArmResource(client, resource.Id)); } - private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtScopeResourceManagementGroupResource GetMockableMgmtScopeResourceManagementGroupResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new ManagementGroupResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtScopeResourceManagementGroupResource(client, resource.Id)); } - private static ManagementGroupResourceExtensionClient GetManagementGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtScopeResourceResourceGroupResource GetMockableMgmtScopeResourceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ManagementGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtScopeResourceResourceGroupResource(client, resource.Id)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtScopeResourceSubscriptionResource GetMockableMgmtScopeResourceSubscriptionResource(ArmResource resource) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return resource.GetCachedClient(client => new MockableMgmtScopeResourceSubscriptionResource(client, resource.Id)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtScopeResourceTenantResource GetMockableMgmtScopeResourceTenantResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtScopeResourceTenantResource(client, resource.Id)); } - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) - { - return resource.GetCachedClient(client => - { - return new SubscriptionResourceExtensionClient(client, resource.Id); - }); - } - - private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new SubscriptionResourceExtensionClient(client, scope); - }); - } - - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmResource resource) - { - return resource.GetCachedClient(client => - { - return new TenantResourceExtensionClient(client, resource.Id); - }); - } - - private static TenantResourceExtensionClient GetTenantResourceExtensionClient(ArmClient client, ResourceIdentifier scope) - { - return client.GetResourceClient(() => - { - return new TenantResourceExtensionClient(client, scope); - }); - } - #region FakePolicyAssignmentResource /// - /// 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 instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static FakePolicyAssignmentResource GetFakePolicyAssignmentResource(this ArmClient client, ResourceIdentifier id) - { - return client.GetResourceClient(() => - { - FakePolicyAssignmentResource.ValidateResourceId(id); - return new FakePolicyAssignmentResource(client, id); - } - ); - } - #endregion - - #region DeploymentExtendedResource - /// - /// 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 instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static DeploymentExtendedResource GetDeploymentExtendedResource(this ArmClient client, ResourceIdentifier id) - { - return client.GetResourceClient(() => - { - DeploymentExtendedResource.ValidateResourceId(id); - return new DeploymentExtendedResource(client, id); - } - ); - } - #endregion - - #region ResourceLinkResource - /// - /// 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 instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static ResourceLinkResource GetResourceLinkResource(this ArmClient client, ResourceIdentifier id) - { - return client.GetResourceClient(() => - { - ResourceLinkResource.ValidateResourceId(id); - return new ResourceLinkResource(client, id); - } - ); - } - #endregion - - #region VMInsightsOnboardingStatusResource - /// - /// 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 instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatusResource(this ArmClient client, ResourceIdentifier id) - { - return client.GetResourceClient(() => - { - VMInsightsOnboardingStatusResource.ValidateResourceId(id); - return new VMInsightsOnboardingStatusResource(client, id); - } - ); - } - #endregion - - #region GuestConfigurationAssignmentResource - /// - /// 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 FakePolicyAssignmentResources in the ArmClient. + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static GuestConfigurationAssignmentResource GetGuestConfigurationAssignmentResource(this ArmClient client, ResourceIdentifier id) - { - return client.GetResourceClient(() => - { - GuestConfigurationAssignmentResource.ValidateResourceId(id); - return new GuestConfigurationAssignmentResource(client, id); - } - ); - } - #endregion - - /// Gets a collection of FakePolicyAssignmentResources in the ArmResource. - /// The instance the method will execute against. - /// An object representing collection of FakePolicyAssignmentResources and their operations over a FakePolicyAssignmentResource. - public static FakePolicyAssignmentCollection GetFakePolicyAssignments(this ArmResource armResource) - { - return GetArmResourceExtensionClient(armResource).GetFakePolicyAssignments(); - } - - /// Gets a collection of FakePolicyAssignmentResources in the ArmResource. - /// The instance the method will execute against. /// The scope that the resource will apply against. /// An object representing collection of FakePolicyAssignmentResources and their operations over a FakePolicyAssignmentResource. public static FakePolicyAssignmentCollection GetFakePolicyAssignments(this ArmClient client, ResourceIdentifier scope) { - return GetArmResourceExtensionClient(client, scope).GetFakePolicyAssignments(); + return GetMockableMgmtScopeResourceArmClient(client).GetFakePolicyAssignments(scope); } /// @@ -223,41 +78,21 @@ public static FakePolicyAssignmentCollection GetFakePolicyAssignments(this ArmCl /// FakePolicyAssignments_Get /// /// - /// - /// The instance the method will execute against. - /// The name of the policy assignment to get. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static async Task> GetFakePolicyAssignmentAsync(this ArmResource armResource, string policyAssignmentName, CancellationToken cancellationToken = default) - { - return await armResource.GetFakePolicyAssignments().GetAsync(policyAssignmentName, cancellationToken).ConfigureAwait(false); - } - - /// - /// This operation retrieves a single policy assignment, given its name and the scope it was created at. - /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// Mocking + /// To mock this method, please mock instead. /// - /// - /// Operation Id - /// FakePolicyAssignments_Get - /// - /// /// /// The instance the method will execute against. /// The scope that the resource will apply against. /// The name of the policy assignment to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetFakePolicyAssignmentAsync(this ArmClient client, ResourceIdentifier scope, string policyAssignmentName, CancellationToken cancellationToken = default) { - return await client.GetFakePolicyAssignments(scope).GetAsync(policyAssignmentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceArmClient(client).GetFakePolicyAssignmentAsync(scope, policyAssignmentName, cancellationToken).ConfigureAwait(false); } /// @@ -272,79 +107,51 @@ public static async Task> GetFakePolicyAs /// FakePolicyAssignments_Get /// /// - /// - /// The instance the method will execute against. - /// The name of the policy assignment to get. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static Response GetFakePolicyAssignment(this ArmResource armResource, string policyAssignmentName, CancellationToken cancellationToken = default) - { - return armResource.GetFakePolicyAssignments().Get(policyAssignmentName, cancellationToken); - } - - /// - /// This operation retrieves a single policy assignment, given its name and the scope it was created at. - /// /// - /// Request Path - /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// Mocking + /// To mock this method, please mock instead. /// - /// - /// Operation Id - /// FakePolicyAssignments_Get - /// - /// /// /// The instance the method will execute against. /// The scope that the resource will apply against. /// The name of the policy assignment to get. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetFakePolicyAssignment(this ArmClient client, ResourceIdentifier scope, string policyAssignmentName, CancellationToken cancellationToken = default) { - return client.GetFakePolicyAssignments(scope).Get(policyAssignmentName, cancellationToken); + return GetMockableMgmtScopeResourceArmClient(client).GetFakePolicyAssignment(scope, policyAssignmentName, cancellationToken); } - /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it in the ArmResource. - /// The instance the method will execute against. - /// Returns a object. - public static VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatus(this ArmResource armResource) - { - return GetArmResourceExtensionClient(armResource).GetVMInsightsOnboardingStatus(); - } - - /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it in the ArmResource. + /// + /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it 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. /// Returns a object. public static VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatus(this ArmClient client, ResourceIdentifier scope) { - return GetArmResourceExtensionClient(client, scope).GetVMInsightsOnboardingStatus(); + return GetMockableMgmtScopeResourceArmClient(client).GetVMInsightsOnboardingStatus(scope); } - /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. - /// The instance the method will execute against. - /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. - public static GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(this ArmResource armResource) - { - return GetArmResourceExtensionClient(armResource).GetGuestConfigurationAssignments(); - } - - /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. + /// + /// Gets a collection of GuestConfigurationAssignmentResources 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.Compute/virtualMachines. /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. public static GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(this ArmClient client, ResourceIdentifier scope) { - if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) - { - throw new ArgumentException(string.Format("Invalid resource type {0} expected Microsoft.Compute/virtualMachines", scope.ResourceType)); - } - return GetArmResourceExtensionClient(client, scope).GetGuestConfigurationAssignments(); + return GetMockableMgmtScopeResourceArmClient(client).GetGuestConfigurationAssignments(scope); } /// @@ -359,45 +166,21 @@ public static GuestConfigurationAssignmentCollection GetGuestConfigurationAssign /// GuestConfigurationAssignments_Get /// /// - /// - /// The instance the method will execute against. - /// The guest configuration assignment name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static async Task> GetGuestConfigurationAssignmentAsync(this ArmResource armResource, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) - { - return await armResource.GetGuestConfigurationAssignments().GetAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get information about a guest configuration assignment - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} - /// - /// - /// Operation Id - /// GuestConfigurationAssignments_Get + /// 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.Compute/virtualMachines. /// The guest configuration assignment name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetGuestConfigurationAssignmentAsync(this ArmClient client, ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) { - if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) - { - throw new ArgumentException(string.Format("Invalid resource type {0} expected Microsoft.Compute/virtualMachines", scope.ResourceType)); - } - return await client.GetGuestConfigurationAssignments(scope).GetAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceArmClient(client).GetGuestConfigurationAssignmentAsync(scope, guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); } /// @@ -412,45 +195,21 @@ public static async Task> GetGues /// GuestConfigurationAssignments_Get /// /// - /// - /// The instance the method will execute against. - /// The guest configuration assignment name. - /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. - /// is null. - [ForwardsClientCalls] - public static Response GetGuestConfigurationAssignment(this ArmResource armResource, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) - { - return armResource.GetGuestConfigurationAssignments().Get(guestConfigurationAssignmentName, cancellationToken); - } - - /// - /// Get information about a guest configuration assignment - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} - /// /// - /// Operation Id - /// GuestConfigurationAssignments_Get + /// 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.Compute/virtualMachines. /// The guest configuration assignment name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetGuestConfigurationAssignment(this ArmClient client, ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) { - if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) - { - throw new ArgumentException(string.Format("Invalid resource type {0} expected Microsoft.Compute/virtualMachines", scope.ResourceType)); - } - return client.GetGuestConfigurationAssignments(scope).Get(guestConfigurationAssignmentName, cancellationToken); + return GetMockableMgmtScopeResourceArmClient(client).GetGuestConfigurationAssignment(scope, guestConfigurationAssignmentName, cancellationToken); } /// @@ -465,6 +224,10 @@ public static Response GetGuestConfigurati /// ResourceLinks_ListAtSourceScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The scope that the resource will apply against. @@ -472,7 +235,7 @@ public static Response GetGuestConfigurati /// The cancellation token to use. public static AsyncPageable GetAllAsync(this ArmClient client, ResourceIdentifier scope, Filter? filter = null, CancellationToken cancellationToken = default) { - return GetArmResourceExtensionClient(client, scope).GetAllAsync(filter, cancellationToken); + return GetMockableMgmtScopeResourceArmClient(client).GetAllAsync(scope, filter, cancellationToken); } /// @@ -487,6 +250,10 @@ public static AsyncPageable GetAllAsync(this ArmClient cli /// ResourceLinks_ListAtSourceScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The scope that the resource will apply against. @@ -494,7 +261,7 @@ public static AsyncPageable GetAllAsync(this ArmClient cli /// The cancellation token to use. public static Pageable GetAll(this ArmClient client, ResourceIdentifier scope, Filter? filter = null, CancellationToken cancellationToken = default) { - return GetArmResourceExtensionClient(client, scope).GetAll(filter, cancellationToken); + return GetMockableMgmtScopeResourceArmClient(client).GetAll(scope, filter, cancellationToken); } /// @@ -509,6 +276,10 @@ public static Pageable GetAll(this ArmClient client, Resou /// Marketplaces_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The scope that the resource will apply against. @@ -518,7 +289,7 @@ public static Pageable GetAll(this ArmClient client, Resou /// The cancellation token to use. public static AsyncPageable GetMarketplacesAsync(this ArmClient client, ResourceIdentifier scope, string filter = null, int? top = null, string skiptoken = null, CancellationToken cancellationToken = default) { - return GetArmResourceExtensionClient(client, scope).GetMarketplacesAsync(filter, top, skiptoken, cancellationToken); + return GetMockableMgmtScopeResourceArmClient(client).GetMarketplacesAsync(scope, filter, top, skiptoken, cancellationToken); } /// @@ -533,6 +304,10 @@ public static AsyncPageable GetMarketplacesAsync(this ArmClient cli /// Marketplaces_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The scope that the resource will apply against. @@ -542,15 +317,255 @@ public static AsyncPageable GetMarketplacesAsync(this ArmClient cli /// The cancellation token to use. public static Pageable GetMarketplaces(this ArmClient client, ResourceIdentifier scope, string filter = null, int? top = null, string skiptoken = null, CancellationToken cancellationToken = default) { - return GetArmResourceExtensionClient(client, scope).GetMarketplaces(filter, top, skiptoken, cancellationToken); + return GetMockableMgmtScopeResourceArmClient(client).GetMarketplaces(scope, filter, top, skiptoken, 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. + /// Returns a object. + public static FakePolicyAssignmentResource GetFakePolicyAssignmentResource(this ArmClient client, ResourceIdentifier id) + { + return GetMockableMgmtScopeResourceArmClient(client).GetFakePolicyAssignmentResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static DeploymentExtendedResource GetDeploymentExtendedResource(this ArmClient client, ResourceIdentifier id) + { + return GetMockableMgmtScopeResourceArmClient(client).GetDeploymentExtendedResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ResourceLinkResource GetResourceLinkResource(this ArmClient client, ResourceIdentifier id) + { + return GetMockableMgmtScopeResourceArmClient(client).GetResourceLinkResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatusResource(this ArmClient client, ResourceIdentifier id) + { + return GetMockableMgmtScopeResourceArmClient(client).GetVMInsightsOnboardingStatusResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static GuestConfigurationAssignmentResource GetGuestConfigurationAssignmentResource(this ArmClient client, ResourceIdentifier id) + { + return GetMockableMgmtScopeResourceArmClient(client).GetGuestConfigurationAssignmentResource(id); + } + + /// + /// Gets a collection of FakePolicyAssignmentResources in the ArmResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// An object representing collection of FakePolicyAssignmentResources and their operations over a FakePolicyAssignmentResource. + public static FakePolicyAssignmentCollection GetFakePolicyAssignments(this ArmResource armResource) + { + return GetMockableMgmtScopeResourceArmResource(armResource).GetFakePolicyAssignments(); + } + + /// + /// This operation retrieves a single policy assignment, given its name and the scope it was created at. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// + /// + /// Operation Id + /// FakePolicyAssignments_Get + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the policy assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetFakePolicyAssignmentAsync(this ArmResource armResource, string policyAssignmentName, CancellationToken cancellationToken = default) + { + return await GetMockableMgmtScopeResourceArmResource(armResource).GetFakePolicyAssignmentAsync(policyAssignmentName, cancellationToken).ConfigureAwait(false); } - /// Gets a collection of DeploymentExtendedResources in the ManagementGroupResource. + /// + /// This operation retrieves a single policy assignment, given its name and the scope it was created at. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// + /// + /// Operation Id + /// FakePolicyAssignments_Get + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the policy assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetFakePolicyAssignment(this ArmResource armResource, string policyAssignmentName, CancellationToken cancellationToken = default) + { + return GetMockableMgmtScopeResourceArmResource(armResource).GetFakePolicyAssignment(policyAssignmentName, cancellationToken); + } + + /// + /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it in the ArmResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Returns a object. + public static VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatus(this ArmResource armResource) + { + return GetMockableMgmtScopeResourceArmResource(armResource).GetVMInsightsOnboardingStatus(); + } + + /// + /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. + public static GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(this ArmResource armResource) + { + return GetMockableMgmtScopeResourceArmResource(armResource).GetGuestConfigurationAssignments(); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetGuestConfigurationAssignmentAsync(this ArmResource armResource, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return await GetMockableMgmtScopeResourceArmResource(armResource).GetGuestConfigurationAssignmentAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetGuestConfigurationAssignment(this ArmResource armResource, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return GetMockableMgmtScopeResourceArmResource(armResource).GetGuestConfigurationAssignment(guestConfigurationAssignmentName, cancellationToken); + } + + /// + /// Gets a collection of DeploymentExtendedResources in the ManagementGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. public static DeploymentExtendedCollection GetDeploymentExtendeds(this ManagementGroupResource managementGroupResource) { - return GetManagementGroupResourceExtensionClient(managementGroupResource).GetDeploymentExtendeds(); + return GetMockableMgmtScopeResourceManagementGroupResource(managementGroupResource).GetDeploymentExtendeds(); } /// @@ -565,16 +580,20 @@ public static DeploymentExtendedCollection GetDeploymentExtendeds(this Managemen /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeploymentExtendedAsync(this ManagementGroupResource managementGroupResource, string deploymentName, CancellationToken cancellationToken = default) { - return await managementGroupResource.GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceManagementGroupResource(managementGroupResource).GetDeploymentExtendedAsync(deploymentName, cancellationToken).ConfigureAwait(false); } /// @@ -589,24 +608,34 @@ public static async Task> GetDeploymentExte /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeploymentExtended(this ManagementGroupResource managementGroupResource, string deploymentName, CancellationToken cancellationToken = default) { - return managementGroupResource.GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + return GetMockableMgmtScopeResourceManagementGroupResource(managementGroupResource).GetDeploymentExtended(deploymentName, cancellationToken); } - /// Gets a collection of DeploymentExtendedResources in the ResourceGroupResource. + /// + /// Gets a collection of DeploymentExtendedResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. public static DeploymentExtendedCollection GetDeploymentExtendeds(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetDeploymentExtendeds(); + return GetMockableMgmtScopeResourceResourceGroupResource(resourceGroupResource).GetDeploymentExtendeds(); } /// @@ -621,16 +650,20 @@ public static DeploymentExtendedCollection GetDeploymentExtendeds(this ResourceG /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeploymentExtendedAsync(this ResourceGroupResource resourceGroupResource, string deploymentName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceResourceGroupResource(resourceGroupResource).GetDeploymentExtendedAsync(deploymentName, cancellationToken).ConfigureAwait(false); } /// @@ -645,24 +678,34 @@ public static async Task> GetDeploymentExte /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeploymentExtended(this ResourceGroupResource resourceGroupResource, string deploymentName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + return GetMockableMgmtScopeResourceResourceGroupResource(resourceGroupResource).GetDeploymentExtended(deploymentName, cancellationToken); } - /// Gets a collection of DeploymentExtendedResources in the SubscriptionResource. + /// + /// Gets a collection of DeploymentExtendedResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. public static DeploymentExtendedCollection GetDeploymentExtendeds(this SubscriptionResource subscriptionResource) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetDeploymentExtendeds(); + return GetMockableMgmtScopeResourceSubscriptionResource(subscriptionResource).GetDeploymentExtendeds(); } /// @@ -677,16 +720,20 @@ public static DeploymentExtendedCollection GetDeploymentExtendeds(this Subscript /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeploymentExtendedAsync(this SubscriptionResource subscriptionResource, string deploymentName, CancellationToken cancellationToken = default) { - return await subscriptionResource.GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceSubscriptionResource(subscriptionResource).GetDeploymentExtendedAsync(deploymentName, cancellationToken).ConfigureAwait(false); } /// @@ -701,16 +748,20 @@ public static async Task> GetDeploymentExte /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeploymentExtended(this SubscriptionResource subscriptionResource, string deploymentName, CancellationToken cancellationToken = default) { - return subscriptionResource.GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + return GetMockableMgmtScopeResourceSubscriptionResource(subscriptionResource).GetDeploymentExtended(deploymentName, cancellationToken); } /// @@ -725,6 +776,10 @@ public static Response GetDeploymentExtended(this Su /// ResourceLinks_ListAtSubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The filter to apply on the list resource links operation. The supported filter for list resource links is targetId. For example, $filter=targetId eq {value}. @@ -732,7 +787,7 @@ public static Response GetDeploymentExtended(this Su /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResourceLinksAsync(this SubscriptionResource subscriptionResource, string filter = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResourceLinksAsync(filter, cancellationToken); + return GetMockableMgmtScopeResourceSubscriptionResource(subscriptionResource).GetResourceLinksAsync(filter, cancellationToken); } /// @@ -747,6 +802,10 @@ public static AsyncPageable GetResourceLinksAsync(this Sub /// ResourceLinks_ListAtSubscription /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The filter to apply on the list resource links operation. The supported filter for list resource links is targetId. For example, $filter=targetId eq {value}. @@ -754,15 +813,21 @@ public static AsyncPageable GetResourceLinksAsync(this Sub /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResourceLinks(this SubscriptionResource subscriptionResource, string filter = null, CancellationToken cancellationToken = default) { - return GetSubscriptionResourceExtensionClient(subscriptionResource).GetResourceLinks(filter, cancellationToken); + return GetMockableMgmtScopeResourceSubscriptionResource(subscriptionResource).GetResourceLinks(filter, cancellationToken); } - /// Gets a collection of DeploymentExtendedResources in the TenantResource. + /// + /// Gets a collection of DeploymentExtendedResources in the TenantResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. public static DeploymentExtendedCollection GetDeploymentExtendeds(this TenantResource tenantResource) { - return GetTenantResourceExtensionClient(tenantResource).GetDeploymentExtendeds(); + return GetMockableMgmtScopeResourceTenantResource(tenantResource).GetDeploymentExtendeds(); } /// @@ -777,16 +842,20 @@ public static DeploymentExtendedCollection GetDeploymentExtendeds(this TenantRes /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetDeploymentExtendedAsync(this TenantResource tenantResource, string deploymentName, CancellationToken cancellationToken = default) { - return await tenantResource.GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceTenantResource(tenantResource).GetDeploymentExtendedAsync(deploymentName, cancellationToken).ConfigureAwait(false); } /// @@ -801,28 +870,36 @@ public static async Task> GetDeploymentExte /// Deployments_GetAtScope /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the deployment. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetDeploymentExtended(this TenantResource tenantResource, string deploymentName, CancellationToken cancellationToken = default) { - return tenantResource.GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + return GetMockableMgmtScopeResourceTenantResource(tenantResource).GetDeploymentExtended(deploymentName, cancellationToken); } - /// Gets a collection of ResourceLinkResources in the TenantResource. + /// + /// Gets a collection of ResourceLinkResources in the TenantResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. /// is null. /// An object representing collection of ResourceLinkResources and their operations over a ResourceLinkResource. public static ResourceLinkCollection GetResourceLinks(this TenantResource tenantResource, string scope) { - Argument.AssertNotNull(scope, nameof(scope)); - - return GetTenantResourceExtensionClient(tenantResource).GetResourceLinks(scope); + return GetMockableMgmtScopeResourceTenantResource(tenantResource).GetResourceLinks(scope); } /// @@ -837,6 +914,10 @@ public static ResourceLinkCollection GetResourceLinks(this TenantResource tenant /// ResourceLinks_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. @@ -845,7 +926,7 @@ public static ResourceLinkCollection GetResourceLinks(this TenantResource tenant [ForwardsClientCalls] public static async Task> GetResourceLinkAsync(this TenantResource tenantResource, string scope, CancellationToken cancellationToken = default) { - return await tenantResource.GetResourceLinks(scope).GetAsync(cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceTenantResource(tenantResource).GetResourceLinkAsync(scope, cancellationToken).ConfigureAwait(false); } /// @@ -860,6 +941,10 @@ public static async Task> GetResourceLinkAsync(th /// ResourceLinks_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. @@ -868,7 +953,7 @@ public static async Task> GetResourceLinkAsync(th [ForwardsClientCalls] public static Response GetResourceLink(this TenantResource tenantResource, string scope, CancellationToken cancellationToken = default) { - return tenantResource.GetResourceLinks(scope).Get(cancellationToken); + return GetMockableMgmtScopeResourceTenantResource(tenantResource).GetResourceLink(scope, cancellationToken); } /// @@ -883,6 +968,10 @@ public static Response GetResourceLink(this TenantResource /// Deployments_CalculateTemplateHash /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The template provided to calculate hash. @@ -890,9 +979,7 @@ public static Response GetResourceLink(this TenantResource /// is null. public static async Task> CalculateTemplateHashDeploymentAsync(this TenantResource tenantResource, BinaryData template, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(template, nameof(template)); - - return await GetTenantResourceExtensionClient(tenantResource).CalculateTemplateHashDeploymentAsync(template, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtScopeResourceTenantResource(tenantResource).CalculateTemplateHashDeploymentAsync(template, cancellationToken).ConfigureAwait(false); } /// @@ -907,6 +994,10 @@ public static async Task> CalculateTemplateHashDepl /// Deployments_CalculateTemplateHash /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The template provided to calculate hash. @@ -914,9 +1005,7 @@ public static async Task> CalculateTemplateHashDepl /// is null. public static Response CalculateTemplateHashDeployment(this TenantResource tenantResource, BinaryData template, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(template, nameof(template)); - - return GetTenantResourceExtensionClient(tenantResource).CalculateTemplateHashDeployment(template, cancellationToken); + return GetMockableMgmtScopeResourceTenantResource(tenantResource).CalculateTemplateHashDeployment(template, cancellationToken); } } } diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceArmClient.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceArmClient.cs new file mode 100644 index 00000000000..ba838a128fc --- /dev/null +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceArmClient.cs @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using MgmtScopeResource; +using MgmtScopeResource.Models; + +namespace MgmtScopeResource.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtScopeResourceArmClient : ArmResource + { + private ClientDiagnostics _resourceLinkClientDiagnostics; + private ResourceLinksRestOperations _resourceLinkRestClient; + private ClientDiagnostics _marketplacesClientDiagnostics; + private MarketplacesRestOperations _marketplacesRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableMgmtScopeResourceArmClient() + { + } + + /// 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 MockableMgmtScopeResourceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtScopeResourceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private ClientDiagnostics ResourceLinkClientDiagnostics => _resourceLinkClientDiagnostics ??= new ClientDiagnostics("MgmtScopeResource", ResourceLinkResource.ResourceType.Namespace, Diagnostics); + private ResourceLinksRestOperations ResourceLinkRestClient => _resourceLinkRestClient ??= new ResourceLinksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(ResourceLinkResource.ResourceType)); + private ClientDiagnostics MarketplacesClientDiagnostics => _marketplacesClientDiagnostics ??= new ClientDiagnostics("MgmtScopeResource", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private MarketplacesRestOperations MarketplacesRestClient => _marketplacesRestClient ??= new MarketplacesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of FakePolicyAssignmentResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of FakePolicyAssignmentResources and their operations over a FakePolicyAssignmentResource. + public virtual FakePolicyAssignmentCollection GetFakePolicyAssignments(ResourceIdentifier scope) + { + return new FakePolicyAssignmentCollection(Client, scope); + } + + /// + /// This operation retrieves a single policy assignment, given its name and the scope it was created at. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// + /// + /// Operation Id + /// FakePolicyAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the policy assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetFakePolicyAssignmentAsync(ResourceIdentifier scope, string policyAssignmentName, CancellationToken cancellationToken = default) + { + return await GetFakePolicyAssignments(scope).GetAsync(policyAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// This operation retrieves a single policy assignment, given its name and the scope it was created at. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// + /// + /// Operation Id + /// FakePolicyAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The name of the policy assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetFakePolicyAssignment(ResourceIdentifier scope, string policyAssignmentName, CancellationToken cancellationToken = default) + { + return GetFakePolicyAssignments(scope).Get(policyAssignmentName, cancellationToken); + } + + /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it in the ArmClient. + /// The scope that the resource will apply against. + /// Returns a object. + public virtual VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatus(ResourceIdentifier scope) + { + return new VMInsightsOnboardingStatusResource(Client, scope.AppendProviderResource("Microsoft.Insights", "vmInsightsOnboardingStatuses", "default")); + } + + /// Gets a collection of GuestConfigurationAssignmentResources in the ArmClient. + /// The scope that the resource will apply against. + /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. + public virtual GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments(ResourceIdentifier scope) + { + if (!scope.ResourceType.Equals("Microsoft.Compute/virtualMachines")) + { + throw new ArgumentException(string.Format("Invalid resource type {0}, expected Microsoft.Compute/virtualMachines", scope.ResourceType)); + } + return new GuestConfigurationAssignmentCollection(Client, scope); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetGuestConfigurationAssignmentAsync(ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return await GetGuestConfigurationAssignments(scope).GetAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// The scope that the resource will apply against. + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetGuestConfigurationAssignment(ResourceIdentifier scope, string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return GetGuestConfigurationAssignments(scope).Get(guestConfigurationAssignmentName, cancellationToken); + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/links + /// + /// + /// Operation Id + /// ResourceLinks_ListAtSourceScope + /// + /// + /// + /// The scope to use. + /// The filter to apply when getting resource links. To get links only at the specified scope (not below the scope), use Filter.atScope(). + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(ResourceIdentifier scope, Filter? filter = null, CancellationToken cancellationToken = default) + { + Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceLinkRestClient.CreateListAtSourceScopeRequest(scope, filter); + Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResourceLinkRestClient.CreateListAtSourceScopeNextPageRequest(nextLink, scope, filter); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "MockableMgmtScopeResourceArmClient.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets a list of resource links at and below the specified source scope. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/links + /// + /// + /// Operation Id + /// ResourceLinks_ListAtSourceScope + /// + /// + /// + /// The scope to use. + /// The filter to apply when getting resource links. To get links only at the specified scope (not below the scope), use Filter.atScope(). + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(ResourceIdentifier scope, Filter? filter = null, CancellationToken cancellationToken = default) + { + Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceLinkRestClient.CreateListAtSourceScopeRequest(scope, filter); + Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResourceLinkRestClient.CreateListAtSourceScopeNextPageRequest(nextLink, scope, filter); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "MockableMgmtScopeResourceArmClient.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Consumption/marketplaces + /// + /// + /// Operation Id + /// Marketplaces_List + /// + /// + /// + /// The scope to use. + /// May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// May be used to limit the number of results to the most recent N marketplaces. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetMarketplacesAsync(ResourceIdentifier scope, string filter = null, int? top = null, string skiptoken = null, CancellationToken cancellationToken = default) + { + Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => MarketplacesRestClient.CreateListRequest(scope, filter, top, skiptoken); + Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => MarketplacesRestClient.CreateListNextPageRequest(nextLink, scope, filter, top, skiptoken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, Marketplace.DeserializeMarketplace, MarketplacesClientDiagnostics, Pipeline, "MockableMgmtScopeResourceArmClient.GetMarketplaces", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Consumption/marketplaces + /// + /// + /// Operation Id + /// Marketplaces_List + /// + /// + /// + /// The scope to use. + /// May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + /// May be used to limit the number of results to the most recent N marketplaces. + /// Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetMarketplaces(ResourceIdentifier scope, string filter = null, int? top = null, string skiptoken = null, CancellationToken cancellationToken = default) + { + Azure.Core.HttpMessage FirstPageRequest(int? pageSizeHint) => MarketplacesRestClient.CreateListRequest(scope, filter, top, skiptoken); + Azure.Core.HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => MarketplacesRestClient.CreateListNextPageRequest(nextLink, scope, filter, top, skiptoken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, Marketplace.DeserializeMarketplace, MarketplacesClientDiagnostics, Pipeline, "MockableMgmtScopeResourceArmClient.GetMarketplaces", "value", "nextLink", 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 FakePolicyAssignmentResource GetFakePolicyAssignmentResource(ResourceIdentifier id) + { + FakePolicyAssignmentResource.ValidateResourceId(id); + return new FakePolicyAssignmentResource(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 DeploymentExtendedResource GetDeploymentExtendedResource(ResourceIdentifier id) + { + DeploymentExtendedResource.ValidateResourceId(id); + return new DeploymentExtendedResource(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 ResourceLinkResource GetResourceLinkResource(ResourceIdentifier id) + { + ResourceLinkResource.ValidateResourceId(id); + return new ResourceLinkResource(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 VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatusResource(ResourceIdentifier id) + { + VMInsightsOnboardingStatusResource.ValidateResourceId(id); + return new VMInsightsOnboardingStatusResource(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 GuestConfigurationAssignmentResource GetGuestConfigurationAssignmentResource(ResourceIdentifier id) + { + GuestConfigurationAssignmentResource.ValidateResourceId(id); + return new GuestConfigurationAssignmentResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceArmResource.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceArmResource.cs new file mode 100644 index 00000000000..a8d1876707b --- /dev/null +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceArmResource.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtScopeResource; + +namespace MgmtScopeResource.Mocking +{ + /// A class to add extension methods to ArmResource. + public partial class MockableMgmtScopeResourceArmResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtScopeResourceArmResource() + { + } + + /// 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 MockableMgmtScopeResourceArmResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of FakePolicyAssignmentResources in the ArmResource. + /// An object representing collection of FakePolicyAssignmentResources and their operations over a FakePolicyAssignmentResource. + public virtual FakePolicyAssignmentCollection GetFakePolicyAssignments() + { + return GetCachedClient(client => new FakePolicyAssignmentCollection(client, Id)); + } + + /// + /// This operation retrieves a single policy assignment, given its name and the scope it was created at. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// + /// + /// Operation Id + /// FakePolicyAssignments_Get + /// + /// + /// + /// The name of the policy assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetFakePolicyAssignmentAsync(string policyAssignmentName, CancellationToken cancellationToken = default) + { + return await GetFakePolicyAssignments().GetAsync(policyAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// This operation retrieves a single policy assignment, given its name and the scope it was created at. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName} + /// + /// + /// Operation Id + /// FakePolicyAssignments_Get + /// + /// + /// + /// The name of the policy assignment to get. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetFakePolicyAssignment(string policyAssignmentName, CancellationToken cancellationToken = default) + { + return GetFakePolicyAssignments().Get(policyAssignmentName, cancellationToken); + } + + /// Gets an object representing a VMInsightsOnboardingStatusResource along with the instance operations that can be performed on it in the ArmResource. + /// Returns a object. + public virtual VMInsightsOnboardingStatusResource GetVMInsightsOnboardingStatus() + { + return new VMInsightsOnboardingStatusResource(Client, Id.AppendProviderResource("Microsoft.Insights", "vmInsightsOnboardingStatuses", "default")); + } + + /// Gets a collection of GuestConfigurationAssignmentResources in the ArmResource. + /// An object representing collection of GuestConfigurationAssignmentResources and their operations over a GuestConfigurationAssignmentResource. + public virtual GuestConfigurationAssignmentCollection GetGuestConfigurationAssignments() + { + return GetCachedClient(client => new GuestConfigurationAssignmentCollection(client, Id)); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetGuestConfigurationAssignmentAsync(string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return await GetGuestConfigurationAssignments().GetAsync(guestConfigurationAssignmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get information about a guest configuration assignment + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName} + /// + /// + /// Operation Id + /// GuestConfigurationAssignments_Get + /// + /// + /// + /// The guest configuration assignment name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetGuestConfigurationAssignment(string guestConfigurationAssignmentName, CancellationToken cancellationToken = default) + { + return GetGuestConfigurationAssignments().Get(guestConfigurationAssignmentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceManagementGroupResource.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceManagementGroupResource.cs new file mode 100644 index 00000000000..2605ab8009e --- /dev/null +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceManagementGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtScopeResource; + +namespace MgmtScopeResource.Mocking +{ + /// A class to add extension methods to ManagementGroupResource. + public partial class MockableMgmtScopeResourceManagementGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtScopeResourceManagementGroupResource() + { + } + + /// 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 MockableMgmtScopeResourceManagementGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of DeploymentExtendedResources in the ManagementGroupResource. + /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. + public virtual DeploymentExtendedCollection GetDeploymentExtendeds() + { + return GetCachedClient(client => new DeploymentExtendedCollection(client, Id)); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeploymentExtendedAsync(string deploymentName, CancellationToken cancellationToken = default) + { + return await GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeploymentExtended(string deploymentName, CancellationToken cancellationToken = default) + { + return GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceResourceGroupResource.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceResourceGroupResource.cs new file mode 100644 index 00000000000..f18f0cfedea --- /dev/null +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceResourceGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtScopeResource; + +namespace MgmtScopeResource.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtScopeResourceResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtScopeResourceResourceGroupResource() + { + } + + /// 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 MockableMgmtScopeResourceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of DeploymentExtendedResources in the ResourceGroupResource. + /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. + public virtual DeploymentExtendedCollection GetDeploymentExtendeds() + { + return GetCachedClient(client => new DeploymentExtendedCollection(client, Id)); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeploymentExtendedAsync(string deploymentName, CancellationToken cancellationToken = default) + { + return await GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeploymentExtended(string deploymentName, CancellationToken cancellationToken = default) + { + return GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceSubscriptionResource.cs similarity index 60% rename from test/TestProjects/MgmtScopeResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs rename to test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceSubscriptionResource.cs index 0f52adfb97b..7ee88b2b5af 100644 --- a/test/TestProjects/MgmtScopeResource/Generated/Extensions/SubscriptionResourceExtensionClient.cs +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceSubscriptionResource.cs @@ -5,30 +5,33 @@ #nullable disable +using System; using System.Threading; +using System.Threading.Tasks; using Autorest.CSharp.Core; using Azure; using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtScopeResource; -namespace MgmtScopeResource +namespace MgmtScopeResource.Mocking { /// A class to add extension methods to SubscriptionResource. - internal partial class SubscriptionResourceExtensionClient : ArmResource + public partial class MockableMgmtScopeResourceSubscriptionResource : ArmResource { private ClientDiagnostics _resourceLinkClientDiagnostics; private ResourceLinksRestOperations _resourceLinkRestClient; - /// Initializes a new instance of the class for mocking. - protected SubscriptionResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtScopeResourceSubscriptionResource() { } - /// Initializes a new instance of the class. + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtScopeResourceSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -45,7 +48,53 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. public virtual DeploymentExtendedCollection GetDeploymentExtendeds() { - return GetCachedClient(Client => new DeploymentExtendedCollection(Client, Id)); + return GetCachedClient(client => new DeploymentExtendedCollection(client, Id)); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeploymentExtendedAsync(string deploymentName, CancellationToken cancellationToken = default) + { + return await GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeploymentExtended(string deploymentName, CancellationToken cancellationToken = default) + { + return GetDeploymentExtendeds().Get(deploymentName, cancellationToken); } /// @@ -68,7 +117,7 @@ public virtual AsyncPageable GetResourceLinksAsync(string { HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceLinkRestClient.CreateListAtSubscriptionRequest(Id.SubscriptionId, filter); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResourceLinkRestClient.CreateListAtSubscriptionNextPageRequest(nextLink, Id.SubscriptionId, filter); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResourceLinks", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "MockableMgmtScopeResourceSubscriptionResource.GetResourceLinks", "value", "nextLink", cancellationToken); } /// @@ -91,7 +140,7 @@ public virtual Pageable GetResourceLinks(string filter = n { HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceLinkRestClient.CreateListAtSubscriptionRequest(Id.SubscriptionId, filter); HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => ResourceLinkRestClient.CreateListAtSubscriptionNextPageRequest(nextLink, Id.SubscriptionId, filter); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetResourceLinks", "value", "nextLink", cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceLinkResource(Client, ResourceLinkData.DeserializeResourceLinkData(e)), ResourceLinkClientDiagnostics, Pipeline, "MockableMgmtScopeResourceSubscriptionResource.GetResourceLinks", "value", "nextLink", cancellationToken); } } } diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceTenantResource.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceTenantResource.cs new file mode 100644 index 00000000000..5cbd8ebd1dc --- /dev/null +++ b/test/TestProjects/MgmtScopeResource/Generated/Extensions/MockableMgmtScopeResourceTenantResource.cs @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using MgmtScopeResource; +using MgmtScopeResource.Models; + +namespace MgmtScopeResource.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableMgmtScopeResourceTenantResource : ArmResource + { + private ClientDiagnostics _deploymentExtendedDeploymentsClientDiagnostics; + private DeploymentsRestOperations _deploymentExtendedDeploymentsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableMgmtScopeResourceTenantResource() + { + } + + /// 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 MockableMgmtScopeResourceTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics DeploymentExtendedDeploymentsClientDiagnostics => _deploymentExtendedDeploymentsClientDiagnostics ??= new ClientDiagnostics("MgmtScopeResource", DeploymentExtendedResource.ResourceType.Namespace, Diagnostics); + private DeploymentsRestOperations DeploymentExtendedDeploymentsRestClient => _deploymentExtendedDeploymentsRestClient ??= new DeploymentsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(DeploymentExtendedResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of DeploymentExtendedResources in the TenantResource. + /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. + public virtual DeploymentExtendedCollection GetDeploymentExtendeds() + { + return GetCachedClient(client => new DeploymentExtendedCollection(client, Id)); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDeploymentExtendedAsync(string deploymentName, CancellationToken cancellationToken = default) + { + return await GetDeploymentExtendeds().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// Request Path + /// /{scope}/providers/Microsoft.Resources/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_GetAtScope + /// + /// + /// + /// The name of the deployment. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDeploymentExtended(string deploymentName, CancellationToken cancellationToken = default) + { + return GetDeploymentExtendeds().Get(deploymentName, cancellationToken); + } + + /// Gets a collection of ResourceLinkResources in the TenantResource. + /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// is null. + /// An object representing collection of ResourceLinkResources and their operations over a ResourceLinkResource. + public virtual ResourceLinkCollection GetResourceLinks(string scope) + { + return new ResourceLinkCollection(Client, Id, scope); + } + + /// + /// Gets a resource link with the specified ID. + /// + /// + /// Request Path + /// /{linkId} + /// + /// + /// Operation Id + /// ResourceLinks_Get + /// + /// + /// + /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetResourceLinkAsync(string scope, CancellationToken cancellationToken = default) + { + return await GetResourceLinks(scope).GetAsync(cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a resource link with the specified ID. + /// + /// + /// Request Path + /// /{linkId} + /// + /// + /// Operation Id + /// ResourceLinks_Get + /// + /// + /// + /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public virtual Response GetResourceLink(string scope, CancellationToken cancellationToken = default) + { + return GetResourceLinks(scope).Get(cancellationToken); + } + + /// + /// Calculate the hash of the given template. + /// + /// + /// Request Path + /// /providers/Microsoft.Resources/calculateTemplateHash + /// + /// + /// Operation Id + /// Deployments_CalculateTemplateHash + /// + /// + /// + /// The template provided to calculate hash. + /// The cancellation token to use. + /// is null. + public virtual async Task> CalculateTemplateHashDeploymentAsync(BinaryData template, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(template, nameof(template)); + + using var scope = DeploymentExtendedDeploymentsClientDiagnostics.CreateScope("MockableMgmtScopeResourceTenantResource.CalculateTemplateHashDeployment"); + scope.Start(); + try + { + var response = await DeploymentExtendedDeploymentsRestClient.CalculateTemplateHashAsync(template, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Calculate the hash of the given template. + /// + /// + /// Request Path + /// /providers/Microsoft.Resources/calculateTemplateHash + /// + /// + /// Operation Id + /// Deployments_CalculateTemplateHash + /// + /// + /// + /// The template provided to calculate hash. + /// The cancellation token to use. + /// is null. + public virtual Response CalculateTemplateHashDeployment(BinaryData template, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(template, nameof(template)); + + using var scope = DeploymentExtendedDeploymentsClientDiagnostics.CreateScope("MockableMgmtScopeResourceTenantResource.CalculateTemplateHashDeployment"); + scope.Start(); + try + { + var response = DeploymentExtendedDeploymentsRestClient.CalculateTemplateHash(template, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 4568810e393..00000000000 --- a/test/TestProjects/MgmtScopeResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtScopeResource -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of DeploymentExtendedResources in the ResourceGroupResource. - /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. - public virtual DeploymentExtendedCollection GetDeploymentExtendeds() - { - return GetCachedClient(Client => new DeploymentExtendedCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtScopeResource/Generated/Extensions/TenantResourceExtensionClient.cs b/test/TestProjects/MgmtScopeResource/Generated/Extensions/TenantResourceExtensionClient.cs deleted file mode 100644 index 94fe433ddae..00000000000 --- a/test/TestProjects/MgmtScopeResource/Generated/Extensions/TenantResourceExtensionClient.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager; -using MgmtScopeResource.Models; - -namespace MgmtScopeResource -{ - /// A class to add extension methods to TenantResource. - internal partial class TenantResourceExtensionClient : ArmResource - { - private ClientDiagnostics _deploymentExtendedDeploymentsClientDiagnostics; - private DeploymentsRestOperations _deploymentExtendedDeploymentsRestClient; - - /// Initializes a new instance of the class for mocking. - protected TenantResourceExtensionClient() - { - } - - /// 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 TenantResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private ClientDiagnostics DeploymentExtendedDeploymentsClientDiagnostics => _deploymentExtendedDeploymentsClientDiagnostics ??= new ClientDiagnostics("MgmtScopeResource", DeploymentExtendedResource.ResourceType.Namespace, Diagnostics); - private DeploymentsRestOperations DeploymentExtendedDeploymentsRestClient => _deploymentExtendedDeploymentsRestClient ??= new DeploymentsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(DeploymentExtendedResource.ResourceType)); - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of DeploymentExtendedResources in the TenantResource. - /// An object representing collection of DeploymentExtendedResources and their operations over a DeploymentExtendedResource. - public virtual DeploymentExtendedCollection GetDeploymentExtendeds() - { - return GetCachedClient(Client => new DeploymentExtendedCollection(Client, Id)); - } - - /// Gets a collection of ResourceLinkResources in the TenantResource. - /// The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and under a resource group, set the scope to /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. - /// An object representing collection of ResourceLinkResources and their operations over a ResourceLinkResource. - public virtual ResourceLinkCollection GetResourceLinks(string scope) - { - return new ResourceLinkCollection(Client, Id, scope); - } - - /// - /// Calculate the hash of the given template. - /// - /// - /// Request Path - /// /providers/Microsoft.Resources/calculateTemplateHash - /// - /// - /// Operation Id - /// Deployments_CalculateTemplateHash - /// - /// - /// - /// The template provided to calculate hash. - /// The cancellation token to use. - public virtual async Task> CalculateTemplateHashDeploymentAsync(BinaryData template, CancellationToken cancellationToken = default) - { - using var scope = DeploymentExtendedDeploymentsClientDiagnostics.CreateScope("TenantResourceExtensionClient.CalculateTemplateHashDeployment"); - scope.Start(); - try - { - var response = await DeploymentExtendedDeploymentsRestClient.CalculateTemplateHashAsync(template, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Calculate the hash of the given template. - /// - /// - /// Request Path - /// /providers/Microsoft.Resources/calculateTemplateHash - /// - /// - /// Operation Id - /// Deployments_CalculateTemplateHash - /// - /// - /// - /// The template provided to calculate hash. - /// The cancellation token to use. - public virtual Response CalculateTemplateHashDeployment(BinaryData template, CancellationToken cancellationToken = default) - { - using var scope = DeploymentExtendedDeploymentsClientDiagnostics.CreateScope("TenantResourceExtensionClient.CalculateTemplateHashDeployment"); - scope.Start(); - try - { - var response = DeploymentExtendedDeploymentsRestClient.CalculateTemplateHash(template, cancellationToken); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MgmtSingletonResourceExtensions.cs b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MgmtSingletonResourceExtensions.cs index 00d7041a2f5..25c72c9a717 100644 --- a/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MgmtSingletonResourceExtensions.cs +++ b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MgmtSingletonResourceExtensions.cs @@ -12,128 +12,115 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtSingletonResource.Mocking; namespace MgmtSingletonResource { /// A class to add extension methods to MgmtSingletonResource. public static partial class MgmtSingletonResourceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtSingletonResourceArmClient GetMockableMgmtSingletonResourceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtSingletonResourceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtSingletonResourceResourceGroupResource GetMockableMgmtSingletonResourceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtSingletonResourceResourceGroupResource(client, resource.Id)); } - #region CarResource + /// /// 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. /// Returns a object. public static CarResource GetCarResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - CarResource.ValidateResourceId(id); - return new CarResource(client, id); - } - ); + return GetMockableMgmtSingletonResourceArmClient(client).GetCarResource(id); } - #endregion - #region IgnitionResource /// /// Gets an object representing an along with the instance operations that can be performed on it but with no data. /// You can use to create an 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. /// Returns a object. public static IgnitionResource GetIgnitionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - IgnitionResource.ValidateResourceId(id); - return new IgnitionResource(client, id); - } - ); + return GetMockableMgmtSingletonResourceArmClient(client).GetIgnitionResource(id); } - #endregion - #region BrakeResource /// /// 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. /// Returns a object. public static BrakeResource GetBrakeResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - BrakeResource.ValidateResourceId(id); - return new BrakeResource(client, id); - } - ); + return GetMockableMgmtSingletonResourceArmClient(client).GetBrakeResource(id); } - #endregion - #region SingletonResource /// /// 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. /// Returns a object. public static SingletonResource GetSingletonResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SingletonResource.ValidateResourceId(id); - return new SingletonResource(client, id); - } - ); + return GetMockableMgmtSingletonResourceArmClient(client).GetSingletonResource(id); } - #endregion - #region ParentResource /// /// 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. /// Returns a object. public static ParentResource GetParentResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ParentResource.ValidateResourceId(id); - return new ParentResource(client, id); - } - ); + return GetMockableMgmtSingletonResourceArmClient(client).GetParentResource(id); } - #endregion - /// Gets a collection of CarResources in the ResourceGroupResource. + /// + /// Gets a collection of CarResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of CarResources and their operations over a CarResource. public static CarCollection GetCars(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCars(); + return GetMockableMgmtSingletonResourceResourceGroupResource(resourceGroupResource).GetCars(); } /// @@ -147,16 +134,20 @@ public static CarCollection GetCars(this ResourceGroupResource resourceGroupReso /// Cars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetCarAsync(this ResourceGroupResource resourceGroupResource, string carName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetCars().GetAsync(carName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSingletonResourceResourceGroupResource(resourceGroupResource).GetCarAsync(carName, cancellationToken).ConfigureAwait(false); } /// @@ -170,24 +161,34 @@ public static async Task> GetCarAsync(this ResourceGroupRe /// Cars_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetCar(this ResourceGroupResource resourceGroupResource, string carName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetCars().Get(carName, cancellationToken); + return GetMockableMgmtSingletonResourceResourceGroupResource(resourceGroupResource).GetCar(carName, cancellationToken); } - /// Gets a collection of ParentResources in the ResourceGroupResource. + /// + /// Gets a collection of ParentResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ParentResources and their operations over a ParentResource. public static ParentResourceCollection GetParentResources(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetParentResources(); + return GetMockableMgmtSingletonResourceResourceGroupResource(resourceGroupResource).GetParentResources(); } /// @@ -202,16 +203,20 @@ public static ParentResourceCollection GetParentResources(this ResourceGroupReso /// ParentResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetParentResourceAsync(this ResourceGroupResource resourceGroupResource, string parentName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetParentResources().GetAsync(parentName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSingletonResourceResourceGroupResource(resourceGroupResource).GetParentResourceAsync(parentName, cancellationToken).ConfigureAwait(false); } /// @@ -226,16 +231,20 @@ public static async Task> GetParentResourceAsync(this R /// ParentResources_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetParentResource(this ResourceGroupResource resourceGroupResource, string parentName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetParentResources().Get(parentName, cancellationToken); + return GetMockableMgmtSingletonResourceResourceGroupResource(resourceGroupResource).GetParentResource(parentName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MockableMgmtSingletonResourceArmClient.cs b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MockableMgmtSingletonResourceArmClient.cs new file mode 100644 index 00000000000..ff22156670d --- /dev/null +++ b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MockableMgmtSingletonResourceArmClient.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtSingletonResource; + +namespace MgmtSingletonResource.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtSingletonResourceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSingletonResourceArmClient() + { + } + + /// 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 MockableMgmtSingletonResourceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtSingletonResourceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 CarResource GetCarResource(ResourceIdentifier id) + { + CarResource.ValidateResourceId(id); + return new CarResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual IgnitionResource GetIgnitionResource(ResourceIdentifier id) + { + IgnitionResource.ValidateResourceId(id); + return new IgnitionResource(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 BrakeResource GetBrakeResource(ResourceIdentifier id) + { + BrakeResource.ValidateResourceId(id); + return new BrakeResource(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 SingletonResource GetSingletonResource(ResourceIdentifier id) + { + SingletonResource.ValidateResourceId(id); + return new SingletonResource(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 ParentResource GetParentResource(ResourceIdentifier id) + { + ParentResource.ValidateResourceId(id); + return new ParentResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MockableMgmtSingletonResourceResourceGroupResource.cs b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MockableMgmtSingletonResourceResourceGroupResource.cs new file mode 100644 index 00000000000..b25326896d4 --- /dev/null +++ b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/MockableMgmtSingletonResourceResourceGroupResource.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtSingletonResource; + +namespace MgmtSingletonResource.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtSingletonResourceResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSingletonResourceResourceGroupResource() + { + } + + /// 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 MockableMgmtSingletonResourceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of CarResources in the ResourceGroupResource. + /// An object representing collection of CarResources and their operations over a CarResource. + public virtual CarCollection GetCars() + { + return GetCachedClient(client => new CarCollection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cars/{carName} + /// + /// + /// Operation Id + /// Cars_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetCarAsync(string carName, CancellationToken cancellationToken = default) + { + return await GetCars().GetAsync(carName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cars/{carName} + /// + /// + /// Operation Id + /// Cars_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetCar(string carName, CancellationToken cancellationToken = default) + { + return GetCars().Get(carName, cancellationToken); + } + + /// Gets a collection of ParentResources in the ResourceGroupResource. + /// An object representing collection of ParentResources and their operations over a ParentResource. + public virtual ParentResourceCollection GetParentResources() + { + return GetCachedClient(client => new ParentResourceCollection(client, Id)); + } + + /// + /// Singleton Test Parent Example. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Billing/parentResources/{parentName} + /// + /// + /// Operation Id + /// ParentResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetParentResourceAsync(string parentName, CancellationToken cancellationToken = default) + { + return await GetParentResources().GetAsync(parentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Singleton Test Parent Example. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Billing/parentResources/{parentName} + /// + /// + /// Operation Id + /// ParentResources_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetParentResource(string parentName, CancellationToken cancellationToken = default) + { + return GetParentResources().Get(parentName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtSingletonResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtSingletonResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 9aeba0eb56a..00000000000 --- a/test/TestProjects/MgmtSingletonResource/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtSingletonResource -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of CarResources in the ResourceGroupResource. - /// An object representing collection of CarResources and their operations over a CarResource. - public virtual CarCollection GetCars() - { - return GetCachedClient(Client => new CarCollection(Client, Id)); - } - - /// Gets a collection of ParentResources in the ResourceGroupResource. - /// An object representing collection of ParentResources and their operations over a ParentResource. - public virtual ParentResourceCollection GetParentResources() - { - return GetCachedClient(Client => new ParentResourceCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MgmtSubscriptionNameParameterExtensions.cs b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MgmtSubscriptionNameParameterExtensions.cs index 46eb8b4ce02..3b0f039567f 100644 --- a/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MgmtSubscriptionNameParameterExtensions.cs +++ b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MgmtSubscriptionNameParameterExtensions.cs @@ -12,52 +12,51 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtSubscriptionNameParameter.Mocking; namespace MgmtSubscriptionNameParameter { /// A class to add extension methods to MgmtSubscriptionNameParameter. public static partial class MgmtSubscriptionNameParameterExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtSubscriptionNameParameterArmClient GetMockableMgmtSubscriptionNameParameterArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtSubscriptionNameParameterArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtSubscriptionNameParameterResourceGroupResource GetMockableMgmtSubscriptionNameParameterResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtSubscriptionNameParameterResourceGroupResource(client, resource.Id)); } - #region SBSubscriptionResource + /// /// 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. /// Returns a object. public static SBSubscriptionResource GetSBSubscriptionResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SBSubscriptionResource.ValidateResourceId(id); - return new SBSubscriptionResource(client, id); - } - ); + return GetMockableMgmtSubscriptionNameParameterArmClient(client).GetSBSubscriptionResource(id); } - #endregion - /// Gets a collection of SBSubscriptionResources in the ResourceGroupResource. + /// + /// Gets a collection of SBSubscriptionResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SBSubscriptionResources and their operations over a SBSubscriptionResource. public static SBSubscriptionCollection GetSBSubscriptions(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSBSubscriptions(); + return GetMockableMgmtSubscriptionNameParameterResourceGroupResource(resourceGroupResource).GetSBSubscriptions(); } /// @@ -72,16 +71,20 @@ public static SBSubscriptionCollection GetSBSubscriptions(this ResourceGroupReso /// Subscriptions_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The subscription name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSBSubscriptionAsync(this ResourceGroupResource resourceGroupResource, string subscriptionName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetSBSubscriptions().GetAsync(subscriptionName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSubscriptionNameParameterResourceGroupResource(resourceGroupResource).GetSBSubscriptionAsync(subscriptionName, cancellationToken).ConfigureAwait(false); } /// @@ -96,16 +99,20 @@ public static async Task> GetSBSubscriptionAsyn /// Subscriptions_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The subscription name. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSBSubscription(this ResourceGroupResource resourceGroupResource, string subscriptionName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetSBSubscriptions().Get(subscriptionName, cancellationToken); + return GetMockableMgmtSubscriptionNameParameterResourceGroupResource(resourceGroupResource).GetSBSubscription(subscriptionName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MockableMgmtSubscriptionNameParameterArmClient.cs b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MockableMgmtSubscriptionNameParameterArmClient.cs new file mode 100644 index 00000000000..76ec1e44533 --- /dev/null +++ b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MockableMgmtSubscriptionNameParameterArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtSubscriptionNameParameter; + +namespace MgmtSubscriptionNameParameter.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtSubscriptionNameParameterArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSubscriptionNameParameterArmClient() + { + } + + /// 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 MockableMgmtSubscriptionNameParameterArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtSubscriptionNameParameterArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 SBSubscriptionResource GetSBSubscriptionResource(ResourceIdentifier id) + { + SBSubscriptionResource.ValidateResourceId(id); + return new SBSubscriptionResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MockableMgmtSubscriptionNameParameterResourceGroupResource.cs b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MockableMgmtSubscriptionNameParameterResourceGroupResource.cs new file mode 100644 index 00000000000..6798d324b94 --- /dev/null +++ b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/MockableMgmtSubscriptionNameParameterResourceGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtSubscriptionNameParameter; + +namespace MgmtSubscriptionNameParameter.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtSubscriptionNameParameterResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSubscriptionNameParameterResourceGroupResource() + { + } + + /// 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 MockableMgmtSubscriptionNameParameterResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of SBSubscriptionResources in the ResourceGroupResource. + /// An object representing collection of SBSubscriptionResources and their operations over a SBSubscriptionResource. + public virtual SBSubscriptionCollection GetSBSubscriptions() + { + return GetCachedClient(client => new SBSubscriptionCollection(client, Id)); + } + + /// + /// Returns a subscription description for the specified topic. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/subscriptions/{subscriptionName} + /// + /// + /// Operation Id + /// Subscriptions_Get + /// + /// + /// + /// The subscription name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSBSubscriptionAsync(string subscriptionName, CancellationToken cancellationToken = default) + { + return await GetSBSubscriptions().GetAsync(subscriptionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns a subscription description for the specified topic. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/subscriptions/{subscriptionName} + /// + /// + /// Operation Id + /// Subscriptions_Get + /// + /// + /// + /// The subscription name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSBSubscription(string subscriptionName, CancellationToken cancellationToken = default) + { + return GetSBSubscriptions().Get(subscriptionName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 36d940d088e..00000000000 --- a/test/TestProjects/MgmtSubscriptionNameParameter/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtSubscriptionNameParameter -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of SBSubscriptionResources in the ResourceGroupResource. - /// An object representing collection of SBSubscriptionResources and their operations over a SBSubscriptionResource. - public virtual SBSubscriptionCollection GetSBSubscriptions() - { - return GetCachedClient(Client => new SBSubscriptionCollection(Client, Id)); - } - } -} diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MgmtSupersetFlattenInheritanceExtensions.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MgmtSupersetFlattenInheritanceExtensions.cs index a1097cc521b..c5c1f07ce94 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MgmtSupersetFlattenInheritanceExtensions.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MgmtSupersetFlattenInheritanceExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtSupersetFlattenInheritance.Mocking; using MgmtSupersetFlattenInheritance.Models; namespace MgmtSupersetFlattenInheritance @@ -19,65 +20,60 @@ namespace MgmtSupersetFlattenInheritance /// A class to add extension methods to MgmtSupersetFlattenInheritance. public static partial class MgmtSupersetFlattenInheritanceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtSupersetFlattenInheritanceArmClient GetMockableMgmtSupersetFlattenInheritanceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtSupersetFlattenInheritanceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtSupersetFlattenInheritanceResourceGroupResource GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtSupersetFlattenInheritanceResourceGroupResource(client, resource.Id)); } - #region ResourceModel1Resource + /// /// 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. /// Returns a object. public static ResourceModel1Resource GetResourceModel1Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - ResourceModel1Resource.ValidateResourceId(id); - return new ResourceModel1Resource(client, id); - } - ); + return GetMockableMgmtSupersetFlattenInheritanceArmClient(client).GetResourceModel1Resource(id); } - #endregion - #region TrackedResourceModel1Resource /// /// 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. /// Returns a object. public static TrackedResourceModel1Resource GetTrackedResourceModel1Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - TrackedResourceModel1Resource.ValidateResourceId(id); - return new TrackedResourceModel1Resource(client, id); - } - ); + return GetMockableMgmtSupersetFlattenInheritanceArmClient(client).GetTrackedResourceModel1Resource(id); } - #endregion - /// Gets a collection of ResourceModel1Resources in the ResourceGroupResource. + /// + /// Gets a collection of ResourceModel1Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of ResourceModel1Resources and their operations over a ResourceModel1Resource. public static ResourceModel1Collection GetResourceModel1s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResourceModel1s(); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel1s(); } /// @@ -91,16 +87,20 @@ public static ResourceModel1Collection GetResourceModel1s(this ResourceGroupReso /// ResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetResourceModel1Async(this ResourceGroupResource resourceGroupResource, string resourceModel1SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetResourceModel1s().GetAsync(resourceModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel1Async(resourceModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -114,24 +114,34 @@ public static async Task> GetResourceModel1Asyn /// ResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetResourceModel1(this ResourceGroupResource resourceGroupResource, string resourceModel1SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetResourceModel1s().Get(resourceModel1SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel1(resourceModel1SName, cancellationToken); } - /// Gets a collection of TrackedResourceModel1Resources in the ResourceGroupResource. + /// + /// Gets a collection of TrackedResourceModel1Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of TrackedResourceModel1Resources and their operations over a TrackedResourceModel1Resource. public static TrackedResourceModel1Collection GetTrackedResourceModel1s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTrackedResourceModel1s(); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel1s(); } /// @@ -145,16 +155,20 @@ public static TrackedResourceModel1Collection GetTrackedResourceModel1s(this Res /// TrackedResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetTrackedResourceModel1Async(this ResourceGroupResource resourceGroupResource, string trackedResourceModel1SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetTrackedResourceModel1s().GetAsync(trackedResourceModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel1Async(trackedResourceModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -168,16 +182,20 @@ public static async Task> GetTrackedReso /// TrackedResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetTrackedResourceModel1(this ResourceGroupResource resourceGroupResource, string trackedResourceModel1SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetTrackedResourceModel1s().Get(trackedResourceModel1SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel1(trackedResourceModel1SName, cancellationToken); } /// @@ -191,13 +209,17 @@ public static Response GetTrackedResourceModel1(t /// CustomModel1s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetCustomModel1sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel1sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel1sAsync(cancellationToken); } /// @@ -211,13 +233,17 @@ public static AsyncPageable GetCustomModel1sAsync(this ResourceGro /// CustomModel1s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetCustomModel1s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel1s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel1s(cancellationToken); } /// @@ -231,6 +257,10 @@ public static Pageable GetCustomModel1s(this ResourceGroupResource /// CustomModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -240,10 +270,7 @@ public static Pageable GetCustomModel1s(this ResourceGroupResource /// or is null. public static async Task> PutCustomModel1Async(this ResourceGroupResource resourceGroupResource, string customModel1SName, CustomModel1 customModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); - Argument.AssertNotNull(customModel1, nameof(customModel1)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutCustomModel1Async(customModel1SName, customModel1, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutCustomModel1Async(customModel1SName, customModel1, cancellationToken).ConfigureAwait(false); } /// @@ -257,6 +284,10 @@ public static async Task> PutCustomModel1Async(this Resou /// CustomModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -266,10 +297,7 @@ public static async Task> PutCustomModel1Async(this Resou /// or is null. public static Response PutCustomModel1(this ResourceGroupResource resourceGroupResource, string customModel1SName, CustomModel1 customModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); - Argument.AssertNotNull(customModel1, nameof(customModel1)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutCustomModel1(customModel1SName, customModel1, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutCustomModel1(customModel1SName, customModel1, cancellationToken); } /// @@ -283,6 +311,10 @@ public static Response PutCustomModel1(this ResourceGroupResource /// CustomModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -291,9 +323,7 @@ public static Response PutCustomModel1(this ResourceGroupResource /// is null. public static async Task> GetCustomModel1Async(this ResourceGroupResource resourceGroupResource, string customModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel1Async(customModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel1Async(customModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -307,6 +337,10 @@ public static async Task> GetCustomModel1Async(this Resou /// CustomModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -315,9 +349,7 @@ public static async Task> GetCustomModel1Async(this Resou /// is null. public static Response GetCustomModel1(this ResourceGroupResource resourceGroupResource, string customModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel1(customModel1SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel1(customModel1SName, cancellationToken); } /// @@ -331,13 +363,17 @@ public static Response GetCustomModel1(this ResourceGroupResource /// CustomModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetCustomModel2sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel2sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2sAsync(cancellationToken); } /// @@ -351,13 +387,17 @@ public static AsyncPageable GetCustomModel2sAsync(this ResourceGro /// CustomModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetCustomModel2s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel2s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2s(cancellationToken); } /// @@ -371,6 +411,10 @@ public static Pageable GetCustomModel2s(this ResourceGroupResource /// CustomModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -380,10 +424,7 @@ public static Pageable GetCustomModel2s(this ResourceGroupResource /// or is null. public static async Task> PutCustomModel2Async(this ResourceGroupResource resourceGroupResource, string customModel2SName, CustomModel2 customModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); - Argument.AssertNotNull(customModel2, nameof(customModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutCustomModel2Async(customModel2SName, customModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutCustomModel2Async(customModel2SName, customModel2, cancellationToken).ConfigureAwait(false); } /// @@ -397,6 +438,10 @@ public static async Task> PutCustomModel2Async(this Resou /// CustomModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -406,10 +451,7 @@ public static async Task> PutCustomModel2Async(this Resou /// or is null. public static Response PutCustomModel2(this ResourceGroupResource resourceGroupResource, string customModel2SName, CustomModel2 customModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); - Argument.AssertNotNull(customModel2, nameof(customModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutCustomModel2(customModel2SName, customModel2, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutCustomModel2(customModel2SName, customModel2, cancellationToken); } /// @@ -423,6 +465,10 @@ public static Response PutCustomModel2(this ResourceGroupResource /// CustomModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -431,9 +477,7 @@ public static Response PutCustomModel2(this ResourceGroupResource /// is null. public static async Task> GetCustomModel2Async(this ResourceGroupResource resourceGroupResource, string customModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel2Async(customModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2Async(customModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -447,6 +491,10 @@ public static async Task> GetCustomModel2Async(this Resou /// CustomModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -455,9 +503,7 @@ public static async Task> GetCustomModel2Async(this Resou /// is null. public static Response GetCustomModel2(this ResourceGroupResource resourceGroupResource, string customModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCustomModel2(customModel2SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetCustomModel2(customModel2SName, cancellationToken); } /// @@ -471,13 +517,17 @@ public static Response GetCustomModel2(this ResourceGroupResource /// SubResourceModel1s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetSubResourceModel1sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel1sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel1sAsync(cancellationToken); } /// @@ -491,13 +541,17 @@ public static AsyncPageable GetSubResourceModel1sAsync(this R /// SubResourceModel1s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetSubResourceModel1s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel1s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel1s(cancellationToken); } /// @@ -511,6 +565,10 @@ public static Pageable GetSubResourceModel1s(this ResourceGro /// SubResourceModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -520,10 +578,7 @@ public static Pageable GetSubResourceModel1s(this ResourceGro /// or is null. public static async Task> PutSubResourceModel1Async(this ResourceGroupResource resourceGroupResource, string subResourceModel1SName, SubResourceModel1 subResourceModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); - Argument.AssertNotNull(subResourceModel1, nameof(subResourceModel1)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSubResourceModel1Async(subResourceModel1SName, subResourceModel1, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutSubResourceModel1Async(subResourceModel1SName, subResourceModel1, cancellationToken).ConfigureAwait(false); } /// @@ -537,6 +592,10 @@ public static async Task> PutSubResourceModel1Async( /// SubResourceModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -546,10 +605,7 @@ public static async Task> PutSubResourceModel1Async( /// or is null. public static Response PutSubResourceModel1(this ResourceGroupResource resourceGroupResource, string subResourceModel1SName, SubResourceModel1 subResourceModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); - Argument.AssertNotNull(subResourceModel1, nameof(subResourceModel1)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSubResourceModel1(subResourceModel1SName, subResourceModel1, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutSubResourceModel1(subResourceModel1SName, subResourceModel1, cancellationToken); } /// @@ -563,6 +619,10 @@ public static Response PutSubResourceModel1(this ResourceGrou /// SubResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -571,9 +631,7 @@ public static Response PutSubResourceModel1(this ResourceGrou /// is null. public static async Task> GetSubResourceModel1Async(this ResourceGroupResource resourceGroupResource, string subResourceModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel1Async(subResourceModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel1Async(subResourceModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -587,6 +645,10 @@ public static async Task> GetSubResourceModel1Async( /// SubResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -595,9 +657,7 @@ public static async Task> GetSubResourceModel1Async( /// is null. public static Response GetSubResourceModel1(this ResourceGroupResource resourceGroupResource, string subResourceModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel1(subResourceModel1SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel1(subResourceModel1SName, cancellationToken); } /// @@ -611,13 +671,17 @@ public static Response GetSubResourceModel1(this ResourceGrou /// SubResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetSubResourceModel2sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel2sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel2sAsync(cancellationToken); } /// @@ -631,13 +695,17 @@ public static AsyncPageable GetSubResourceModel2sAsync(this R /// SubResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetSubResourceModel2s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel2s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel2s(cancellationToken); } /// @@ -651,6 +719,10 @@ public static Pageable GetSubResourceModel2s(this ResourceGro /// SubResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -660,10 +732,7 @@ public static Pageable GetSubResourceModel2s(this ResourceGro /// or is null. public static async Task> PutSubResourceModel2Async(this ResourceGroupResource resourceGroupResource, string subResourceModel2SName, SubResourceModel2 subResourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); - Argument.AssertNotNull(subResourceModel2, nameof(subResourceModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSubResourceModel2Async(subResourceModel2SName, subResourceModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutSubResourceModel2Async(subResourceModel2SName, subResourceModel2, cancellationToken).ConfigureAwait(false); } /// @@ -677,6 +746,10 @@ public static async Task> PutSubResourceModel2Async( /// SubResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -686,10 +759,7 @@ public static async Task> PutSubResourceModel2Async( /// or is null. public static Response PutSubResourceModel2(this ResourceGroupResource resourceGroupResource, string subResourceModel2SName, SubResourceModel2 subResourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); - Argument.AssertNotNull(subResourceModel2, nameof(subResourceModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSubResourceModel2(subResourceModel2SName, subResourceModel2, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutSubResourceModel2(subResourceModel2SName, subResourceModel2, cancellationToken); } /// @@ -703,6 +773,10 @@ public static Response PutSubResourceModel2(this ResourceGrou /// SubResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -711,9 +785,7 @@ public static Response PutSubResourceModel2(this ResourceGrou /// is null. public static async Task> GetSubResourceModel2Async(this ResourceGroupResource resourceGroupResource, string subResourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel2Async(subResourceModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel2Async(subResourceModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -727,6 +799,10 @@ public static async Task> GetSubResourceModel2Async( /// SubResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -735,9 +811,7 @@ public static async Task> GetSubResourceModel2Async( /// is null. public static Response GetSubResourceModel2(this ResourceGroupResource resourceGroupResource, string subResourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSubResourceModel2(subResourceModel2SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetSubResourceModel2(subResourceModel2SName, cancellationToken); } /// @@ -751,13 +825,17 @@ public static Response GetSubResourceModel2(this ResourceGrou /// WritableSubResourceModel1s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetWritableSubResourceModel1sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel1sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel1sAsync(cancellationToken); } /// @@ -771,13 +849,17 @@ public static AsyncPageable GetWritableSubResourceMod /// WritableSubResourceModel1s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetWritableSubResourceModel1s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel1s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel1s(cancellationToken); } /// @@ -791,6 +873,10 @@ public static Pageable GetWritableSubResourceModel1s( /// WritableSubResourceModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -800,10 +886,7 @@ public static Pageable GetWritableSubResourceModel1s( /// or is null. public static async Task> PutWritableSubResourceModel1Async(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel1SName, WritableSubResourceModel1 writableSubResourceModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); - Argument.AssertNotNull(writableSubResourceModel1, nameof(writableSubResourceModel1)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutWritableSubResourceModel1Async(writableSubResourceModel1SName, writableSubResourceModel1, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutWritableSubResourceModel1Async(writableSubResourceModel1SName, writableSubResourceModel1, cancellationToken).ConfigureAwait(false); } /// @@ -817,6 +900,10 @@ public static async Task> PutWritableSubReso /// WritableSubResourceModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -826,10 +913,7 @@ public static async Task> PutWritableSubReso /// or is null. public static Response PutWritableSubResourceModel1(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel1SName, WritableSubResourceModel1 writableSubResourceModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); - Argument.AssertNotNull(writableSubResourceModel1, nameof(writableSubResourceModel1)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutWritableSubResourceModel1(writableSubResourceModel1SName, writableSubResourceModel1, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutWritableSubResourceModel1(writableSubResourceModel1SName, writableSubResourceModel1, cancellationToken); } /// @@ -843,6 +927,10 @@ public static Response PutWritableSubResourceModel1(t /// WritableSubResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -851,9 +939,7 @@ public static Response PutWritableSubResourceModel1(t /// is null. public static async Task> GetWritableSubResourceModel1Async(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel1Async(writableSubResourceModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel1Async(writableSubResourceModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -867,6 +953,10 @@ public static async Task> GetWritableSubReso /// WritableSubResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -875,9 +965,7 @@ public static async Task> GetWritableSubReso /// is null. public static Response GetWritableSubResourceModel1(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel1(writableSubResourceModel1SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel1(writableSubResourceModel1SName, cancellationToken); } /// @@ -891,13 +979,17 @@ public static Response GetWritableSubResourceModel1(t /// WritableSubResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetWritableSubResourceModel2sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel2sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel2sAsync(cancellationToken); } /// @@ -911,13 +1003,17 @@ public static AsyncPageable GetWritableSubResourceMod /// WritableSubResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetWritableSubResourceModel2s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel2s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel2s(cancellationToken); } /// @@ -931,6 +1027,10 @@ public static Pageable GetWritableSubResourceModel2s( /// WritableSubResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -940,10 +1040,7 @@ public static Pageable GetWritableSubResourceModel2s( /// or is null. public static async Task> PutWritableSubResourceModel2Async(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel2SName, WritableSubResourceModel2 writableSubResourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); - Argument.AssertNotNull(writableSubResourceModel2, nameof(writableSubResourceModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutWritableSubResourceModel2Async(writableSubResourceModel2SName, writableSubResourceModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutWritableSubResourceModel2Async(writableSubResourceModel2SName, writableSubResourceModel2, cancellationToken).ConfigureAwait(false); } /// @@ -957,6 +1054,10 @@ public static async Task> PutWritableSubReso /// WritableSubResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -966,10 +1067,7 @@ public static async Task> PutWritableSubReso /// or is null. public static Response PutWritableSubResourceModel2(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel2SName, WritableSubResourceModel2 writableSubResourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); - Argument.AssertNotNull(writableSubResourceModel2, nameof(writableSubResourceModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutWritableSubResourceModel2(writableSubResourceModel2SName, writableSubResourceModel2, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutWritableSubResourceModel2(writableSubResourceModel2SName, writableSubResourceModel2, cancellationToken); } /// @@ -983,6 +1081,10 @@ public static Response PutWritableSubResourceModel2(t /// WritableSubResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -991,9 +1093,7 @@ public static Response PutWritableSubResourceModel2(t /// is null. public static async Task> GetWritableSubResourceModel2Async(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel2Async(writableSubResourceModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel2Async(writableSubResourceModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -1007,6 +1107,10 @@ public static async Task> GetWritableSubReso /// WritableSubResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1015,9 +1119,7 @@ public static async Task> GetWritableSubReso /// is null. public static Response GetWritableSubResourceModel2(this ResourceGroupResource resourceGroupResource, string writableSubResourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetWritableSubResourceModel2(writableSubResourceModel2SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetWritableSubResourceModel2(writableSubResourceModel2SName, cancellationToken); } /// @@ -1031,13 +1133,17 @@ public static Response GetWritableSubResourceModel2(t /// ResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetResourceModel2sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResourceModel2sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel2sAsync(cancellationToken); } /// @@ -1051,13 +1157,17 @@ public static AsyncPageable GetResourceModel2sAsync(this Resourc /// ResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetResourceModel2s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResourceModel2s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel2s(cancellationToken); } /// @@ -1071,6 +1181,10 @@ public static Pageable GetResourceModel2s(this ResourceGroupReso /// ResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1080,10 +1194,7 @@ public static Pageable GetResourceModel2s(this ResourceGroupReso /// or is null. public static async Task> PutResourceModel2Async(this ResourceGroupResource resourceGroupResource, string resourceModel2SName, ResourceModel2 resourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); - Argument.AssertNotNull(resourceModel2, nameof(resourceModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutResourceModel2Async(resourceModel2SName, resourceModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutResourceModel2Async(resourceModel2SName, resourceModel2, cancellationToken).ConfigureAwait(false); } /// @@ -1097,6 +1208,10 @@ public static async Task> PutResourceModel2Async(this R /// ResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1106,10 +1221,7 @@ public static async Task> PutResourceModel2Async(this R /// or is null. public static Response PutResourceModel2(this ResourceGroupResource resourceGroupResource, string resourceModel2SName, ResourceModel2 resourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); - Argument.AssertNotNull(resourceModel2, nameof(resourceModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutResourceModel2(resourceModel2SName, resourceModel2, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutResourceModel2(resourceModel2SName, resourceModel2, cancellationToken); } /// @@ -1123,6 +1235,10 @@ public static Response PutResourceModel2(this ResourceGroupResou /// ResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1131,9 +1247,7 @@ public static Response PutResourceModel2(this ResourceGroupResou /// is null. public static async Task> GetResourceModel2Async(this ResourceGroupResource resourceGroupResource, string resourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResourceModel2Async(resourceModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel2Async(resourceModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -1147,6 +1261,10 @@ public static async Task> GetResourceModel2Async(this R /// ResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1155,9 +1273,7 @@ public static async Task> GetResourceModel2Async(this R /// is null. public static Response GetResourceModel2(this ResourceGroupResource resourceGroupResource, string resourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetResourceModel2(resourceModel2SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetResourceModel2(resourceModel2SName, cancellationToken); } /// @@ -1171,13 +1287,17 @@ public static Response GetResourceModel2(this ResourceGroupResou /// TrackedResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// An async collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTrackedResourceModel2sAsync(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTrackedResourceModel2sAsync(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel2sAsync(cancellationToken); } /// @@ -1191,13 +1311,17 @@ public static AsyncPageable GetTrackedResourceModel2sAsyn /// TrackedResourceModel2s_List /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The cancellation token to use. /// A collection of that may take multiple service requests to iterate over. public static Pageable GetTrackedResourceModel2s(this ResourceGroupResource resourceGroupResource, CancellationToken cancellationToken = default) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTrackedResourceModel2s(cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel2s(cancellationToken); } /// @@ -1211,6 +1335,10 @@ public static Pageable GetTrackedResourceModel2s(this Res /// TrackedResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1220,10 +1348,7 @@ public static Pageable GetTrackedResourceModel2s(this Res /// or is null. public static async Task> PutTrackedResourceModel2Async(this ResourceGroupResource resourceGroupResource, string trackedResourceModel2SName, TrackedResourceModel2 trackedResourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); - Argument.AssertNotNull(trackedResourceModel2, nameof(trackedResourceModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutTrackedResourceModel2Async(trackedResourceModel2SName, trackedResourceModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutTrackedResourceModel2Async(trackedResourceModel2SName, trackedResourceModel2, cancellationToken).ConfigureAwait(false); } /// @@ -1237,6 +1362,10 @@ public static async Task> PutTrackedResourceMode /// TrackedResourceModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1246,10 +1375,7 @@ public static async Task> PutTrackedResourceMode /// or is null. public static Response PutTrackedResourceModel2(this ResourceGroupResource resourceGroupResource, string trackedResourceModel2SName, TrackedResourceModel2 trackedResourceModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); - Argument.AssertNotNull(trackedResourceModel2, nameof(trackedResourceModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutTrackedResourceModel2(trackedResourceModel2SName, trackedResourceModel2, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutTrackedResourceModel2(trackedResourceModel2SName, trackedResourceModel2, cancellationToken); } /// @@ -1263,6 +1389,10 @@ public static Response PutTrackedResourceModel2(this Reso /// TrackedResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1271,9 +1401,7 @@ public static Response PutTrackedResourceModel2(this Reso /// is null. public static async Task> GetTrackedResourceModel2Async(this ResourceGroupResource resourceGroupResource, string trackedResourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTrackedResourceModel2Async(trackedResourceModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel2Async(trackedResourceModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -1287,6 +1415,10 @@ public static async Task> GetTrackedResourceMode /// TrackedResourceModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1295,9 +1427,7 @@ public static async Task> GetTrackedResourceMode /// is null. public static Response GetTrackedResourceModel2(this ResourceGroupResource resourceGroupResource, string trackedResourceModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetTrackedResourceModel2(trackedResourceModel2SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetTrackedResourceModel2(trackedResourceModel2SName, cancellationToken); } /// @@ -1311,6 +1441,10 @@ public static Response GetTrackedResourceModel2(this Reso /// NonResourceModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1320,10 +1454,7 @@ public static Response GetTrackedResourceModel2(this Reso /// or is null. public static async Task> PutNonResourceModel1Async(this ResourceGroupResource resourceGroupResource, string nonResourceModel1SName, NonResourceModel1 nonResourceModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); - Argument.AssertNotNull(nonResourceModel1, nameof(nonResourceModel1)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutNonResourceModel1Async(nonResourceModel1SName, nonResourceModel1, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutNonResourceModel1Async(nonResourceModel1SName, nonResourceModel1, cancellationToken).ConfigureAwait(false); } /// @@ -1337,6 +1468,10 @@ public static async Task> PutNonResourceModel1Async( /// NonResourceModel1s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1346,10 +1481,7 @@ public static async Task> PutNonResourceModel1Async( /// or is null. public static Response PutNonResourceModel1(this ResourceGroupResource resourceGroupResource, string nonResourceModel1SName, NonResourceModel1 nonResourceModel1, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); - Argument.AssertNotNull(nonResourceModel1, nameof(nonResourceModel1)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutNonResourceModel1(nonResourceModel1SName, nonResourceModel1, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).PutNonResourceModel1(nonResourceModel1SName, nonResourceModel1, cancellationToken); } /// @@ -1363,6 +1495,10 @@ public static Response PutNonResourceModel1(this ResourceGrou /// NonResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1371,9 +1507,7 @@ public static Response PutNonResourceModel1(this ResourceGrou /// is null. public static async Task> GetNonResourceModel1Async(this ResourceGroupResource resourceGroupResource, string nonResourceModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetNonResourceModel1Async(nonResourceModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetNonResourceModel1Async(nonResourceModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -1387,6 +1521,10 @@ public static async Task> GetNonResourceModel1Async( /// NonResourceModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -1395,9 +1533,7 @@ public static async Task> GetNonResourceModel1Async( /// is null. public static Response GetNonResourceModel1(this ResourceGroupResource resourceGroupResource, string nonResourceModel1SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetNonResourceModel1(nonResourceModel1SName, cancellationToken); + return GetMockableMgmtSupersetFlattenInheritanceResourceGroupResource(resourceGroupResource).GetNonResourceModel1(nonResourceModel1SName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MockableMgmtSupersetFlattenInheritanceArmClient.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MockableMgmtSupersetFlattenInheritanceArmClient.cs new file mode 100644 index 00000000000..a27cc3573ca --- /dev/null +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MockableMgmtSupersetFlattenInheritanceArmClient.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtSupersetFlattenInheritance; + +namespace MgmtSupersetFlattenInheritance.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtSupersetFlattenInheritanceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSupersetFlattenInheritanceArmClient() + { + } + + /// 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 MockableMgmtSupersetFlattenInheritanceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtSupersetFlattenInheritanceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 ResourceModel1Resource GetResourceModel1Resource(ResourceIdentifier id) + { + ResourceModel1Resource.ValidateResourceId(id); + return new ResourceModel1Resource(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 TrackedResourceModel1Resource GetTrackedResourceModel1Resource(ResourceIdentifier id) + { + TrackedResourceModel1Resource.ValidateResourceId(id); + return new TrackedResourceModel1Resource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MockableMgmtSupersetFlattenInheritanceResourceGroupResource.cs similarity index 72% rename from test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs rename to test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MockableMgmtSupersetFlattenInheritanceResourceGroupResource.cs index f4ef7ff4da3..595488ddb70 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/Generated/Extensions/MockableMgmtSupersetFlattenInheritanceResourceGroupResource.cs @@ -13,12 +13,13 @@ using Azure.Core; using Azure.Core.Pipeline; using Azure.ResourceManager; +using MgmtSupersetFlattenInheritance; using MgmtSupersetFlattenInheritance.Models; -namespace MgmtSupersetFlattenInheritance +namespace MgmtSupersetFlattenInheritance.Mocking { /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource + public partial class MockableMgmtSupersetFlattenInheritanceResourceGroupResource : ArmResource { private ClientDiagnostics _customModel1sClientDiagnostics; private CustomModel1SRestOperations _customModel1sRestClient; @@ -39,15 +40,15 @@ internal partial class ResourceGroupResourceExtensionClient : ArmResource private ClientDiagnostics _nonResourceModel1sClientDiagnostics; private NonResourceModel1SRestOperations _nonResourceModel1sRestClient; - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSupersetFlattenInheritanceResourceGroupResource() { } - /// Initializes a new instance of the class. + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + internal MockableMgmtSupersetFlattenInheritanceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } @@ -80,14 +81,102 @@ private string GetApiVersionOrNull(ResourceType resourceType) /// An object representing collection of ResourceModel1Resources and their operations over a ResourceModel1Resource. public virtual ResourceModel1Collection GetResourceModel1s() { - return GetCachedClient(Client => new ResourceModel1Collection(Client, Id)); + return GetCachedClient(client => new ResourceModel1Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/resourceModel1s/{resourceModel1sName} + /// + /// + /// Operation Id + /// ResourceModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResourceModel1Async(string resourceModel1SName, CancellationToken cancellationToken = default) + { + return await GetResourceModel1s().GetAsync(resourceModel1SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/resourceModel1s/{resourceModel1sName} + /// + /// + /// Operation Id + /// ResourceModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResourceModel1(string resourceModel1SName, CancellationToken cancellationToken = default) + { + return GetResourceModel1s().Get(resourceModel1SName, cancellationToken); } /// Gets a collection of TrackedResourceModel1Resources in the ResourceGroupResource. /// An object representing collection of TrackedResourceModel1Resources and their operations over a TrackedResourceModel1Resource. public virtual TrackedResourceModel1Collection GetTrackedResourceModel1s() { - return GetCachedClient(Client => new TrackedResourceModel1Collection(Client, Id)); + return GetCachedClient(client => new TrackedResourceModel1Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/trackedResourceModel1s/{trackedResourceModel1sName} + /// + /// + /// Operation Id + /// TrackedResourceModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTrackedResourceModel1Async(string trackedResourceModel1SName, CancellationToken cancellationToken = default) + { + return await GetTrackedResourceModel1s().GetAsync(trackedResourceModel1SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/trackedResourceModel1s/{trackedResourceModel1sName} + /// + /// + /// Operation Id + /// TrackedResourceModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTrackedResourceModel1(string trackedResourceModel1SName, CancellationToken cancellationToken = default) + { + return GetTrackedResourceModel1s().Get(trackedResourceModel1SName, cancellationToken); } /// @@ -107,7 +196,7 @@ public virtual TrackedResourceModel1Collection GetTrackedResourceModel1s() public virtual AsyncPageable GetCustomModel1sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => CustomModel1sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, CustomModel1.DeserializeCustomModel1, CustomModel1sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetCustomModel1s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, CustomModel1.DeserializeCustomModel1, CustomModel1sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel1s", "value", null, cancellationToken); } /// @@ -127,7 +216,7 @@ public virtual AsyncPageable GetCustomModel1sAsync(CancellationTok public virtual Pageable GetCustomModel1s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => CustomModel1sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, CustomModel1.DeserializeCustomModel1, CustomModel1sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetCustomModel1s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, CustomModel1.DeserializeCustomModel1, CustomModel1sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel1s", "value", null, cancellationToken); } /// @@ -145,9 +234,14 @@ public virtual Pageable GetCustomModel1s(CancellationToken cancell /// The String to use. /// The CustomModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutCustomModel1Async(string customModel1SName, CustomModel1 customModel1, CancellationToken cancellationToken = default) { - using var scope = CustomModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutCustomModel1"); + Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); + Argument.AssertNotNull(customModel1, nameof(customModel1)); + + using var scope = CustomModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutCustomModel1"); scope.Start(); try { @@ -176,9 +270,14 @@ public virtual async Task> PutCustomModel1Async(string cu /// The String to use. /// The CustomModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutCustomModel1(string customModel1SName, CustomModel1 customModel1, CancellationToken cancellationToken = default) { - using var scope = CustomModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutCustomModel1"); + Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); + Argument.AssertNotNull(customModel1, nameof(customModel1)); + + using var scope = CustomModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutCustomModel1"); scope.Start(); try { @@ -206,9 +305,13 @@ public virtual Response PutCustomModel1(string customModel1SName, /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetCustomModel1Async(string customModel1SName, CancellationToken cancellationToken = default) { - using var scope = CustomModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetCustomModel1"); + Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); + + using var scope = CustomModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel1"); scope.Start(); try { @@ -236,9 +339,13 @@ public virtual async Task> GetCustomModel1Async(string cu /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetCustomModel1(string customModel1SName, CancellationToken cancellationToken = default) { - using var scope = CustomModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetCustomModel1"); + Argument.AssertNotNullOrEmpty(customModel1SName, nameof(customModel1SName)); + + using var scope = CustomModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel1"); scope.Start(); try { @@ -269,7 +376,7 @@ public virtual Response GetCustomModel1(string customModel1SName, public virtual AsyncPageable GetCustomModel2sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => CustomModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, CustomModel2.DeserializeCustomModel2, CustomModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetCustomModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, CustomModel2.DeserializeCustomModel2, CustomModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel2s", "value", null, cancellationToken); } /// @@ -289,7 +396,7 @@ public virtual AsyncPageable GetCustomModel2sAsync(CancellationTok public virtual Pageable GetCustomModel2s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => CustomModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, CustomModel2.DeserializeCustomModel2, CustomModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetCustomModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, CustomModel2.DeserializeCustomModel2, CustomModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel2s", "value", null, cancellationToken); } /// @@ -307,9 +414,14 @@ public virtual Pageable GetCustomModel2s(CancellationToken cancell /// The String to use. /// The CustomModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutCustomModel2Async(string customModel2SName, CustomModel2 customModel2, CancellationToken cancellationToken = default) { - using var scope = CustomModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutCustomModel2"); + Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); + Argument.AssertNotNull(customModel2, nameof(customModel2)); + + using var scope = CustomModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutCustomModel2"); scope.Start(); try { @@ -338,9 +450,14 @@ public virtual async Task> PutCustomModel2Async(string cu /// The String to use. /// The CustomModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutCustomModel2(string customModel2SName, CustomModel2 customModel2, CancellationToken cancellationToken = default) { - using var scope = CustomModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutCustomModel2"); + Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); + Argument.AssertNotNull(customModel2, nameof(customModel2)); + + using var scope = CustomModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutCustomModel2"); scope.Start(); try { @@ -368,9 +485,13 @@ public virtual Response PutCustomModel2(string customModel2SName, /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetCustomModel2Async(string customModel2SName, CancellationToken cancellationToken = default) { - using var scope = CustomModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetCustomModel2"); + Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); + + using var scope = CustomModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel2"); scope.Start(); try { @@ -398,9 +519,13 @@ public virtual async Task> GetCustomModel2Async(string cu /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetCustomModel2(string customModel2SName, CancellationToken cancellationToken = default) { - using var scope = CustomModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetCustomModel2"); + Argument.AssertNotNullOrEmpty(customModel2SName, nameof(customModel2SName)); + + using var scope = CustomModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetCustomModel2"); scope.Start(); try { @@ -431,7 +556,7 @@ public virtual Response GetCustomModel2(string customModel2SName, public virtual AsyncPageable GetSubResourceModel1sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => SubResourceModel1sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, SubResourceModel1.DeserializeSubResourceModel1, SubResourceModel1sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetSubResourceModel1s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, SubResourceModel1.DeserializeSubResourceModel1, SubResourceModel1sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel1s", "value", null, cancellationToken); } /// @@ -451,7 +576,7 @@ public virtual AsyncPageable GetSubResourceModel1sAsync(Cance public virtual Pageable GetSubResourceModel1s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => SubResourceModel1sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, SubResourceModel1.DeserializeSubResourceModel1, SubResourceModel1sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetSubResourceModel1s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, SubResourceModel1.DeserializeSubResourceModel1, SubResourceModel1sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel1s", "value", null, cancellationToken); } /// @@ -469,9 +594,14 @@ public virtual Pageable GetSubResourceModel1s(CancellationTok /// The String to use. /// The SubResourceModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutSubResourceModel1Async(string subResourceModel1SName, SubResourceModel1 subResourceModel1, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSubResourceModel1"); + Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); + Argument.AssertNotNull(subResourceModel1, nameof(subResourceModel1)); + + using var scope = SubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutSubResourceModel1"); scope.Start(); try { @@ -500,9 +630,14 @@ public virtual async Task> PutSubResourceModel1Async /// The String to use. /// The SubResourceModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutSubResourceModel1(string subResourceModel1SName, SubResourceModel1 subResourceModel1, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSubResourceModel1"); + Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); + Argument.AssertNotNull(subResourceModel1, nameof(subResourceModel1)); + + using var scope = SubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutSubResourceModel1"); scope.Start(); try { @@ -530,9 +665,13 @@ public virtual Response PutSubResourceModel1(string subResour /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetSubResourceModel1Async(string subResourceModel1SName, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSubResourceModel1"); + Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); + + using var scope = SubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel1"); scope.Start(); try { @@ -560,9 +699,13 @@ public virtual async Task> GetSubResourceModel1Async /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetSubResourceModel1(string subResourceModel1SName, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSubResourceModel1"); + Argument.AssertNotNullOrEmpty(subResourceModel1SName, nameof(subResourceModel1SName)); + + using var scope = SubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel1"); scope.Start(); try { @@ -593,7 +736,7 @@ public virtual Response GetSubResourceModel1(string subResour public virtual AsyncPageable GetSubResourceModel2sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => SubResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, SubResourceModel2.DeserializeSubResourceModel2, SubResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetSubResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, SubResourceModel2.DeserializeSubResourceModel2, SubResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel2s", "value", null, cancellationToken); } /// @@ -613,7 +756,7 @@ public virtual AsyncPageable GetSubResourceModel2sAsync(Cance public virtual Pageable GetSubResourceModel2s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => SubResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, SubResourceModel2.DeserializeSubResourceModel2, SubResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetSubResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, SubResourceModel2.DeserializeSubResourceModel2, SubResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel2s", "value", null, cancellationToken); } /// @@ -631,9 +774,14 @@ public virtual Pageable GetSubResourceModel2s(CancellationTok /// The String to use. /// The SubResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutSubResourceModel2Async(string subResourceModel2SName, SubResourceModel2 subResourceModel2, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSubResourceModel2"); + Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); + Argument.AssertNotNull(subResourceModel2, nameof(subResourceModel2)); + + using var scope = SubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutSubResourceModel2"); scope.Start(); try { @@ -662,9 +810,14 @@ public virtual async Task> PutSubResourceModel2Async /// The String to use. /// The SubResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutSubResourceModel2(string subResourceModel2SName, SubResourceModel2 subResourceModel2, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSubResourceModel2"); + Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); + Argument.AssertNotNull(subResourceModel2, nameof(subResourceModel2)); + + using var scope = SubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutSubResourceModel2"); scope.Start(); try { @@ -692,9 +845,13 @@ public virtual Response PutSubResourceModel2(string subResour /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetSubResourceModel2Async(string subResourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSubResourceModel2"); + Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); + + using var scope = SubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel2"); scope.Start(); try { @@ -722,9 +879,13 @@ public virtual async Task> GetSubResourceModel2Async /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetSubResourceModel2(string subResourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = SubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSubResourceModel2"); + Argument.AssertNotNullOrEmpty(subResourceModel2SName, nameof(subResourceModel2SName)); + + using var scope = SubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetSubResourceModel2"); scope.Start(); try { @@ -755,7 +916,7 @@ public virtual Response GetSubResourceModel2(string subResour public virtual AsyncPageable GetWritableSubResourceModel1sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => WritableSubResourceModel1sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, WritableSubResourceModel1.DeserializeWritableSubResourceModel1, WritableSubResourceModel1sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetWritableSubResourceModel1s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, WritableSubResourceModel1.DeserializeWritableSubResourceModel1, WritableSubResourceModel1sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel1s", "value", null, cancellationToken); } /// @@ -775,7 +936,7 @@ public virtual AsyncPageable GetWritableSubResourceMo public virtual Pageable GetWritableSubResourceModel1s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => WritableSubResourceModel1sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, WritableSubResourceModel1.DeserializeWritableSubResourceModel1, WritableSubResourceModel1sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetWritableSubResourceModel1s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, WritableSubResourceModel1.DeserializeWritableSubResourceModel1, WritableSubResourceModel1sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel1s", "value", null, cancellationToken); } /// @@ -793,9 +954,14 @@ public virtual Pageable GetWritableSubResourceModel1s /// The String to use. /// The WritableSubResourceModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutWritableSubResourceModel1Async(string writableSubResourceModel1SName, WritableSubResourceModel1 writableSubResourceModel1, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutWritableSubResourceModel1"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); + Argument.AssertNotNull(writableSubResourceModel1, nameof(writableSubResourceModel1)); + + using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutWritableSubResourceModel1"); scope.Start(); try { @@ -824,9 +990,14 @@ public virtual async Task> PutWritableSubRes /// The String to use. /// The WritableSubResourceModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutWritableSubResourceModel1(string writableSubResourceModel1SName, WritableSubResourceModel1 writableSubResourceModel1, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutWritableSubResourceModel1"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); + Argument.AssertNotNull(writableSubResourceModel1, nameof(writableSubResourceModel1)); + + using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutWritableSubResourceModel1"); scope.Start(); try { @@ -854,9 +1025,13 @@ public virtual Response PutWritableSubResourceModel1( /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetWritableSubResourceModel1Async(string writableSubResourceModel1SName, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetWritableSubResourceModel1"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); + + using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel1"); scope.Start(); try { @@ -884,9 +1059,13 @@ public virtual async Task> GetWritableSubRes /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetWritableSubResourceModel1(string writableSubResourceModel1SName, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetWritableSubResourceModel1"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel1SName, nameof(writableSubResourceModel1SName)); + + using var scope = WritableSubResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel1"); scope.Start(); try { @@ -917,7 +1096,7 @@ public virtual Response GetWritableSubResourceModel1( public virtual AsyncPageable GetWritableSubResourceModel2sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => WritableSubResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, WritableSubResourceModel2.DeserializeWritableSubResourceModel2, WritableSubResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetWritableSubResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, WritableSubResourceModel2.DeserializeWritableSubResourceModel2, WritableSubResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel2s", "value", null, cancellationToken); } /// @@ -937,7 +1116,7 @@ public virtual AsyncPageable GetWritableSubResourceMo public virtual Pageable GetWritableSubResourceModel2s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => WritableSubResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, WritableSubResourceModel2.DeserializeWritableSubResourceModel2, WritableSubResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetWritableSubResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, WritableSubResourceModel2.DeserializeWritableSubResourceModel2, WritableSubResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel2s", "value", null, cancellationToken); } /// @@ -955,9 +1134,14 @@ public virtual Pageable GetWritableSubResourceModel2s /// The String to use. /// The WritableSubResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutWritableSubResourceModel2Async(string writableSubResourceModel2SName, WritableSubResourceModel2 writableSubResourceModel2, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutWritableSubResourceModel2"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); + Argument.AssertNotNull(writableSubResourceModel2, nameof(writableSubResourceModel2)); + + using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutWritableSubResourceModel2"); scope.Start(); try { @@ -986,9 +1170,14 @@ public virtual async Task> PutWritableSubRes /// The String to use. /// The WritableSubResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutWritableSubResourceModel2(string writableSubResourceModel2SName, WritableSubResourceModel2 writableSubResourceModel2, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutWritableSubResourceModel2"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); + Argument.AssertNotNull(writableSubResourceModel2, nameof(writableSubResourceModel2)); + + using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutWritableSubResourceModel2"); scope.Start(); try { @@ -1016,9 +1205,13 @@ public virtual Response PutWritableSubResourceModel2( /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetWritableSubResourceModel2Async(string writableSubResourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetWritableSubResourceModel2"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); + + using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel2"); scope.Start(); try { @@ -1046,9 +1239,13 @@ public virtual async Task> GetWritableSubRes /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetWritableSubResourceModel2(string writableSubResourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetWritableSubResourceModel2"); + Argument.AssertNotNullOrEmpty(writableSubResourceModel2SName, nameof(writableSubResourceModel2SName)); + + using var scope = WritableSubResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetWritableSubResourceModel2"); scope.Start(); try { @@ -1079,7 +1276,7 @@ public virtual Response GetWritableSubResourceModel2( public virtual AsyncPageable GetResourceModel2sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, ResourceModel2.DeserializeResourceModel2, ResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, ResourceModel2.DeserializeResourceModel2, ResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetResourceModel2s", "value", null, cancellationToken); } /// @@ -1099,7 +1296,7 @@ public virtual AsyncPageable GetResourceModel2sAsync(Cancellatio public virtual Pageable GetResourceModel2s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => ResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, ResourceModel2.DeserializeResourceModel2, ResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, ResourceModel2.DeserializeResourceModel2, ResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetResourceModel2s", "value", null, cancellationToken); } /// @@ -1117,9 +1314,14 @@ public virtual Pageable GetResourceModel2s(CancellationToken can /// The String to use. /// The ResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutResourceModel2Async(string resourceModel2SName, ResourceModel2 resourceModel2, CancellationToken cancellationToken = default) { - using var scope = ResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutResourceModel2"); + Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); + Argument.AssertNotNull(resourceModel2, nameof(resourceModel2)); + + using var scope = ResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutResourceModel2"); scope.Start(); try { @@ -1148,9 +1350,14 @@ public virtual async Task> PutResourceModel2Async(strin /// The String to use. /// The ResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutResourceModel2(string resourceModel2SName, ResourceModel2 resourceModel2, CancellationToken cancellationToken = default) { - using var scope = ResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutResourceModel2"); + Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); + Argument.AssertNotNull(resourceModel2, nameof(resourceModel2)); + + using var scope = ResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutResourceModel2"); scope.Start(); try { @@ -1178,9 +1385,13 @@ public virtual Response PutResourceModel2(string resourceModel2S /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetResourceModel2Async(string resourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = ResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetResourceModel2"); + Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); + + using var scope = ResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetResourceModel2"); scope.Start(); try { @@ -1208,9 +1419,13 @@ public virtual async Task> GetResourceModel2Async(strin /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetResourceModel2(string resourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = ResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetResourceModel2"); + Argument.AssertNotNullOrEmpty(resourceModel2SName, nameof(resourceModel2SName)); + + using var scope = ResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetResourceModel2"); scope.Start(); try { @@ -1241,7 +1456,7 @@ public virtual Response GetResourceModel2(string resourceModel2S public virtual AsyncPageable GetTrackedResourceModel2sAsync(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TrackedResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, TrackedResourceModel2.DeserializeTrackedResourceModel2, TrackedResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetTrackedResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, TrackedResourceModel2.DeserializeTrackedResourceModel2, TrackedResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetTrackedResourceModel2s", "value", null, cancellationToken); } /// @@ -1261,7 +1476,7 @@ public virtual AsyncPageable GetTrackedResourceModel2sAsy public virtual Pageable GetTrackedResourceModel2s(CancellationToken cancellationToken = default) { HttpMessage FirstPageRequest(int? pageSizeHint) => TrackedResourceModel2sRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, TrackedResourceModel2.DeserializeTrackedResourceModel2, TrackedResourceModel2sClientDiagnostics, Pipeline, "ResourceGroupResourceExtensionClient.GetTrackedResourceModel2s", "value", null, cancellationToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, TrackedResourceModel2.DeserializeTrackedResourceModel2, TrackedResourceModel2sClientDiagnostics, Pipeline, "MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetTrackedResourceModel2s", "value", null, cancellationToken); } /// @@ -1279,9 +1494,14 @@ public virtual Pageable GetTrackedResourceModel2s(Cancell /// The String to use. /// The TrackedResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutTrackedResourceModel2Async(string trackedResourceModel2SName, TrackedResourceModel2 trackedResourceModel2, CancellationToken cancellationToken = default) { - using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutTrackedResourceModel2"); + Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); + Argument.AssertNotNull(trackedResourceModel2, nameof(trackedResourceModel2)); + + using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutTrackedResourceModel2"); scope.Start(); try { @@ -1310,9 +1530,14 @@ public virtual async Task> PutTrackedResourceMod /// The String to use. /// The TrackedResourceModel2 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutTrackedResourceModel2(string trackedResourceModel2SName, TrackedResourceModel2 trackedResourceModel2, CancellationToken cancellationToken = default) { - using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutTrackedResourceModel2"); + Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); + Argument.AssertNotNull(trackedResourceModel2, nameof(trackedResourceModel2)); + + using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutTrackedResourceModel2"); scope.Start(); try { @@ -1340,9 +1565,13 @@ public virtual Response PutTrackedResourceModel2(string t /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetTrackedResourceModel2Async(string trackedResourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetTrackedResourceModel2"); + Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); + + using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetTrackedResourceModel2"); scope.Start(); try { @@ -1370,9 +1599,13 @@ public virtual async Task> GetTrackedResourceMod /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetTrackedResourceModel2(string trackedResourceModel2SName, CancellationToken cancellationToken = default) { - using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetTrackedResourceModel2"); + Argument.AssertNotNullOrEmpty(trackedResourceModel2SName, nameof(trackedResourceModel2SName)); + + using var scope = TrackedResourceModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetTrackedResourceModel2"); scope.Start(); try { @@ -1401,9 +1634,14 @@ public virtual Response GetTrackedResourceModel2(string t /// The String to use. /// The NonResourceModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual async Task> PutNonResourceModel1Async(string nonResourceModel1SName, NonResourceModel1 nonResourceModel1, CancellationToken cancellationToken = default) { - using var scope = NonResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutNonResourceModel1"); + Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); + Argument.AssertNotNull(nonResourceModel1, nameof(nonResourceModel1)); + + using var scope = NonResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutNonResourceModel1"); scope.Start(); try { @@ -1432,9 +1670,14 @@ public virtual async Task> PutNonResourceModel1Async /// The String to use. /// The NonResourceModel1 to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. public virtual Response PutNonResourceModel1(string nonResourceModel1SName, NonResourceModel1 nonResourceModel1, CancellationToken cancellationToken = default) { - using var scope = NonResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutNonResourceModel1"); + Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); + Argument.AssertNotNull(nonResourceModel1, nameof(nonResourceModel1)); + + using var scope = NonResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.PutNonResourceModel1"); scope.Start(); try { @@ -1462,9 +1705,13 @@ public virtual Response PutNonResourceModel1(string nonResour /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual async Task> GetNonResourceModel1Async(string nonResourceModel1SName, CancellationToken cancellationToken = default) { - using var scope = NonResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetNonResourceModel1"); + Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); + + using var scope = NonResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetNonResourceModel1"); scope.Start(); try { @@ -1492,9 +1739,13 @@ public virtual async Task> GetNonResourceModel1Async /// /// The String to use. /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. public virtual Response GetNonResourceModel1(string nonResourceModel1SName, CancellationToken cancellationToken = default) { - using var scope = NonResourceModel1sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetNonResourceModel1"); + Argument.AssertNotNullOrEmpty(nonResourceModel1SName, nameof(nonResourceModel1SName)); + + using var scope = NonResourceModel1sClientDiagnostics.CreateScope("MockableMgmtSupersetFlattenInheritanceResourceGroupResource.GetNonResourceModel1"); scope.Start(); try { diff --git a/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MgmtSupersetInheritanceExtensions.cs b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MgmtSupersetInheritanceExtensions.cs index f9ce6c987ab..ea52404079c 100644 --- a/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MgmtSupersetInheritanceExtensions.cs +++ b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MgmtSupersetInheritanceExtensions.cs @@ -12,6 +12,7 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtSupersetInheritance.Mocking; using MgmtSupersetInheritance.Models; namespace MgmtSupersetInheritance @@ -19,103 +20,92 @@ namespace MgmtSupersetInheritance /// A class to add extension methods to MgmtSupersetInheritance. public static partial class MgmtSupersetInheritanceExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtSupersetInheritanceArmClient GetMockableMgmtSupersetInheritanceArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtSupersetInheritanceArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtSupersetInheritanceResourceGroupResource GetMockableMgmtSupersetInheritanceResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtSupersetInheritanceResourceGroupResource(client, resource.Id)); } - #region SupersetModel1Resource + /// /// 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. /// Returns a object. public static SupersetModel1Resource GetSupersetModel1Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SupersetModel1Resource.ValidateResourceId(id); - return new SupersetModel1Resource(client, id); - } - ); + return GetMockableMgmtSupersetInheritanceArmClient(client).GetSupersetModel1Resource(id); } - #endregion - #region SupersetModel4Resource /// /// 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. /// Returns a object. public static SupersetModel4Resource GetSupersetModel4Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SupersetModel4Resource.ValidateResourceId(id); - return new SupersetModel4Resource(client, id); - } - ); + return GetMockableMgmtSupersetInheritanceArmClient(client).GetSupersetModel4Resource(id); } - #endregion - #region SupersetModel6Resource /// /// 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. /// Returns a object. public static SupersetModel6Resource GetSupersetModel6Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SupersetModel6Resource.ValidateResourceId(id); - return new SupersetModel6Resource(client, id); - } - ); + return GetMockableMgmtSupersetInheritanceArmClient(client).GetSupersetModel6Resource(id); } - #endregion - #region SupersetModel7Resource /// /// 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. /// Returns a object. public static SupersetModel7Resource GetSupersetModel7Resource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - SupersetModel7Resource.ValidateResourceId(id); - return new SupersetModel7Resource(client, id); - } - ); + return GetMockableMgmtSupersetInheritanceArmClient(client).GetSupersetModel7Resource(id); } - #endregion - /// Gets a collection of SupersetModel1Resources in the ResourceGroupResource. + /// + /// Gets a collection of SupersetModel1Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SupersetModel1Resources and their operations over a SupersetModel1Resource. public static SupersetModel1Collection GetSupersetModel1s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel1s(); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel1s(); } /// @@ -129,16 +119,20 @@ public static SupersetModel1Collection GetSupersetModel1s(this ResourceGroupReso /// SupersetModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSupersetModel1Async(this ResourceGroupResource resourceGroupResource, string supersetModel1SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetSupersetModel1s().GetAsync(supersetModel1SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel1Async(supersetModel1SName, cancellationToken).ConfigureAwait(false); } /// @@ -152,24 +146,34 @@ public static async Task> GetSupersetModel1Asyn /// SupersetModel1s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSupersetModel1(this ResourceGroupResource resourceGroupResource, string supersetModel1SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetSupersetModel1s().Get(supersetModel1SName, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel1(supersetModel1SName, cancellationToken); } - /// Gets a collection of SupersetModel4Resources in the ResourceGroupResource. + /// + /// Gets a collection of SupersetModel4Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SupersetModel4Resources and their operations over a SupersetModel4Resource. public static SupersetModel4Collection GetSupersetModel4s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel4s(); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel4s(); } /// @@ -183,16 +187,20 @@ public static SupersetModel4Collection GetSupersetModel4s(this ResourceGroupReso /// SupersetModel4s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSupersetModel4Async(this ResourceGroupResource resourceGroupResource, string supersetModel4SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetSupersetModel4s().GetAsync(supersetModel4SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel4Async(supersetModel4SName, cancellationToken).ConfigureAwait(false); } /// @@ -206,24 +214,34 @@ public static async Task> GetSupersetModel4Asyn /// SupersetModel4s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSupersetModel4(this ResourceGroupResource resourceGroupResource, string supersetModel4SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetSupersetModel4s().Get(supersetModel4SName, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel4(supersetModel4SName, cancellationToken); } - /// Gets a collection of SupersetModel6Resources in the ResourceGroupResource. + /// + /// Gets a collection of SupersetModel6Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SupersetModel6Resources and their operations over a SupersetModel6Resource. public static SupersetModel6Collection GetSupersetModel6s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel6s(); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel6s(); } /// @@ -237,16 +255,20 @@ public static SupersetModel6Collection GetSupersetModel6s(this ResourceGroupReso /// SupersetModel6s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSupersetModel6Async(this ResourceGroupResource resourceGroupResource, string supersetModel6SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetSupersetModel6s().GetAsync(supersetModel6SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel6Async(supersetModel6SName, cancellationToken).ConfigureAwait(false); } /// @@ -260,24 +282,34 @@ public static async Task> GetSupersetModel6Asyn /// SupersetModel6s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSupersetModel6(this ResourceGroupResource resourceGroupResource, string supersetModel6SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetSupersetModel6s().Get(supersetModel6SName, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel6(supersetModel6SName, cancellationToken); } - /// Gets a collection of SupersetModel7Resources in the ResourceGroupResource. + /// + /// Gets a collection of SupersetModel7Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of SupersetModel7Resources and their operations over a SupersetModel7Resource. public static SupersetModel7Collection GetSupersetModel7s(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel7s(); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel7s(); } /// @@ -291,16 +323,20 @@ public static SupersetModel7Collection GetSupersetModel7s(this ResourceGroupReso /// SupersetModel7s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetSupersetModel7Async(this ResourceGroupResource resourceGroupResource, string supersetModel7SName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetSupersetModel7s().GetAsync(supersetModel7SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel7Async(supersetModel7SName, cancellationToken).ConfigureAwait(false); } /// @@ -314,16 +350,20 @@ public static async Task> GetSupersetModel7Asyn /// SupersetModel7s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetSupersetModel7(this ResourceGroupResource resourceGroupResource, string supersetModel7SName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetSupersetModel7s().Get(supersetModel7SName, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel7(supersetModel7SName, cancellationToken); } /// @@ -337,6 +377,10 @@ public static Response GetSupersetModel7(this ResourceGr /// SupersetModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -346,10 +390,7 @@ public static Response GetSupersetModel7(this ResourceGr /// or is null. public static async Task> PutSupersetModel2Async(this ResourceGroupResource resourceGroupResource, string supersetModel2SName, SupersetModel2 supersetModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); - Argument.AssertNotNull(supersetModel2, nameof(supersetModel2)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSupersetModel2Async(supersetModel2SName, supersetModel2, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).PutSupersetModel2Async(supersetModel2SName, supersetModel2, cancellationToken).ConfigureAwait(false); } /// @@ -363,6 +404,10 @@ public static async Task> PutSupersetModel2Async(this R /// SupersetModel2s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -372,10 +417,7 @@ public static async Task> PutSupersetModel2Async(this R /// or is null. public static Response PutSupersetModel2(this ResourceGroupResource resourceGroupResource, string supersetModel2SName, SupersetModel2 supersetModel2, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); - Argument.AssertNotNull(supersetModel2, nameof(supersetModel2)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSupersetModel2(supersetModel2SName, supersetModel2, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).PutSupersetModel2(supersetModel2SName, supersetModel2, cancellationToken); } /// @@ -389,6 +431,10 @@ public static Response PutSupersetModel2(this ResourceGroupResou /// SupersetModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -397,9 +443,7 @@ public static Response PutSupersetModel2(this ResourceGroupResou /// is null. public static async Task> GetSupersetModel2Async(this ResourceGroupResource resourceGroupResource, string supersetModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel2Async(supersetModel2SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel2Async(supersetModel2SName, cancellationToken).ConfigureAwait(false); } /// @@ -413,6 +457,10 @@ public static async Task> GetSupersetModel2Async(this R /// SupersetModel2s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -421,9 +469,7 @@ public static async Task> GetSupersetModel2Async(this R /// is null. public static Response GetSupersetModel2(this ResourceGroupResource resourceGroupResource, string supersetModel2SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel2(supersetModel2SName, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel2(supersetModel2SName, cancellationToken); } /// @@ -437,6 +483,10 @@ public static Response GetSupersetModel2(this ResourceGroupResou /// SupersetModel3s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -446,10 +496,7 @@ public static Response GetSupersetModel2(this ResourceGroupResou /// or is null. public static async Task> PutSupersetModel3Async(this ResourceGroupResource resourceGroupResource, string supersetModel3SName, SupersetModel3 supersetModel3, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); - Argument.AssertNotNull(supersetModel3, nameof(supersetModel3)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSupersetModel3Async(supersetModel3SName, supersetModel3, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).PutSupersetModel3Async(supersetModel3SName, supersetModel3, cancellationToken).ConfigureAwait(false); } /// @@ -463,6 +510,10 @@ public static async Task> PutSupersetModel3Async(this R /// SupersetModel3s_Put /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -472,10 +523,7 @@ public static async Task> PutSupersetModel3Async(this R /// or is null. public static Response PutSupersetModel3(this ResourceGroupResource resourceGroupResource, string supersetModel3SName, SupersetModel3 supersetModel3, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); - Argument.AssertNotNull(supersetModel3, nameof(supersetModel3)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).PutSupersetModel3(supersetModel3SName, supersetModel3, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).PutSupersetModel3(supersetModel3SName, supersetModel3, cancellationToken); } /// @@ -489,6 +537,10 @@ public static Response PutSupersetModel3(this ResourceGroupResou /// SupersetModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -497,9 +549,7 @@ public static Response PutSupersetModel3(this ResourceGroupResou /// is null. public static async Task> GetSupersetModel3Async(this ResourceGroupResource resourceGroupResource, string supersetModel3SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); - - return await GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel3Async(supersetModel3SName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel3Async(supersetModel3SName, cancellationToken).ConfigureAwait(false); } /// @@ -513,6 +563,10 @@ public static async Task> GetSupersetModel3Async(this R /// SupersetModel3s_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The String to use. @@ -521,9 +575,7 @@ public static async Task> GetSupersetModel3Async(this R /// is null. public static Response GetSupersetModel3(this ResourceGroupResource resourceGroupResource, string supersetModel3SName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); - - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetSupersetModel3(supersetModel3SName, cancellationToken); + return GetMockableMgmtSupersetInheritanceResourceGroupResource(resourceGroupResource).GetSupersetModel3(supersetModel3SName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MockableMgmtSupersetInheritanceArmClient.cs b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MockableMgmtSupersetInheritanceArmClient.cs new file mode 100644 index 00000000000..e71cb34a102 --- /dev/null +++ b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MockableMgmtSupersetInheritanceArmClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtSupersetInheritance; + +namespace MgmtSupersetInheritance.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtSupersetInheritanceArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSupersetInheritanceArmClient() + { + } + + /// 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 MockableMgmtSupersetInheritanceArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtSupersetInheritanceArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 SupersetModel1Resource GetSupersetModel1Resource(ResourceIdentifier id) + { + SupersetModel1Resource.ValidateResourceId(id); + return new SupersetModel1Resource(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 SupersetModel4Resource GetSupersetModel4Resource(ResourceIdentifier id) + { + SupersetModel4Resource.ValidateResourceId(id); + return new SupersetModel4Resource(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 SupersetModel6Resource GetSupersetModel6Resource(ResourceIdentifier id) + { + SupersetModel6Resource.ValidateResourceId(id); + return new SupersetModel6Resource(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 SupersetModel7Resource GetSupersetModel7Resource(ResourceIdentifier id) + { + SupersetModel7Resource.ValidateResourceId(id); + return new SupersetModel7Resource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MockableMgmtSupersetInheritanceResourceGroupResource.cs b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MockableMgmtSupersetInheritanceResourceGroupResource.cs new file mode 100644 index 00000000000..36ee55ed555 --- /dev/null +++ b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/MockableMgmtSupersetInheritanceResourceGroupResource.cs @@ -0,0 +1,535 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using MgmtSupersetInheritance; +using MgmtSupersetInheritance.Models; + +namespace MgmtSupersetInheritance.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtSupersetInheritanceResourceGroupResource : ArmResource + { + private ClientDiagnostics _supersetModel2sClientDiagnostics; + private SupersetModel2SRestOperations _supersetModel2sRestClient; + private ClientDiagnostics _supersetModel3sClientDiagnostics; + private SupersetModel3SRestOperations _supersetModel3sRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableMgmtSupersetInheritanceResourceGroupResource() + { + } + + /// 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 MockableMgmtSupersetInheritanceResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics SupersetModel2sClientDiagnostics => _supersetModel2sClientDiagnostics ??= new ClientDiagnostics("MgmtSupersetInheritance", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private SupersetModel2SRestOperations SupersetModel2sRestClient => _supersetModel2sRestClient ??= new SupersetModel2SRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + private ClientDiagnostics SupersetModel3sClientDiagnostics => _supersetModel3sClientDiagnostics ??= new ClientDiagnostics("MgmtSupersetInheritance", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private SupersetModel3SRestOperations SupersetModel3sRestClient => _supersetModel3sRestClient ??= new SupersetModel3SRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of SupersetModel1Resources in the ResourceGroupResource. + /// An object representing collection of SupersetModel1Resources and their operations over a SupersetModel1Resource. + public virtual SupersetModel1Collection GetSupersetModel1s() + { + return GetCachedClient(client => new SupersetModel1Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel1s/{supersetModel1sName} + /// + /// + /// Operation Id + /// SupersetModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSupersetModel1Async(string supersetModel1SName, CancellationToken cancellationToken = default) + { + return await GetSupersetModel1s().GetAsync(supersetModel1SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel1s/{supersetModel1sName} + /// + /// + /// Operation Id + /// SupersetModel1s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSupersetModel1(string supersetModel1SName, CancellationToken cancellationToken = default) + { + return GetSupersetModel1s().Get(supersetModel1SName, cancellationToken); + } + + /// Gets a collection of SupersetModel4Resources in the ResourceGroupResource. + /// An object representing collection of SupersetModel4Resources and their operations over a SupersetModel4Resource. + public virtual SupersetModel4Collection GetSupersetModel4s() + { + return GetCachedClient(client => new SupersetModel4Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel4s/{supersetModel4sName} + /// + /// + /// Operation Id + /// SupersetModel4s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSupersetModel4Async(string supersetModel4SName, CancellationToken cancellationToken = default) + { + return await GetSupersetModel4s().GetAsync(supersetModel4SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel4s/{supersetModel4sName} + /// + /// + /// Operation Id + /// SupersetModel4s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSupersetModel4(string supersetModel4SName, CancellationToken cancellationToken = default) + { + return GetSupersetModel4s().Get(supersetModel4SName, cancellationToken); + } + + /// Gets a collection of SupersetModel6Resources in the ResourceGroupResource. + /// An object representing collection of SupersetModel6Resources and their operations over a SupersetModel6Resource. + public virtual SupersetModel6Collection GetSupersetModel6s() + { + return GetCachedClient(client => new SupersetModel6Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel6s/{supersetModel6sName} + /// + /// + /// Operation Id + /// SupersetModel6s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSupersetModel6Async(string supersetModel6SName, CancellationToken cancellationToken = default) + { + return await GetSupersetModel6s().GetAsync(supersetModel6SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel6s/{supersetModel6sName} + /// + /// + /// Operation Id + /// SupersetModel6s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSupersetModel6(string supersetModel6SName, CancellationToken cancellationToken = default) + { + return GetSupersetModel6s().Get(supersetModel6SName, cancellationToken); + } + + /// Gets a collection of SupersetModel7Resources in the ResourceGroupResource. + /// An object representing collection of SupersetModel7Resources and their operations over a SupersetModel7Resource. + public virtual SupersetModel7Collection GetSupersetModel7s() + { + return GetCachedClient(client => new SupersetModel7Collection(client, Id)); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel7s/{supersetModel7sName} + /// + /// + /// Operation Id + /// SupersetModel7s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSupersetModel7Async(string supersetModel7SName, CancellationToken cancellationToken = default) + { + return await GetSupersetModel7s().GetAsync(supersetModel7SName, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel7s/{supersetModel7sName} + /// + /// + /// Operation Id + /// SupersetModel7s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSupersetModel7(string supersetModel7SName, CancellationToken cancellationToken = default) + { + return GetSupersetModel7s().Get(supersetModel7SName, cancellationToken); + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} + /// + /// + /// Operation Id + /// SupersetModel2s_Put + /// + /// + /// + /// The String to use. + /// The SupersetModel2 to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> PutSupersetModel2Async(string supersetModel2SName, SupersetModel2 supersetModel2, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); + Argument.AssertNotNull(supersetModel2, nameof(supersetModel2)); + + using var scope = SupersetModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.PutSupersetModel2"); + scope.Start(); + try + { + var response = await SupersetModel2sRestClient.PutAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, supersetModel2, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} + /// + /// + /// Operation Id + /// SupersetModel2s_Put + /// + /// + /// + /// The String to use. + /// The SupersetModel2 to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response PutSupersetModel2(string supersetModel2SName, SupersetModel2 supersetModel2, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); + Argument.AssertNotNull(supersetModel2, nameof(supersetModel2)); + + using var scope = SupersetModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.PutSupersetModel2"); + scope.Start(); + try + { + var response = SupersetModel2sRestClient.Put(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, supersetModel2, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} + /// + /// + /// Operation Id + /// SupersetModel2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetSupersetModel2Async(string supersetModel2SName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); + + using var scope = SupersetModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.GetSupersetModel2"); + scope.Start(); + try + { + var response = await SupersetModel2sRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} + /// + /// + /// Operation Id + /// SupersetModel2s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response GetSupersetModel2(string supersetModel2SName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel2SName, nameof(supersetModel2SName)); + + using var scope = SupersetModel2sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.GetSupersetModel2"); + scope.Start(); + try + { + var response = SupersetModel2sRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} + /// + /// + /// Operation Id + /// SupersetModel3s_Put + /// + /// + /// + /// The String to use. + /// The SupersetModel3 to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> PutSupersetModel3Async(string supersetModel3SName, SupersetModel3 supersetModel3, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); + Argument.AssertNotNull(supersetModel3, nameof(supersetModel3)); + + using var scope = SupersetModel3sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.PutSupersetModel3"); + scope.Start(); + try + { + var response = await SupersetModel3sRestClient.PutAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, supersetModel3, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} + /// + /// + /// Operation Id + /// SupersetModel3s_Put + /// + /// + /// + /// The String to use. + /// The SupersetModel3 to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response PutSupersetModel3(string supersetModel3SName, SupersetModel3 supersetModel3, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); + Argument.AssertNotNull(supersetModel3, nameof(supersetModel3)); + + using var scope = SupersetModel3sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.PutSupersetModel3"); + scope.Start(); + try + { + var response = SupersetModel3sRestClient.Put(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, supersetModel3, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} + /// + /// + /// Operation Id + /// SupersetModel3s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetSupersetModel3Async(string supersetModel3SName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); + + using var scope = SupersetModel3sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.GetSupersetModel3"); + scope.Start(); + try + { + var response = await SupersetModel3sRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} + /// + /// + /// Operation Id + /// SupersetModel3s_Get + /// + /// + /// + /// The String to use. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response GetSupersetModel3(string supersetModel3SName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(supersetModel3SName, nameof(supersetModel3SName)); + + using var scope = SupersetModel3sClientDiagnostics.CreateScope("MockableMgmtSupersetInheritanceResourceGroupResource.GetSupersetModel3"); + scope.Start(); + try + { + var response = SupersetModel3sRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 93e03f3aecd..00000000000 --- a/test/TestProjects/MgmtSupersetInheritance/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using Azure.ResourceManager; -using MgmtSupersetInheritance.Models; - -namespace MgmtSupersetInheritance -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - private ClientDiagnostics _supersetModel2sClientDiagnostics; - private SupersetModel2SRestOperations _supersetModel2sRestClient; - private ClientDiagnostics _supersetModel3sClientDiagnostics; - private SupersetModel3SRestOperations _supersetModel3sRestClient; - - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private ClientDiagnostics SupersetModel2sClientDiagnostics => _supersetModel2sClientDiagnostics ??= new ClientDiagnostics("MgmtSupersetInheritance", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private SupersetModel2SRestOperations SupersetModel2sRestClient => _supersetModel2sRestClient ??= new SupersetModel2SRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); - private ClientDiagnostics SupersetModel3sClientDiagnostics => _supersetModel3sClientDiagnostics ??= new ClientDiagnostics("MgmtSupersetInheritance", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private SupersetModel3SRestOperations SupersetModel3sRestClient => _supersetModel3sRestClient ??= new SupersetModel3SRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of SupersetModel1Resources in the ResourceGroupResource. - /// An object representing collection of SupersetModel1Resources and their operations over a SupersetModel1Resource. - public virtual SupersetModel1Collection GetSupersetModel1s() - { - return GetCachedClient(Client => new SupersetModel1Collection(Client, Id)); - } - - /// Gets a collection of SupersetModel4Resources in the ResourceGroupResource. - /// An object representing collection of SupersetModel4Resources and their operations over a SupersetModel4Resource. - public virtual SupersetModel4Collection GetSupersetModel4s() - { - return GetCachedClient(Client => new SupersetModel4Collection(Client, Id)); - } - - /// Gets a collection of SupersetModel6Resources in the ResourceGroupResource. - /// An object representing collection of SupersetModel6Resources and their operations over a SupersetModel6Resource. - public virtual SupersetModel6Collection GetSupersetModel6s() - { - return GetCachedClient(Client => new SupersetModel6Collection(Client, Id)); - } - - /// Gets a collection of SupersetModel7Resources in the ResourceGroupResource. - /// An object representing collection of SupersetModel7Resources and their operations over a SupersetModel7Resource. - public virtual SupersetModel7Collection GetSupersetModel7s() - { - return GetCachedClient(Client => new SupersetModel7Collection(Client, Id)); - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} - /// - /// - /// Operation Id - /// SupersetModel2s_Put - /// - /// - /// - /// The String to use. - /// The SupersetModel2 to use. - /// The cancellation token to use. - public virtual async Task> PutSupersetModel2Async(string supersetModel2SName, SupersetModel2 supersetModel2, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSupersetModel2"); - scope.Start(); - try - { - var response = await SupersetModel2sRestClient.PutAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, supersetModel2, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} - /// - /// - /// Operation Id - /// SupersetModel2s_Put - /// - /// - /// - /// The String to use. - /// The SupersetModel2 to use. - /// The cancellation token to use. - public virtual Response PutSupersetModel2(string supersetModel2SName, SupersetModel2 supersetModel2, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSupersetModel2"); - scope.Start(); - try - { - var response = SupersetModel2sRestClient.Put(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, supersetModel2, cancellationToken); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} - /// - /// - /// Operation Id - /// SupersetModel2s_Get - /// - /// - /// - /// The String to use. - /// The cancellation token to use. - public virtual async Task> GetSupersetModel2Async(string supersetModel2SName, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSupersetModel2"); - scope.Start(); - try - { - var response = await SupersetModel2sRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel2s/{supersetModel2sName} - /// - /// - /// Operation Id - /// SupersetModel2s_Get - /// - /// - /// - /// The String to use. - /// The cancellation token to use. - public virtual Response GetSupersetModel2(string supersetModel2SName, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel2sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSupersetModel2"); - scope.Start(); - try - { - var response = SupersetModel2sRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, supersetModel2SName, cancellationToken); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} - /// - /// - /// Operation Id - /// SupersetModel3s_Put - /// - /// - /// - /// The String to use. - /// The SupersetModel3 to use. - /// The cancellation token to use. - public virtual async Task> PutSupersetModel3Async(string supersetModel3SName, SupersetModel3 supersetModel3, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSupersetModel3"); - scope.Start(); - try - { - var response = await SupersetModel3sRestClient.PutAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, supersetModel3, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} - /// - /// - /// Operation Id - /// SupersetModel3s_Put - /// - /// - /// - /// The String to use. - /// The SupersetModel3 to use. - /// The cancellation token to use. - public virtual Response PutSupersetModel3(string supersetModel3SName, SupersetModel3 supersetModel3, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.PutSupersetModel3"); - scope.Start(); - try - { - var response = SupersetModel3sRestClient.Put(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, supersetModel3, cancellationToken); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} - /// - /// - /// Operation Id - /// SupersetModel3s_Get - /// - /// - /// - /// The String to use. - /// The cancellation token to use. - public virtual async Task> GetSupersetModel3Async(string supersetModel3SName, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSupersetModel3"); - scope.Start(); - try - { - var response = await SupersetModel3sRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/supersetModel3s/{supersetModel3sName} - /// - /// - /// Operation Id - /// SupersetModel3s_Get - /// - /// - /// - /// The String to use. - /// The cancellation token to use. - public virtual Response GetSupersetModel3(string supersetModel3SName, CancellationToken cancellationToken = default) - { - using var scope = SupersetModel3sClientDiagnostics.CreateScope("ResourceGroupResourceExtensionClient.GetSupersetModel3"); - scope.Start(); - try - { - var response = SupersetModel3sRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, supersetModel3SName, cancellationToken); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - } -} diff --git a/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MgmtXmlDeserializationExtensions.cs b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MgmtXmlDeserializationExtensions.cs index 126ff3e805f..a564d39fd93 100644 --- a/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MgmtXmlDeserializationExtensions.cs +++ b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MgmtXmlDeserializationExtensions.cs @@ -12,52 +12,51 @@ using Azure.Core; using Azure.ResourceManager; using Azure.ResourceManager.Resources; +using MgmtXmlDeserialization.Mocking; namespace MgmtXmlDeserialization { /// A class to add extension methods to MgmtXmlDeserialization. public static partial class MgmtXmlDeserializationExtensions { - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + private static MockableMgmtXmlDeserializationArmClient GetMockableMgmtXmlDeserializationArmClient(ArmClient client) { - return resource.GetCachedClient(client => - { - return new ResourceGroupResourceExtensionClient(client, resource.Id); - }); + return client.GetCachedClient(client0 => new MockableMgmtXmlDeserializationArmClient(client0)); } - private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + private static MockableMgmtXmlDeserializationResourceGroupResource GetMockableMgmtXmlDeserializationResourceGroupResource(ArmResource resource) { - return client.GetResourceClient(() => - { - return new ResourceGroupResourceExtensionClient(client, scope); - }); + return resource.GetCachedClient(client => new MockableMgmtXmlDeserializationResourceGroupResource(client, resource.Id)); } - #region XmlInstanceResource + /// /// 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. /// Returns a object. public static XmlInstanceResource GetXmlInstanceResource(this ArmClient client, ResourceIdentifier id) { - return client.GetResourceClient(() => - { - XmlInstanceResource.ValidateResourceId(id); - return new XmlInstanceResource(client, id); - } - ); + return GetMockableMgmtXmlDeserializationArmClient(client).GetXmlInstanceResource(id); } - #endregion - /// Gets a collection of XmlInstanceResources in the ResourceGroupResource. + /// + /// Gets a collection of XmlInstanceResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// /// The instance the method will execute against. /// An object representing collection of XmlInstanceResources and their operations over a XmlInstanceResource. public static XmlInstanceCollection GetXmlInstances(this ResourceGroupResource resourceGroupResource) { - return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetXmlInstances(); + return GetMockableMgmtXmlDeserializationResourceGroupResource(resourceGroupResource).GetXmlInstances(); } /// @@ -72,16 +71,20 @@ public static XmlInstanceCollection GetXmlInstances(this ResourceGroupResource r /// XmlDeserialization_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the API Management service. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static async Task> GetXmlInstanceAsync(this ResourceGroupResource resourceGroupResource, string xmlName, CancellationToken cancellationToken = default) { - return await resourceGroupResource.GetXmlInstances().GetAsync(xmlName, cancellationToken).ConfigureAwait(false); + return await GetMockableMgmtXmlDeserializationResourceGroupResource(resourceGroupResource).GetXmlInstanceAsync(xmlName, cancellationToken).ConfigureAwait(false); } /// @@ -96,16 +99,20 @@ public static async Task> GetXmlInstanceAsync(this /// XmlDeserialization_Get /// /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// /// /// The instance the method will execute against. /// The name of the API Management service. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. [ForwardsClientCalls] public static Response GetXmlInstance(this ResourceGroupResource resourceGroupResource, string xmlName, CancellationToken cancellationToken = default) { - return resourceGroupResource.GetXmlInstances().Get(xmlName, cancellationToken); + return GetMockableMgmtXmlDeserializationResourceGroupResource(resourceGroupResource).GetXmlInstance(xmlName, cancellationToken); } } } diff --git a/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MockableMgmtXmlDeserializationArmClient.cs b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MockableMgmtXmlDeserializationArmClient.cs new file mode 100644 index 00000000000..805fa2998c0 --- /dev/null +++ b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MockableMgmtXmlDeserializationArmClient.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; +using MgmtXmlDeserialization; + +namespace MgmtXmlDeserialization.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMgmtXmlDeserializationArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtXmlDeserializationArmClient() + { + } + + /// 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 MockableMgmtXmlDeserializationArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMgmtXmlDeserializationArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 XmlInstanceResource GetXmlInstanceResource(ResourceIdentifier id) + { + XmlInstanceResource.ValidateResourceId(id); + return new XmlInstanceResource(Client, id); + } + } +} diff --git a/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MockableMgmtXmlDeserializationResourceGroupResource.cs b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MockableMgmtXmlDeserializationResourceGroupResource.cs new file mode 100644 index 00000000000..a0eb745c088 --- /dev/null +++ b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/MockableMgmtXmlDeserializationResourceGroupResource.cs @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; +using MgmtXmlDeserialization; + +namespace MgmtXmlDeserialization.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMgmtXmlDeserializationResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMgmtXmlDeserializationResourceGroupResource() + { + } + + /// 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 MockableMgmtXmlDeserializationResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of XmlInstanceResources in the ResourceGroupResource. + /// An object representing collection of XmlInstanceResources and their operations over a XmlInstanceResource. + public virtual XmlInstanceCollection GetXmlInstances() + { + return GetCachedClient(client => new XmlInstanceCollection(client, Id)); + } + + /// + /// Gets the details of the Xml specified by its identifier. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.XmlDeserialization/xmls/{xmlName} + /// + /// + /// Operation Id + /// XmlDeserialization_Get + /// + /// + /// + /// The name of the API Management service. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetXmlInstanceAsync(string xmlName, CancellationToken cancellationToken = default) + { + return await GetXmlInstances().GetAsync(xmlName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the details of the Xml specified by its identifier. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.XmlDeserialization/xmls/{xmlName} + /// + /// + /// Operation Id + /// XmlDeserialization_Get + /// + /// + /// + /// The name of the API Management service. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetXmlInstance(string xmlName, CancellationToken cancellationToken = default) + { + return GetXmlInstances().Get(xmlName, cancellationToken); + } + } +} diff --git a/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/ResourceGroupResourceExtensionClient.cs deleted file mode 100644 index 8fcba18fb5f..00000000000 --- a/test/TestProjects/MgmtXmlDeserialization/Generated/Extensions/ResourceGroupResourceExtensionClient.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager; - -namespace MgmtXmlDeserialization -{ - /// A class to add extension methods to ResourceGroupResource. - internal partial class ResourceGroupResourceExtensionClient : ArmResource - { - /// Initializes a new instance of the class for mocking. - protected ResourceGroupResourceExtensionClient() - { - } - - /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of XmlInstanceResources in the ResourceGroupResource. - /// An object representing collection of XmlInstanceResources and their operations over a XmlInstanceResource. - public virtual XmlInstanceCollection GetXmlInstances() - { - return GetCachedClient(Client => new XmlInstanceCollection(Client, Id)); - } - } -}