internal RestApiCollection(ArmResource operation, string nameSpace)
     : base(operation)
 {
     _clientDiagnostics  = new ClientDiagnostics("Azure.ResourceManager.Resources", nameSpace, DiagnosticOptions);
     _nameSpace          = nameSpace;
     _providerCollection = new ProviderCollection(ArmClient.GetSubscription(Id));
 }
        internal GenericResource(ArmClient armClient, ResourceIdentifier id) : base(armClient, 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);
            ArmClient.TryGetApiVersion(Id.ResourceType, out string apiVersion);
            _resourcesRestClient = new ResourcesRestOperations(_clientDiagnostics, Pipeline, DiagnosticOptions.ApplicationId, BaseUri, apiVersion);
            _providerCollection  = new ProviderCollection(ArmClient.GetSubscription(subscription));
        }
Example #3
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 new ProviderCollection(ArmClient.GetSubscription(subscription)).TryGetApiVersionAsync(resourceId.ResourceType, cancellationToken).ConfigureAwait(false);

            if (version is null)
            {
                throw new InvalidOperationException($"An invalid resource id was given {resourceId}");
            }
            return(version);
        }
Example #4
0
        public DeploymentCollection GetDeploymentCollection(ArmClient armClient, ResourceIdentifier resourceIdentifier, string scope)
        {
            switch (scope)
            {
            case LanguageConstants.TargetScopeTypeResourceGroup:
                var resourceGroup = armClient.GetResourceGroup(resourceIdentifier);
                return(resourceGroup.GetDeployments());

            case LanguageConstants.TargetScopeTypeSubscription:
                var subscription = armClient.GetSubscription(resourceIdentifier);
                return(subscription.GetDeployments());

            case LanguageConstants.TargetScopeTypeManagementGroup:
                var managementGroup = armClient.GetManagementGroup(resourceIdentifier);
                return(managementGroup.GetDeployments());

            default:
                throw new Exception(string.Format(LangServerResources.UnsupportedTargetScopeMessage, scope));
            }
        }