/// <inheritdoc /> public Task ReportReplicaHealthAsync( PartitionId partitionId, ReplicaId replicaId, ReplicaHealthReportServiceKind?replicaHealthReportServiceKind, HealthInformation healthInformation, bool?immediate = false, long?serverTimeout = 60, CancellationToken cancellationToken = default(CancellationToken)) { partitionId.ThrowIfNull(nameof(partitionId)); replicaId.ThrowIfNull(nameof(replicaId)); replicaHealthReportServiceKind.ThrowIfNull(nameof(replicaHealthReportServiceKind)); healthInformation.ThrowIfNull(nameof(healthInformation)); serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295); var requestId = Guid.NewGuid().ToString(); var url = "Partitions/{partitionId}/$/GetReplicas/{replicaId}/$/ReportHealth"; url = url.Replace("{partitionId}", partitionId.ToString()); url = url.Replace("{replicaId}", replicaId.ToString()); var queryParams = new List <string>(); // Append to queryParams if not null. replicaHealthReportServiceKind?.AddToQueryParameters(queryParams, $"ReplicaHealthReportServiceKind={replicaHealthReportServiceKind.ToString()}"); immediate?.AddToQueryParameters(queryParams, $"Immediate={immediate}"); serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}"); queryParams.Add("api-version=6.0"); url += "?" + string.Join("&", queryParams); string content; using (var sw = new StringWriter()) { HealthInformationConverter.Serialize(new JsonTextWriter(sw), healthInformation); 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.SendAsync(RequestFunc, url, requestId, cancellationToken)); }
/// <inheritdoc /> public Task ReportDeployedServicePackageHealthAsync( NodeName nodeName, string applicationId, string servicePackageName, HealthInformation healthInformation, bool?immediate = false, long?serverTimeout = 60, CancellationToken cancellationToken = default(CancellationToken)) { nodeName.ThrowIfNull(nameof(nodeName)); applicationId.ThrowIfNull(nameof(applicationId)); servicePackageName.ThrowIfNull(nameof(servicePackageName)); healthInformation.ThrowIfNull(nameof(healthInformation)); serverTimeout?.ThrowIfOutOfInclusiveRange("serverTimeout", 1, 4294967295); var requestId = Guid.NewGuid().ToString(); var url = "Nodes/{nodeName}/$/GetApplications/{applicationId}/$/GetServicePackages/{servicePackageName}/$/ReportHealth"; url = url.Replace("{nodeName}", Uri.EscapeDataString(nodeName.ToString())); url = url.Replace("{applicationId}", applicationId); url = url.Replace("{servicePackageName}", servicePackageName); var queryParams = new List <string>(); // Append to queryParams if not null. immediate?.AddToQueryParameters(queryParams, $"Immediate={immediate}"); serverTimeout?.AddToQueryParameters(queryParams, $"timeout={serverTimeout}"); queryParams.Add("api-version=6.0"); url += "?" + string.Join("&", queryParams); string content; using (var sw = new StringWriter()) { HealthInformationConverter.Serialize(new JsonTextWriter(sw), healthInformation); 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.SendAsync(RequestFunc, url, requestId, cancellationToken)); }