/// <summary>
 /// Initializes a new instance of the <see cref="AzureResourceManagerClient"/> class.
 /// </summary>
 /// <param name="baseUri"> The base URI of the service. </param>
 /// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
 /// <param name="defaultSubscriptionId"> The id of the default Azure subscription. </param>
 /// <param name="options"> The client parameters to use in these operations. </param>
 public AzureResourceManagerClient(Uri baseUri, TokenCredential credential, string defaultSubscriptionId, AzureResourceManagerClientOptions options)
 {
     ClientOptions = new AzureResourceManagerClientOptions(baseUri, credential, options);
     defaultSubscriptionId ??= GetDefaultSubscription().ConfigureAwait(false).GetAwaiter().GetResult();
     DefaultSubscription = new SubscriptionOperations(ClientOptions, new ResourceIdentifier($"/subscriptions/{defaultSubscriptionId}"));
     ApiVersionOverrides = new Dictionary <string, string>();
 }
Exemple #2
0
 /// <summary>
 /// List resources under the a resource context
 /// </summary>
 /// <param name="subscription"> The <see cref="SubscriptionOperations"/> instance to use for the list. </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>
 public static AsyncPageable <GenericResource> ListAtContextAsync(
     SubscriptionOperations subscription,
     ResourceFilterCollection resourceFilters = null,
     int?top = null,
     CancellationToken cancellationToken = default)
 {
     return(ListAtContextInternalAsync(
                subscription,
                null,
                resourceFilters,
                top,
                cancellationToken));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceGroupOperations"/> class.
        /// </summary>
        /// <param name="options"> The client parameters to use in these operations. </param>
        /// <param name="rgName"> The name of the resource group to use. </param>
        internal ResourceGroupOperations(SubscriptionOperations options, string rgName)
            : base(options, $"{options.Id}/resourceGroups/{rgName}")
        {
            if (rgName.Length > 90)
            {
                throw new ArgumentOutOfRangeException("ResourceGroupName cannot be longer than 90 characters.");
            }

            if (!ValidationPattern.IsMatch(rgName))
            {
                throw new ArgumentException("The name of the resource group can include alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters that match the allowed characters.");
            }
        }
 /// <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));
 }
Exemple #5
0
 /// <summary>
 /// List resources under a subscription
 /// </summary>
 /// <param name="subscription"> The <see cref="SubscriptionOperations"/> instance to use for the list. </param>
 /// <param name="resourceFilters"> Optional filters for results. </param>
 /// <param name="expand"> Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. </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="CancellationToken.None" />. </param>
 /// <returns> A collection of resource operations that may take multiple service requests to iterate over. </returns>
 public static Pageable <GenericResourceExpanded> ListAtContext(
     SubscriptionOperations subscription,
     ResourceFilterCollection resourceFilters = null,
     string expand = null,
     int?top       = null,
     CancellationToken cancellationToken = default)
 {
     return(ListAtContextInternal(
                subscription,
                null,
                resourceFilters,
                expand,
                top,
                cancellationToken));
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Subscription"/> class.
 /// </summary>
 /// <param name="subscription"> The subscription operations to copy the client options from. </param>
 /// <param name="subscriptionData"> The resource data model. </param>
 internal Subscription(SubscriptionOperations subscription, SubscriptionData subscriptionData)
     : base(subscription, subscriptionData.Id)
 {
     Data = subscriptionData;
 }
Exemple #7
0
 internal ResourceGroupContainer(AzureResourceManagerClientOptions options, SubscriptionOperations subscription)
     : base(options, subscription.Id)
 {
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocationContainer"/> class.
 /// </summary>
 /// <param name="subscriptionOperations"> The subscription that this location container belongs to. </param>
 internal LocationContainer(SubscriptionOperations subscriptionOperations)
     : base(subscriptionOperations.ClientOptions, subscriptionOperations.Id, subscriptionOperations.Credential, subscriptionOperations.BaseUri)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceGroupOperations"/> class.
 /// </summary>
 /// <param name="options"> The client parameters to use in these operations. </param>
 /// <param name="rgName"> The name of the resource group to use. </param>
 internal ResourceGroupOperations(SubscriptionOperations options, string rgName)
     : base(options, $"{options.Id}/resourceGroups/{rgName}")
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionOperations"/> class.
 /// </summary>
 /// <param name="subscription"> The subscription operations to copy client options from. </param>
 /// <param name="id"> The identifier of the subscription. </param>
 protected SubscriptionOperations(SubscriptionOperations subscription, ResourceIdentifier id)
     : base(subscription.ClientOptions, id, subscription.Credential, subscription.BaseUri)
 {
 }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceGroupContainer"/> class.
 /// </summary>
 /// <param name="subscription"> The parent subscription. </param>
 internal ResourceGroupContainer(SubscriptionOperations subscription)
     : base(subscription)
 {
 }