public virtual Response <bool> Exists(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(templateSpecName, nameof(templateSpecName));

            using var scope = _templateSpecClientDiagnostics.CreateScope("TemplateSpecCollection.Exists");
            scope.Start();
            try
            {
                var response = _templateSpecRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, expand, cancellationToken: cancellationToken);
                return(Response.FromValue(response.Value != null, response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #2
0
 public virtual Response <TemplateSpec> Get(TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("TemplateSpec.Get");
     scope.Start();
     try
     {
         var response = _templateSpecsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken);
         if (response.Value == null)
         {
             throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
         }
         return(Response.FromValue(new TemplateSpec(this, response.Value), response.GetRawResponse()));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Example #3
0
        public virtual Response <bool> CheckIfExists(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            if (templateSpecName == null)
            {
                throw new ArgumentNullException(nameof(templateSpecName));
            }

            using var scope = _clientDiagnostics.CreateScope("TemplateSpecCollection.CheckIfExists");
            scope.Start();
            try
            {
                var response = GetIfExists(templateSpecName, expand, cancellationToken: cancellationToken);
                return(Response.FromValue(response.Value != null, response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual async Task <Response <TemplateSpecResource> > GetAsync(TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _templateSpecClientDiagnostics.CreateScope("TemplateSpecResource.Get");
            scope.Start();
            try
            {
                var response = await _templateSpecRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new TemplateSpecResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #5
0
        public virtual Response <TemplateSpec> GetIfExists(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            if (templateSpecName == null)
            {
                throw new ArgumentNullException(nameof(templateSpecName));
            }

            using var scope = _clientDiagnostics.CreateScope("TemplateSpecCollection.GetIfExists");
            scope.Start();
            try
            {
                var response = _templateSpecsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, expand, cancellationToken: cancellationToken);
                return(response.Value == null
                    ? Response.FromValue <TemplateSpec>(null, response.GetRawResponse())
                    : Response.FromValue(new TemplateSpec(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual AsyncPageable <TemplateSpec> GetTemplateSpecsAsync(TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <TemplateSpec> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = TemplateSpecClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetTemplateSpecs");
                scope.Start();
                try
                {
                    var response = await TemplateSpecRestClient.ListBySubscriptionAsync(Id.SubscriptionId, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value.Select(value => new TemplateSpec(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <TemplateSpec> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = TemplateSpecClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetTemplateSpecs");
                scope.Start();
                try
                {
                    var response = await TemplateSpecRestClient.ListBySubscriptionNextPageAsync(nextLink, Id.SubscriptionId, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value.Select(value => new TemplateSpec(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Example #7
0
        public virtual AsyncPageable <TemplateSpec> GetAllAsync(TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <TemplateSpec> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("TemplateSpecContainer.GetAll");
                scope.Start();
                try
                {
                    var response = await _restClient.GetAllByResourceGroupAsync(Id.ResourceGroupName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value.Select(value => new TemplateSpec(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <TemplateSpec> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("TemplateSpecContainer.GetAll");
                scope.Start();
                try
                {
                    var response = await _restClient.GetAllByResourceGroupNextPageAsync(nextLink, Id.ResourceGroupName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value.Select(value => new TemplateSpec(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Example #8
0
        public virtual Pageable <TemplateSpecResource> GetTemplateSpecs(TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            Page <TemplateSpecResource> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = TemplateSpecClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetTemplateSpecs");
                scope.Start();
                try
                {
                    var response = TemplateSpecRestClient.ListBySubscription(Id.SubscriptionId, expand, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new TemplateSpecResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <TemplateSpecResource> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = TemplateSpecClientDiagnostics.CreateScope("SubscriptionResourceExtensionClient.GetTemplateSpecs");
                scope.Start();
                try
                {
                    var response = TemplateSpecRestClient.ListBySubscriptionNextPage(nextLink, Id.SubscriptionId, expand, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new TemplateSpecResource(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }
Example #9
0
        public virtual Response <TemplateSpec> Get(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("TemplateSpecContainer.Get");
            scope.Start();
            try
            {
                if (templateSpecName == null)
                {
                    throw new ArgumentNullException(nameof(templateSpecName));
                }

                var response = _restClient.Get(Id.ResourceGroupName, templateSpecName, expand, cancellationToken: cancellationToken);
                if (response.Value == null)
                {
                    throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new TemplateSpec(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #10
0
        public async virtual Task <Response <TemplateSpec> > GetIfExistsAsync(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("TemplateSpecContainer.GetIfExists");
            scope.Start();
            try
            {
                if (templateSpecName == null)
                {
                    throw new ArgumentNullException(nameof(templateSpecName));
                }

                var response = await _restClient.GetAsync(Id.ResourceGroupName, templateSpecName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                return(response.Value == null
                    ? Response.FromValue <TemplateSpec>(null, response.GetRawResponse())
                    : Response.FromValue(new TemplateSpec(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #11
0
 public static Response <TemplateSpec> GetTemplateSpec(this ResourceGroup resourceGroup, string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
 {
     return(resourceGroup.GetTemplateSpecs().Get(templateSpecName, expand, cancellationToken));
 }
Example #12
0
 public static async Task <Response <TemplateSpec> > GetTemplateSpecAsync(this ResourceGroup resourceGroup, string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
 {
     return(await resourceGroup.GetTemplateSpecs().GetAsync(templateSpecName, expand, cancellationToken).ConfigureAwait(false));
 }
Example #13
0
        public virtual async Task <Response <TemplateSpec> > GetIfExistsAsync(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(templateSpecName, nameof(templateSpecName));

            using var scope = _templateSpecClientDiagnostics.CreateScope("TemplateSpecCollection.GetIfExists");
            scope.Start();
            try
            {
                var response = await _templateSpecRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    return(Response.FromValue <TemplateSpec>(null, response.GetRawResponse()));
                }
                return(Response.FromValue(new TemplateSpec(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #14
0
        public virtual async Task <Response <bool> > ExistsAsync(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(templateSpecName, nameof(templateSpecName));

            using var scope = _templateSpecClientDiagnostics.CreateScope("TemplateSpecCollection.Exists");
            scope.Start();
            try
            {
                var response = await GetIfExistsAsync(templateSpecName, expand : expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(response.Value != null, response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #15
0
        public async virtual Task <Response <TemplateSpec> > GetAsync(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            if (templateSpecName == null)
            {
                throw new ArgumentNullException(nameof(templateSpecName));
            }

            using var scope = _clientDiagnostics.CreateScope("TemplateSpecCollection.Get");
            scope.Start();
            try
            {
                var response = await _templateSpecsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, templateSpecName, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new TemplateSpec(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #16
0
 public static Pageable <TemplateSpec> GetTemplateSpecs(this Subscription subscription, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
 {
     return(GetExtensionClient(subscription).GetTemplateSpecs(expand, cancellationToken));
 }
Example #17
0
        public async virtual Task <Response <bool> > CheckIfExistsAsync(string templateSpecName, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("TemplateSpecContainer.CheckIfExists");
            scope.Start();
            try
            {
                if (templateSpecName == null)
                {
                    throw new ArgumentNullException(nameof(templateSpecName));
                }

                var response = await GetIfExistsAsync(templateSpecName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(response.Value != null, response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 public static Pageable <TemplateSpec> GetTemplateSpecs(this Subscription subscription, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
 {
     return(subscription.UseClientContext((baseUri, credential, options, pipeline) =>
     {
         var clientDiagnostics = new ClientDiagnostics(options);
         var restOperations = GetTemplateSpecsRestOperations(clientDiagnostics, credential, options, pipeline, subscription.Id.SubscriptionId, baseUri);
         Page <TemplateSpec> FirstPageFunc(int?pageSizeHint)
         {
             using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetTemplateSpecs");
             scope.Start();
             try
             {
                 var response = restOperations.GetAllBySubscription(expand, cancellationToken: cancellationToken);
                 return Page.FromValues(response.Value.Value.Select(value => new TemplateSpec(subscription, value)), response.Value.NextLink, response.GetRawResponse());
             }
             catch (Exception e)
             {
                 scope.Failed(e);
                 throw;
             }
         }
         Page <TemplateSpec> NextPageFunc(string nextLink, int?pageSizeHint)
         {
             using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetTemplateSpecs");
             scope.Start();
             try
             {
                 var response = restOperations.GetAllBySubscriptionNextPage(nextLink, expand, cancellationToken: cancellationToken);
                 return Page.FromValues(response.Value.Value.Select(value => new TemplateSpec(subscription, value)), response.Value.NextLink, response.GetRawResponse());
             }
             catch (Exception e)
             {
                 scope.Failed(e);
                 throw;
             }
         }
         return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
     }
                                          ));
 }
Example #19
0
 public static AsyncPageable <TemplateSpecResource> GetTemplateSpecsAsync(this SubscriptionResource subscriptionResource, TemplateSpecExpandKind?expand = null, CancellationToken cancellationToken = default)
 {
     return(GetExtensionClient(subscriptionResource).GetTemplateSpecsAsync(expand, cancellationToken));
 }