Exemple #1
0
        public virtual AsyncPageable <string> GetWebAppsByHybridConnectionAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <string> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _serverfarmHybridConnectionNamespaceRelayAppServicePlansClientDiagnostics.CreateScope("ServerfarmHybridConnectionNamespaceRelayResource.GetWebAppsByHybridConnection");
                scope.Start();
                try
                {
                    var response = await _serverfarmHybridConnectionNamespaceRelayAppServicePlansRestClient.ListWebAppsByHybridConnectionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <string> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _serverfarmHybridConnectionNamespaceRelayAppServicePlansClientDiagnostics.CreateScope("ServerfarmHybridConnectionNamespaceRelayResource.GetWebAppsByHybridConnection");
                scope.Start();
                try
                {
                    var response = await _serverfarmHybridConnectionNamespaceRelayAppServicePlansRestClient.ListWebAppsByHybridConnectionNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #2
0
        public virtual AsyncPageable <FrontDoorSecurityPolicyResource> GetAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <FrontDoorSecurityPolicyResource> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _frontDoorSecurityPolicyClientDiagnostics.CreateScope("FrontDoorSecurityPolicyCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _frontDoorSecurityPolicyRestClient.ListByProfileAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <FrontDoorSecurityPolicyResource> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _frontDoorSecurityPolicyClientDiagnostics.CreateScope("FrontDoorSecurityPolicyCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _frontDoorSecurityPolicyRestClient.ListByProfileNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <SiteSlotContinuousWebJob> GetAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <SiteSlotContinuousWebJob> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _siteSlotContinuousWebJobWebAppsClientDiagnostics.CreateScope("SiteSlotContinuousWebJobCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _siteSlotContinuousWebJobWebAppsRestClient.ListContinuousWebJobsSlotAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <SiteSlotContinuousWebJob> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _siteSlotContinuousWebJobWebAppsClientDiagnostics.CreateScope("SiteSlotContinuousWebJobCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _siteSlotContinuousWebJobWebAppsRestClient.ListContinuousWebJobsSlotNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <LoadBalancer> ListAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <LoadBalancer> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("LoadBalancersClient.ListAll");
                scope.Start();
                try
                {
                    var response = await RestClient.ListAllAsync(cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <LoadBalancer> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("LoadBalancersClient.ListAll");
                scope.Start();
                try
                {
                    var response = await RestClient.ListAllNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <PurchasedPhoneNumber> ListPhoneNumbersAsync(int?skip = null, int?top = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <PurchasedPhoneNumber> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("InternalPhoneNumbersClient.ListPhoneNumbers");
                scope.Start();
                try
                {
                    var response = await RestClient.ListPhoneNumbersAsync(skip, top, cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.PhoneNumbers, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <PurchasedPhoneNumber> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("InternalPhoneNumbersClient.ListPhoneNumbers");
                scope.Start();
                try
                {
                    var response = await RestClient.ListPhoneNumbersNextPageAsync(nextLink, skip, top, cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.PhoneNumbers, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <ResourceLink> ListAtSubscriptionAsync(string filter = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <ResourceLink> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription");
                scope.Start();
                try
                {
                    var response = await RestClient.ListAtSubscriptionAsync(filter, cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <ResourceLink> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription");
                scope.Start();
                try
                {
                    var response = await RestClient.ListAtSubscriptionNextPageAsync(nextLink, filter, cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #7
0
        public virtual AsyncPageable <SourceControl> GetAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <SourceControl> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _sourceControlClientDiagnostics.CreateScope("SourceControlCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _sourceControlRestClient.ListSourceControlsAsync(cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <SourceControl> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _sourceControlClientDiagnostics.CreateScope("SourceControlCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _sourceControlRestClient.ListSourceControlsNextPageAsync(nextLink, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #8
0
        public virtual AsyncPageable <VirtualMachineVirtualMachineRunCommand> GetAllAsync(string expand = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <VirtualMachineVirtualMachineRunCommand> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("VirtualMachineVirtualMachineRunCommandCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _restClient.GetAllByVirtualMachineAsync(Id.ResourceGroupName, Id.Name, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

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

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

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <VirtualNetworkUsage> GetUsageAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <VirtualNetworkUsage> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("VirtualNetwork.GetUsage");
                scope.Start();
                try
                {
                    var response = await _restClient.GetUsageAsync(Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            async Task <Page <VirtualNetworkUsage> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("VirtualNetwork.GetUsage");
                scope.Start();
                try
                {
                    var response = await _restClient.GetUsageNextPageAsync(nextLink, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <StaticSiteUserProvidedFunctionApp> GetAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <StaticSiteUserProvidedFunctionApp> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _staticSiteUserProvidedFunctionAppStaticSitesClientDiagnostics.CreateScope("StaticSiteUserProvidedFunctionAppCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _staticSiteUserProvidedFunctionAppStaticSitesRestClient.GetUserProvidedFunctionAppsForStaticSiteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <StaticSiteUserProvidedFunctionApp> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _staticSiteUserProvidedFunctionAppStaticSitesClientDiagnostics.CreateScope("StaticSiteUserProvidedFunctionAppCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _staticSiteUserProvidedFunctionAppStaticSitesRestClient.GetUserProvidedFunctionAppsForStaticSiteNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #11
0
        public virtual AsyncPageable <ConfigurationStore> GetConfigurationStoresAsync(string skipToken = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <ConfigurationStore> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = ConfigurationStoreClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetConfigurationStores");
                scope.Start();
                try
                {
                    var response = await ConfigurationStoreRestClient.ListAsync(Id.SubscriptionId, skipToken, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <ConfigurationStore> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = ConfigurationStoreClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetConfigurationStores");
                scope.Start();
                try
                {
                    var response = await ConfigurationStoreRestClient.ListNextPageAsync(nextLink, Id.SubscriptionId, skipToken, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <EventHub> GetAllAsync(int?skip = null, int?top = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <EventHub> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("EventHubCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _eventHubsRestClient.ListByNamespaceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skip, top, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <EventHub> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("EventHubCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _eventHubsRestClient.ListByNamespaceNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skip, top, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #13
0
        public virtual AsyncPageable <SqlServer> GetAllAsync(string expand = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <SqlServer> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _sqlServerServersClientDiagnostics.CreateScope("SqlServerCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _sqlServerServersRestClient.ListByResourceGroupAsync(Id.SubscriptionId, Id.ResourceGroupName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <SqlServer> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _sqlServerServersClientDiagnostics.CreateScope("SqlServerCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _sqlServerServersRestClient.ListByResourceGroupNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <VirtualMachineScaleSetVmResource> GetAllAsync(string filter = null, string select = null, string expand = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <VirtualMachineScaleSetVmResource> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _virtualMachineScaleSetVmVirtualMachineScaleSetVMsClientDiagnostics.CreateScope("VirtualMachineScaleSetVmCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _virtualMachineScaleSetVmVirtualMachineScaleSetVMsRestClient.ListAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, select, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <VirtualMachineScaleSetVmResource> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _virtualMachineScaleSetVmVirtualMachineScaleSetVMsClientDiagnostics.CreateScope("VirtualMachineScaleSetVmCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _virtualMachineScaleSetVmVirtualMachineScaleSetVMsRestClient.ListNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, select, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #15
0
        public virtual AsyncPageable <ServerJobAgentJobExecutionStepTarget> GetJobTargetExecutionsAsync(Guid jobExecutionId, DateTimeOffset?createTimeMin = null, DateTimeOffset?createTimeMax = null, DateTimeOffset?endTimeMin = null, DateTimeOffset?endTimeMax = null, bool?isActive = null, int?skip = null, int?top = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <ServerJobAgentJobExecutionStepTarget> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _serverJobAgentJobExecutionStepTargetJobTargetExecutionsClientDiagnostics.CreateScope("ServerJobAgentJobExecutionCollection.GetJobTargetExecutions");
                scope.Start();
                try
                {
                    var response = await _serverJobAgentJobExecutionStepTargetJobTargetExecutionsRestClient.ListByJobExecutionAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, jobExecutionId, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            async Task <Page <ServerJobAgentJobExecutionStepTarget> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _serverJobAgentJobExecutionStepTargetJobTargetExecutionsClientDiagnostics.CreateScope("ServerJobAgentJobExecutionCollection.GetJobTargetExecutions");
                scope.Start();
                try
                {
                    var response = await _serverJobAgentJobExecutionStepTargetJobTargetExecutionsRestClient.ListByJobExecutionNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, jobExecutionId, createTimeMin, createTimeMax, endTimeMin, endTimeMax, isActive, skip, top, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #16
0
        public virtual AsyncPageable <JobPreparationAndReleaseTaskExecutionInformation> ListPreparationAndReleaseTaskStatusAsync(string jobId, JobListPreparationAndReleaseTaskStatusOptions jobListPreparationAndReleaseTaskStatusOptions, CancellationToken cancellationToken = default)
        {
            if (jobId == null)
            {
                throw new ArgumentNullException(nameof(jobId));
            }

            async Task <Page <JobPreparationAndReleaseTaskExecutionInformation> > FirstPageFunc(int?pageSizeHint)
            {
                var response = await RestClient.ListPreparationAndReleaseTaskStatusAsync(jobId, jobListPreparationAndReleaseTaskStatusOptions, cancellationToken).ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.OdataNextLink, response.GetRawResponse()));
            }

            async Task <Page <JobPreparationAndReleaseTaskExecutionInformation> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                var response = await RestClient.ListPreparationAndReleaseTaskStatusNextPageAsync(nextLink, jobId, jobListPreparationAndReleaseTaskStatusOptions, cancellationToken).ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.OdataNextLink, response.GetRawResponse()));
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #17
0
        public virtual AsyncPageable <TestResource> GetAllAsync(int pages = 1, CancellationToken cancellation = default)
        {
            async Task <Page <TestResource> > pageFunc(int?pageSizeHint)
            {
                using var scope = _diagnostic.CreateScope("TestResourceContainer.GetAll");
                scope.Start();

                try
                {
                    await Task.Delay(10);

                    var result = new object[] { new object(), new object() };
                    return(Page.FromValues(result.Select(o => new TestResource()), null, new MockResponse(200)));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(pageFunc, null));
        }
Exemple #18
0
        public virtual AsyncPageable <VirtualMachineExtensionImage> GetAllAsync(string type, string filter = null, int?top = null, string orderby = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(type, nameof(type));

            async Task <Page <VirtualMachineExtensionImage> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _virtualMachineExtensionImageClientDiagnostics.CreateScope("VirtualMachineExtensionImageCollection.GetAll");
                scope.Start();
                try
                {
                    var response = await _virtualMachineExtensionImageRestClient.ListVersionsAsync(Id.SubscriptionId, _location, _publisherName, type, filter, top, orderby, cancellationToken : cancellationToken).ConfigureAwait(false);

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

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null));
        }
Exemple #19
0
        public virtual AsyncPageable <CloudJob> ListFromJobScheduleAsync(string jobScheduleId, JobListFromJobScheduleOptions jobListFromJobScheduleOptions, CancellationToken cancellationToken = default)
        {
            if (jobScheduleId == null)
            {
                throw new ArgumentNullException(nameof(jobScheduleId));
            }

            async Task <Page <CloudJob> > FirstPageFunc(int?pageSizeHint)
            {
                var response = await RestClient.ListFromJobScheduleAsync(jobScheduleId, jobListFromJobScheduleOptions, cancellationToken).ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.OdataNextLink, response.GetRawResponse()));
            }

            async Task <Page <CloudJob> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                var response = await RestClient.ListFromJobScheduleNextPageAsync(nextLink, jobScheduleId, jobListFromJobScheduleOptions, cancellationToken).ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.OdataNextLink, response.GetRawResponse()));
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
        public virtual AsyncPageable <RestApi> GetAllAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <RestApi> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("RestApiCollection.GetAll");
                scope.Start();
                try
                {
                    var restClient = await GetRestClientAsync().ConfigureAwait(false);

                    var response = await restClient.ListAsync(cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, null, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null));
        }
        private AsyncPageable <AnalyzeHealthcareEntitiesResultCollection> CreateOperationValueAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <AnalyzeHealthcareEntitiesResultCollection> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                //diagnostics scope?
                try
                {
                    Response <HealthcareJobState> jobState = await _serviceClient.HealthStatusNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false);

                    AnalyzeHealthcareEntitiesResultCollection result = Transforms.ConvertToAnalyzeHealthcareEntitiesResultCollection(jobState.Value.Results, _idToIndexMap);
                    return(Page.FromValues(new List <AnalyzeHealthcareEntitiesResultCollection>()
                    {
                        result
                    }, jobState.Value.NextLink, jobState.GetRawResponse()));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(_firstPage), NextPageFunc));
        }
        public virtual AsyncPageable <Usage> GetUsagesByLocationAsync(string location, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(location, nameof(location));

            async Task <Page <Usage> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = UsagesClientDiagnostics.CreateScope("SubscriptionExtensionClient.GetUsagesByLocation");
                scope.Start();
                try
                {
                    var response = await UsagesRestClient.ListByLocationAsync(Id.SubscriptionId, location, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, null, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null));
        }
Exemple #23
0
        public virtual AsyncPageable <MetricAlertStatus> GetMetricAlertsStatusesByNameAsync(string statusName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(statusName, nameof(statusName));

            async Task <Page <MetricAlertStatus> > FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _metricAlertsStatusClientDiagnostics.CreateScope("MetricAlertResource.GetMetricAlertsStatusesByName");
                scope.Start();
                try
                {
                    var response = await _metricAlertsStatusRestClient.ListByNameAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, statusName, cancellationToken : cancellationToken).ConfigureAwait(false);

                    return(Page.FromValues(response.Value.Value, null, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null));
        }
Exemple #24
0
        public virtual AsyncPageable <ComputeNode> ListAsync(string poolId, ComputeNodeListOptions computeNodeListOptions, CancellationToken cancellationToken = default)
        {
            if (poolId == null)
            {
                throw new ArgumentNullException(nameof(poolId));
            }

            async Task <Page <ComputeNode> > FirstPageFunc(int?pageSizeHint)
            {
                var response = await RestClient.ListAsync(poolId, computeNodeListOptions, cancellationToken).ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.OdataNextLink, response.GetRawResponse()));
            }

            async Task <Page <ComputeNode> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                var response = await RestClient.ListNextPageAsync(nextLink, poolId, computeNodeListOptions, cancellationToken).ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.OdataNextLink, response.GetRawResponse()));
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc));
        }
Exemple #25
0
        /// <summary>
        /// Periodically calls the server till the long-running operation completes.
        /// </summary>
        /// <param name="pollingInterval">
        /// The interval between status requests to the server.
        /// The interval can change based on information returned from the server.
        /// For example, the server might communicate to the client that there is not reason to poll for status change sooner than some time.
        /// </param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> used for the periodical service calls.</param>
        /// <returns>The last HTTP response received from the server.</returns>
        /// <remarks>
        /// This method will periodically call UpdateStatusAsync till HasCompleted is true.
        /// An API call is then made to retrieve the status of the documents.
        /// </remarks>
        public async override ValueTask <Response <AsyncPageable <DocumentStatusResult> > > WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default)
        {
            while (true)
            {
                await UpdateStatusAsync(cancellationToken).ConfigureAwait(false);

                if (!HasCompleted)
                {
                    pollingInterval = _retryAfterHeaderValue.HasValue ? TimeSpan.FromSeconds(_retryAfterHeaderValue.Value) : pollingInterval;
                    await Task.Delay(pollingInterval, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    var response = await _serviceClient.GetDocumentsStatusAsync(new Guid(Id), cancellationToken : cancellationToken).ConfigureAwait(false);

                    _firstPage = Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
                    _hasValue  = true;
                    async Task <Page <DocumentStatusResult> > NextPageFunc(string nextLink, int?pageSizeHint)
                    {
                        // TODO: diagnostics scope?
                        try
                        {
                            var response = await _serviceClient.GetDocumentsStatusNextPageAsync(nextLink, new Guid(Id), cancellationToken : cancellationToken).ConfigureAwait(false);

                            return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }

                    var result = PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(_firstPage), NextPageFunc);
                    return(Response.FromValue(result, response));
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// List a set of device twins.
        /// </summary>
        /// <param name="pageSize">The size of each page to be retrieved from the service. Service may override this size.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A pageable set of device twins <see cref="AsyncPageable{T}"/>.</returns>
        public virtual AsyncPageable <TwinData> GetTwinsAsync(int?pageSize = null, CancellationToken cancellationToken = default)
        {
            async Task <Page <TwinData> > FirstPageFunc(int?pageSizeHint)
            {
                var querySpecification = new QuerySpecification
                {
                    Query = HubDeviceQuery
                };
                Response <IReadOnlyList <TwinData> > response = await _queryRestClient.GetTwinsAsync(
                    querySpecification,
                    null,
                    pageSizeHint?.ToString(CultureInfo.InvariantCulture),
                    cancellationToken).ConfigureAwait(false);

                response.GetRawResponse().Headers.TryGetValue(ContinuationTokenHeader, out string continuationToken);

                return(Page.FromValues(response.Value, continuationToken, response.GetRawResponse()));
            }

            async Task <Page <TwinData> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                var querySpecification = new QuerySpecification()
                {
                    Query = HubDeviceQuery
                };
                Response <IReadOnlyList <TwinData> > response = await _queryRestClient.GetTwinsAsync(
                    querySpecification,
                    nextLink,
                    pageSizeHint?.ToString(CultureInfo.InvariantCulture),
                    cancellationToken).ConfigureAwait(false);

                response.GetRawResponse().Headers.TryGetValue(ContinuationTokenHeader, out string continuationToken);
                return(Page.FromValues(response.Value, continuationToken, response.GetRawResponse()));
            }

            return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc, pageSize));
        }
 /// <summary>
 /// Gets a list of tables from the storage account.
 /// </summary>
 /// <param name="filter">Returns only tables that satisfy the specified filter.</param>
 /// <param name="maxPerPage">
 /// The maximum number of tables that will be returned per page.
 /// Note: This value does not limit the total number of results if the result is fully enumerated.
 /// </param>
 /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
 /// <returns>An <see cref="AsyncPageable{T}"/> containing a collection of <see cref="TableItem"/>s.</returns>
 public virtual AsyncPageable <TableItem> GetTablesAsync(string filter = null, int?maxPerPage = null, CancellationToken cancellationToken = default)
 {
     using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}");
     scope.Start();
     try
     {
         return(PageableHelpers.CreateAsyncEnumerable(
                    async pageSizeHint =>
         {
             var response = await _tableOperations.QueryAsync(
                 null,
                 new QueryOptions()
             {
                 Filter = filter, Select = null, Top = pageSizeHint, Format = _format
             },
                 cancellationToken).ConfigureAwait(false);
             return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse());
         },
                    async(nextLink, pageSizeHint) =>
         {
             var response = await _tableOperations.QueryAsync(
                 nextTableName: nextLink,
                 new QueryOptions()
             {
                 Filter = filter, Select = null, Top = pageSizeHint, Format = _format
             },
                 cancellationToken).ConfigureAwait(false);
             return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse());
         },
                    maxPerPage));
     }
     catch (Exception ex)
     {
         scope.Failed(ex);
         throw;
     }
 }
        /// <summary>
        /// Periodically calls the server till the long-running operation completes.
        /// </summary>
        /// <param name="pollingInterval">
        /// The interval between status requests to the server.
        /// The interval can change based on information returned from the server.
        /// For example, the server might communicate to the client that there is not reason to poll for status change sooner than some time.
        /// </param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> used for the periodical service calls.</param>
        /// <returns>The last HTTP response received from the server.</returns>
        /// <remarks>
        /// This method will periodically call UpdateStatusAsync till HasCompleted is true.
        /// An API call is then made to retrieve the status of the documents.
        /// </remarks>
        public async override ValueTask <Response <AsyncPageable <DocumentStatusResult> > > WaitForCompletionAsync(
            TimeSpan pollingInterval,
            CancellationToken cancellationToken = default)
        {
            await this.DefaultWaitForCompletionAsync(pollingInterval, cancellationToken).ConfigureAwait(false);

            var response = await _serviceClient.GetDocumentsStatusAsync(new Guid(Id), cancellationToken : cancellationToken).ConfigureAwait(false);

            _firstPage = Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
            _hasValue  = true;

            async Task <Page <DocumentStatusResult> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                // TODO: diagnostics scope?
                var response = await _serviceClient.GetDocumentsStatusNextPageAsync(nextLink, new Guid(Id), cancellationToken : cancellationToken)
                               .ConfigureAwait(false);

                return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()));
            }

            var result = PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(_firstPage), NextPageFunc);

            return(Response.FromValue(result, response));
        }
        public virtual AsyncPageable<MetricDefinition> ListMetricDefinitionsAsync(string resourceGroupName, string accountName, string databaseRid, string collectionRid, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (accountName == null)
            {
                throw new ArgumentNullException(nameof(accountName));
            }
            if (databaseRid == null)
            {
                throw new ArgumentNullException(nameof(databaseRid));
            }
            if (collectionRid == null)
            {
                throw new ArgumentNullException(nameof(collectionRid));
            }

            async Task<Page<MetricDefinition>> FirstPageFunc(int? pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("CollectionOperations.ListMetricDefinitions");
                scope.Start();
                try
                {
                    var response = await RestClient.ListMetricDefinitionsAsync(resourceGroupName, accountName, databaseRid, collectionRid, cancellationToken).ConfigureAwait(false);
                    return Page.FromValues(response.Value.Value, null, response.GetRawResponse());
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }
            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null);
        }
 /// <summary>
 /// Gets a list of tables from the storage account.
 /// </summary>
 /// <param name="select">Returns the desired properties of an entity from the set. </param>
 /// <param name="filter">Returns only tables or entities that satisfy the specified filter.</param>
 /// <param name="top">Returns only the top n tables or entities from the set.</param>
 /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
 /// <returns></returns>
 public virtual AsyncPageable <TableItem> GetTablesAsync(string select = null, string filter = null, int?top = null, CancellationToken cancellationToken = default)
 {
     return(PageableHelpers.CreateAsyncEnumerable(async _ =>
     {
         var response = await _tableOperations.RestClient.QueryAsync(
             null,
             new QueryOptions()
         {
             Filter = filter, Select = select, Top = top, Format = _format
         },
             cancellationToken).ConfigureAwait(false);
         return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse());
     }, async(nextLink, _) =>
     {
         var response = await _tableOperations.RestClient.QueryAsync(
             null,
             new QueryOptions()
         {
             Filter = filter, Select = select, Top = top, Format = _format, NextTableName = nextLink
         },
             cancellationToken).ConfigureAwait(false);
         return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse());
     }));
 }