コード例 #1
0
        /// <inheritdoc />
        public Task <ApplicationTypeManifest> GetApplicationManifestAsync(
            string applicationTypeName,
            string applicationTypeVersion,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            applicationTypeName.ThrowIfNull(nameof(applicationTypeName));
            applicationTypeVersion.ThrowIfNull(nameof(applicationTypeVersion));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "ApplicationTypes/{applicationTypeName}/$/GetApplicationManifest";

            url = url.Replace("{applicationTypeName}", Uri.EscapeDataString(applicationTypeName));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            applicationTypeVersion?.AddToQueryParameters(queryParams, $"ApplicationTypeVersion={applicationTypeVersion}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, ApplicationTypeManifestConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #2
0
        /// <inheritdoc />
        public Task <BackupPolicyDescription> GetBackupPolicyByNameAsync(
            string backupPolicyName,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            backupPolicyName.ThrowIfNull(nameof(backupPolicyName));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "BackupRestore/BackupPolicies/{backupPolicyName}";

            url = url.Replace("{backupPolicyName}", Uri.EscapeDataString(backupPolicyName));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.4");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, BackupPolicyDescriptionConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #3
0
        /// <inheritdoc />
        public Task <PagedData <BackupConfigurationInfo> > GetApplicationBackupConfigurationInfoAsync(
            string applicationId,
            ContinuationToken continuationToken = default(ContinuationToken),
            long?maxResults    = 0,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            applicationId.ThrowIfNull(nameof(applicationId));
            maxResults?.ThrowIfLessThan("maxResults", 0);
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Applications/{applicationId}/$/GetBackupConfigurationInfo";

            url = url.Replace("{applicationId}", applicationId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            continuationToken?.AddToQueryParameters(queryParams, $"ContinuationToken={continuationToken.ToString()}");
            maxResults?.AddToQueryParameters(queryParams, $"MaxResults={maxResults}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.4");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsPagedData(RequestFunc, url, BackupConfigurationInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #4
0
        /// <inheritdoc />
        public Task <NodeTransitionProgress> GetNodeTransitionProgressAsync(
            NodeName nodeName,
            Guid?operationId,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nodeName.ThrowIfNull(nameof(nodeName));
            operationId.ThrowIfNull(nameof(operationId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Faults/Nodes/{nodeName}/$/GetTransitionProgress";

            url = url.Replace("{nodeName}", Uri.EscapeDataString(nodeName.ToString()));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            operationId?.AddToQueryParameters(queryParams, $"OperationId={operationId.ToString()}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, NodeTransitionProgressConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #5
0
        /// <inheritdoc />
        public Task CancelOperationAsync(
            Guid?operationId,
            bool?force,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            operationId.ThrowIfNull(nameof(operationId));
            force.ThrowIfNull(nameof(force));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "Faults/$/Cancel";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            operationId?.AddToQueryParameters(queryParams, $"OperationId={operationId.ToString()}");
            force?.AddToQueryParameters(queryParams, $"Force={force}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #6
0
        /// <inheritdoc />
        public Task RemoveNodeStateAsync(
            NodeName nodeName,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nodeName.ThrowIfNull(nameof(nodeName));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Nodes/{nodeName}/$/RemoveNodeState";

            url = url.Replace("{nodeName}", Uri.EscapeDataString(nodeName.ToString()));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #7
0
        /// <inheritdoc />
        public Task <PagedData <ChaosEventWrapper> > GetChaosEventsAsync(
            ContinuationToken continuationToken = default(ContinuationToken),
            string startTimeUtc = default(string),
            string endTimeUtc   = default(string),
            long?maxResults     = 0,
            long?serverTimeout  = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            maxResults?.ThrowIfLessThan("maxResults", 0);
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "Tools/Chaos/Events";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            continuationToken?.AddToQueryParameters(queryParams, $"ContinuationToken={continuationToken.ToString()}");
            startTimeUtc?.AddToQueryParameters(queryParams, $"StartTimeUtc={startTimeUtc}");
            endTimeUtc?.AddToQueryParameters(queryParams, $"EndTimeUtc={endTimeUtc}");
            maxResults?.AddToQueryParameters(queryParams, $"MaxResults={maxResults}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.2");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsPagedData(RequestFunc, url, ChaosEventWrapperConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #8
0
        /// <inheritdoc />
        public Task MovePrimaryReplicaAsync(
            PartitionId partitionId,
            NodeName nodeName      = default(NodeName),
            bool?ignoreConstraints = false,
            long?serverTimeout     = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            partitionId.ThrowIfNull(nameof(partitionId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Partitions/{partitionId}/$/MovePrimaryReplica";

            url = url.Replace("{partitionId}", partitionId.ToString());
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            nodeName?.AddToQueryParameters(queryParams, $"NodeName={nodeName.ToString()}");
            ignoreConstraints?.AddToQueryParameters(queryParams, $"IgnoreConstraints={ignoreConstraints}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.5");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #9
0
        /// <inheritdoc />
        public Task RecoverSystemPartitionsAsync(
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "$/RecoverSystemPartitions";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #10
0
        /// <inheritdoc />
        public Task <IEnumerable <FabricConfigVersionInfo> > GetProvisionedFabricConfigVersionInfoListAsync(
            string configVersion = default(string),
            long?serverTimeout   = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "$/GetProvisionedConfigVersions";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            configVersion?.AddToQueryParameters(queryParams, $"ConfigVersion={configVersion}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsList(RequestFunc, url, FabricConfigVersionInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #11
0
        /// <inheritdoc />
        public Task <ClusterConfiguration> GetClusterConfigurationAsync(
            string configurationApiVersion,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            configurationApiVersion.ThrowIfNull(nameof(configurationApiVersion));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "$/GetClusterConfiguration";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            configurationApiVersion?.AddToQueryParameters(queryParams, $"ConfigurationApiVersion={configurationApiVersion}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, ClusterConfigurationConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #12
0
        /// <inheritdoc />
        public Task ResumePartitionBackupAsync(
            PartitionId partitionId,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            partitionId.ThrowIfNull(nameof(partitionId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Partitions/{partitionId}/$/ResumeBackup";

            url = url.Replace("{partitionId}", partitionId.ToString());
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.2-preview");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #13
0
        /// <inheritdoc />
        public Task ToggleVerboseServicePlacementHealthReportingAsync(
            bool?enabled,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            enabled.ThrowIfNull(nameof(enabled));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "$/ToggleVerboseServicePlacementHealthReporting";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            enabled?.AddToQueryParameters(queryParams, $"Enabled={enabled}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.4");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #14
0
        /// <inheritdoc />
        public Task <IEnumerable <ConfigParameterOverride> > GetConfigurationOverridesAsync(
            NodeName nodeName,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nodeName.ThrowIfNull(nameof(nodeName));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Nodes/{nodeName}/$/GetConfigurationOverrides";

            url = url.Replace("{nodeName}", Uri.EscapeDataString(nodeName.ToString()));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=7.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsList(RequestFunc, url, ConfigParameterOverrideConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #15
0
        /// <inheritdoc />
        public Task <DeployedApplicationInfo> GetDeployedApplicationInfoAsync(
            NodeName nodeName,
            string applicationId,
            long?serverTimeout                  = 60,
            bool?includeHealthState             = false,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nodeName.ThrowIfNull(nameof(nodeName));
            applicationId.ThrowIfNull(nameof(applicationId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Nodes/{nodeName}/$/GetApplications/{applicationId}";

            url = url.Replace("{nodeName}", Uri.EscapeDataString(nodeName.ToString()));
            url = url.Replace("{applicationId}", applicationId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            includeHealthState?.AddToQueryParameters(queryParams, $"IncludeHealthState={includeHealthState}");
            queryParams.Add("api-version=6.1");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, DeployedApplicationInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #16
0
        /// <inheritdoc />
        public Task <PagedData <PropertyInfo> > GetPropertyInfoListAsync(
            string nameId,
            bool?includeValues = false,
            ContinuationToken continuationToken = default(ContinuationToken),
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nameId.ThrowIfNull(nameof(nameId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Names/{nameId}/$/GetProperties";

            url = url.Replace("{nameId}", nameId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            includeValues?.AddToQueryParameters(queryParams, $"IncludeValues={includeValues}");
            continuationToken?.AddToQueryParameters(queryParams, $"ContinuationToken={continuationToken.ToString()}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsPagedData(RequestFunc, url, PropertyInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #17
0
        /// <inheritdoc />
        public Task DeleteApplicationAsync(
            string applicationId,
            bool?forceRemove   = default(bool?),
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            applicationId.ThrowIfNull(nameof(applicationId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Applications/{applicationId}/$/Delete";

            url = url.Replace("{applicationId}", applicationId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            forceRemove?.AddToQueryParameters(queryParams, $"ForceRemove={forceRemove}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Post,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #18
0
        /// <inheritdoc />
        public Task GetNameExistsInfoAsync(
            string nameId,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nameId.ThrowIfNull(nameof(nameId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Names/{nameId}";

            url = url.Replace("{nameId}", nameId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #19
0
        /// <inheritdoc />
        public Task <PagedData <NodeInfo> > GetNodeInfoListAsync(
            ContinuationToken continuationToken = default(ContinuationToken),
            NodeStatusFilter?nodeStatusFilter   = NodeStatusFilter.Default,
            long?maxResults    = 0,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            maxResults?.ThrowIfLessThan("maxResults", 0);
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "Nodes";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            continuationToken?.AddToQueryParameters(queryParams, $"ContinuationToken={continuationToken.ToString()}");
            nodeStatusFilter?.AddToQueryParameters(queryParams, $"NodeStatusFilter={nodeStatusFilter.ToString()}");
            maxResults?.AddToQueryParameters(queryParams, $"MaxResults={maxResults}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.3");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsPagedData(RequestFunc, url, NodeInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #20
0
        /// <inheritdoc />
        public Task <UnplacedReplicaInformation> GetUnplacedReplicaInformationAsync(
            string serviceId,
            PartitionId partitionId             = default(PartitionId),
            bool?onlyQueryPrimaries             = false,
            long?serverTimeout                  = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            serviceId.ThrowIfNull(nameof(serviceId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Services/{serviceId}/$/GetUnplacedReplicaInformation";

            url = url.Replace("{serviceId}", serviceId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            partitionId?.AddToQueryParameters(queryParams, $"PartitionId={partitionId.ToString()}");
            onlyQueryPrimaries?.AddToQueryParameters(queryParams, $"OnlyQueryPrimaries={onlyQueryPrimaries}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.4");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, UnplacedReplicaInformationConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #21
0
        /// <inheritdoc />
        public Task <Chaos> GetChaosAsync(
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "Tools/Chaos";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.2");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, ChaosConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #22
0
        /// <inheritdoc />
        public Task <string> InvokeInfrastructureQueryAsync(
            string command,
            string serviceId   = default(string),
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            command.ThrowIfNull(nameof(command));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "$/InvokeInfrastructureQuery";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            command?.AddToQueryParameters(queryParams, $"Command={command}");
            serviceId?.AddToQueryParameters(queryParams, $"ServiceId={serviceId}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsRawJson(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #23
0
        /// <inheritdoc />
        public Task <IEnumerable <OperationStatus> > GetFaultOperationListAsync(
            int?typeFilter,
            int?stateFilter,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            typeFilter.ThrowIfNull(nameof(typeFilter));
            stateFilter.ThrowIfNull(nameof(stateFilter));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "Faults/";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            typeFilter?.AddToQueryParameters(queryParams, $"TypeFilter={typeFilter}");
            stateFilter?.AddToQueryParameters(queryParams, $"StateFilter={stateFilter}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsList(RequestFunc, url, OperationStatusConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #24
0
        /// <inheritdoc />
        public Task <UploadSession> GetImageStoreUploadSessionByIdAsync(
            Guid?sessionId,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            sessionId.ThrowIfNull(nameof(sessionId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId   = Guid.NewGuid().ToString();
            var url         = "ImageStore/$/GetUploadSession";
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            sessionId?.AddToQueryParameters(queryParams, $"session-id={sessionId.ToString()}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, UploadSessionConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #25
0
        /// <inheritdoc />
        public Task <RestoreProgressInfo> GetPartitionRestoreProgressAsync(
            PartitionId partitionId,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            partitionId.ThrowIfNull(nameof(partitionId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Partitions/{partitionId}/$/GetRestoreProgress";

            url = url.Replace("{partitionId}", partitionId.ToString());
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.4");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, RestoreProgressInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #26
0
        /// <inheritdoc />
        public Task DeleteImageStoreContentAsync(
            string contentPath,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            contentPath.ThrowIfNull(nameof(contentPath));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "ImageStore/{contentPath}";

            url = url.Replace("{contentPath}", Uri.EscapeDataString(contentPath));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Delete,
                };

                return(request);
            }

            return(this.httpClient.SendAsync(RequestFunc, url, requestId, cancellationToken));
        }
コード例 #27
0
        /// <inheritdoc />
        public Task <PagedData <BackupEntity> > GetAllEntitiesBackedUpByPolicyAsync(
            string backupPolicyName,
            ContinuationToken continuationToken = default(ContinuationToken),
            long?maxResults    = 0,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            backupPolicyName.ThrowIfNull(nameof(backupPolicyName));
            maxResults?.ThrowIfLessThan("maxResults", 0);
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "BackupRestore/BackupPolicies/{backupPolicyName}/$/GetBackupEnabledEntities";

            url = url.Replace("{backupPolicyName}", Uri.EscapeDataString(backupPolicyName));
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            continuationToken?.AddToQueryParameters(queryParams, $"ContinuationToken={continuationToken.ToString()}");
            maxResults?.AddToQueryParameters(queryParams, $"MaxResults={maxResults}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.4");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponseAsPagedData(RequestFunc, url, BackupEntityConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #28
0
        /// <inheritdoc />
        public Task <ApplicationInfo> GetApplicationInfoAsync(
            string applicationId,
            bool?excludeApplicationParameters = false,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            applicationId.ThrowIfNull(nameof(applicationId));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Applications/{applicationId}";

            url = url.Replace("{applicationId}", applicationId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            excludeApplicationParameters?.AddToQueryParameters(queryParams, $"ExcludeApplicationParameters={excludeApplicationParameters}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, ApplicationInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #29
0
        /// <inheritdoc />
        public Task <ComposeDeploymentStatusInfo> GetComposeDeploymentStatusAsync(
            string deploymentName,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            deploymentName.ThrowIfNull(nameof(deploymentName));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "ComposeDeployments/{deploymentName}";

            url = url.Replace("{deploymentName}", deploymentName);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.0-preview");
            url += "?" + string.Join("&", queryParams);

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method = HttpMethod.Get,
                };

                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, ComposeDeploymentStatusInfoConverter.Deserialize, requestId, cancellationToken));
        }
コード例 #30
0
        /// <inheritdoc />
        public Task <ContainerApiResponse> InvokeContainerApiAsync(
            NodeName nodeName,
            string applicationId,
            string serviceManifestName,
            string codePackageName,
            string codePackageInstanceId,
            ContainerApiRequestBody containerApiRequestBody,
            long?serverTimeout = 60,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            nodeName.ThrowIfNull(nameof(nodeName));
            applicationId.ThrowIfNull(nameof(applicationId));
            serviceManifestName.ThrowIfNull(nameof(serviceManifestName));
            codePackageName.ThrowIfNull(nameof(codePackageName));
            codePackageInstanceId.ThrowIfNull(nameof(codePackageInstanceId));
            containerApiRequestBody.ThrowIfNull(nameof(containerApiRequestBody));
            serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295);
            var requestId = Guid.NewGuid().ToString();
            var url       = "Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetCodePackages/$/ContainerApi";

            url = url.Replace("{nodeName}", Uri.EscapeDataString(nodeName.ToString()));
            url = url.Replace("{applicationId}", applicationId);
            var queryParams = new List <string>();

            // Append to queryParams if not null.
            serviceManifestName?.AddToQueryParameters(queryParams, $"ServiceManifestName={serviceManifestName}");
            codePackageName?.AddToQueryParameters(queryParams, $"CodePackageName={codePackageName}");
            codePackageInstanceId?.AddToQueryParameters(queryParams, $"CodePackageInstanceId={codePackageInstanceId}");
            serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}");
            queryParams.Add("api-version=6.2");
            url += "?" + string.Join("&", queryParams);

            string content;

            using (var sw = new StringWriter())
            {
                ContainerApiRequestBodyConverter.Serialize(new JsonTextWriter(sw), containerApiRequestBody);
                content = sw.ToString();
            }

            HttpRequestMessage RequestFunc()
            {
                var request = new HttpRequestMessage()
                {
                    Method  = HttpMethod.Post,
                    Content = new StringContent(content, Encoding.UTF8),
                };

                request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
                return(request);
            }

            return(this.httpClient.SendAsyncGetResponse(RequestFunc, url, ContainerApiResponseConverter.Deserialize, requestId, cancellationToken));
        }