Example #1
0
        /// <summary>
        /// Filters the list of virtual machines for this resource group represented as generic resources.
        /// </summary>
        /// <param name="filter"> The substring to filter by. </param>
        /// <param name="top"> The number of items to truncate by. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
        /// <returns> An async collection of <see cref="ArmResource"/> that may take multiple service requests to iterate over. </returns>
        public AsyncPageable <ArmResource> ListByNameAsync(ArmSubstringFilter filter, int?top = null, CancellationToken cancellationToken = default)
        {
            ArmFilterCollection filters = new ArmFilterCollection(VirtualMachineOperations.ResourceType);

            filters.SubstringFilter = filter;
            return(ResourceListOperations.ListAtContextAsync(ClientOptions, Id, filters, top, cancellationToken));
        }
        public Pageable <ArmResource> ListByName(ArmSubstringFilter filter, int?top = null, CancellationToken cancellationToken = default)
        {
            ArmFilterCollection filters = new ArmFilterCollection(PublicIPAddressData.ResourceType);

            filters.SubstringFilter = filter;
            return(ResourceListOperations.ListAtContext(ClientOptions, Id, filters, top, cancellationToken));
        }
        private static Pageable <ArmResource> ListAtContextInternal(
            AzureResourceManagerClientOptions clientOptions,
            ResourceIdentifier scopeId,
            string scopeFilter = null,
            ArmFilterCollection resourceFilters = null,
            int?top = null,
            CancellationToken cancellationToken = default)
        {
            var resourceOperations = GetResourcesClient(clientOptions, scopeId.Subscription).Resources;
            Pageable <GenericResourceExpanded> result;

            if (scopeFilter == null)
            {
                result = resourceOperations.List(resourceFilters?.ToString(), null, top, cancellationToken);
            }
            else
            {
                result = resourceOperations.ListByResourceGroup(
                    scopeFilter,
                    resourceFilters?.ToString(),
                    null,
                    top,
                    cancellationToken);
            }

            return(ConvertResults(result, clientOptions));
        }
        public static Pageable <ArmResource> ListVirtualMachinesByName(this SubscriptionOperations subscription, ArmSubstringFilter filter, int?top = null, CancellationToken cancellationToken = default)
        {
            ArmFilterCollection filters = new ArmFilterCollection(VirtualMachineOperations.ResourceType);

            filters.SubstringFilter = filter;
            return(ResourceListOperations.ListAtContext(subscription.ClientOptions, subscription.Id, filters, top, cancellationToken));
        }
 /// <summary>
 /// List resources under a subscription
 /// </summary>
 /// <param name="subscription"> The id of the Azure subscription. </param>
 /// <param name="resourceFilters"> Optional filters for results. </param>
 /// <param name="top"> The number of results to return. </param>
 /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service.
 /// The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
 /// <returns> A collection of resource operations that may take multiple service requests to iterate over. </returns>
 public static Pageable <ArmResource> ListAtContext(
     SubscriptionOperations subscription,
     ArmFilterCollection resourceFilters = null,
     int?top = null,
     CancellationToken cancellationToken = default)
 {
     return(ListAtContextInternal(
                subscription.ClientOptions,
                subscription.Id,
                null,
                resourceFilters,
                top,
                cancellationToken));
 }
        /// <summary>
        /// List resources under the a resource context
        /// </summary>
        /// <param name="clientOptions"> The client parameters to use in these operations. </param>
        /// <param name="id"> The identifier of the resource that is the target of operations. </param>
        /// <param name="resourceFilters"> Optional filters for results. </param>
        /// <param name="top"> The number of results to return. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service.
        /// The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
        /// <returns>An async collection of resource operations that may take multiple service requests to iterate over. </returns>
        /// <exception cref="ArgumentException"> <paramref name="id"/> is not valid to list at context. </exception>
        public static AsyncPageable <ArmResource> ListAtContextAsync(
            AzureResourceManagerClientOptions clientOptions,
            ResourceIdentifier id,
            ArmFilterCollection resourceFilters = null,
            int?top = null,
            CancellationToken cancellationToken = default)
        {
            Validate(id);

            var scopeId = id.Type == ResourceGroupOperations.ResourceType ? id.Name : null;

            return(ListAtContextInternalAsync(
                       clientOptions,
                       id,
                       scopeId,
                       resourceFilters,
                       top,
                       cancellationToken));
        }