Ejemplo n.º 1
0
 internal RestApiCollection(ArmResource operation, string nameSpace)
     : base(operation.Client, operation.Id)
 {
     _clientDiagnostics  = new ClientDiagnostics("Azure.ResourceManager.Resources", nameSpace, DiagnosticOptions);
     _nameSpace          = nameSpace;
     _providerCollection = new ProviderCollection(Client.GetSubscription(Id));
 }
Ejemplo n.º 2
0
        internal GenericResource(ArmClient client, ResourceIdentifier id) : base(client, id)
        {
            ResourceIdentifier subscription = Id.GetSubscriptionResourceIdentifier();

            if (subscription == null)
            {
                throw new ArgumentException("Only resource in a subscription is supported");
            }
            _clientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Resources", Id.ResourceType.Namespace, DiagnosticOptions);
            TryGetApiVersion(Id.ResourceType, out string apiVersion);
            _resourcesRestClient = new ResourcesRestOperations(_clientDiagnostics, Pipeline, DiagnosticOptions.ApplicationId, BaseUri, apiVersion);
            _providerCollection  = new ProviderCollection(Client.GetSubscription(subscription));
        }
Ejemplo n.º 3
0
        private string GetApiVersion(ResourceIdentifier resourceId, CancellationToken cancellationToken)
        {
            ResourceIdentifier subscription = resourceId.GetSubscriptionResourceIdentifier();

            if (subscription == null)
            {
                throw new ArgumentException("Only resource id in a subscription is supported", nameof(resourceId));
            }
            string version = new ProviderCollection(ArmClient.GetSubscription(subscription)).TryGetApiVersion(resourceId.ResourceType, cancellationToken);

            if (version is null)
            {
                throw new InvalidOperationException($"An invalid resource id was given {resourceId}");
            }
            return(version);
        }