public void GetSubscriptionResourceIdentifier(string resourceId, bool shouldBeNull)
        {
            ResourceIdentifier id    = new ResourceIdentifier(resourceId);
            ResourceIdentifier subId = id.GetSubscriptionResourceIdentifier();

            if (shouldBeNull)
            {
                Assert.IsNull(subId);
            }
            else
            {
                Assert.IsNotNull(subId);
            }
        }
Exemplo n.º 2
0
        private async Task <string> GetApiVersionAsync(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 = await GetProviderCollectionForSubscription(subscription).GetApiVersionAsync(resourceId.ResourceType, cancellationToken).ConfigureAwait(false);

            if (version is null)
            {
                throw new InvalidOperationException($"An invalid resource id was given {resourceId}");
            }
            return(version);
        }
Exemplo 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);
        }