/// <inheritdoc /> public Task <RepairTaskUpdateInfo> UpdateRepairTaskHealthPolicyAsync( RepairTaskUpdateHealthPolicyDescription repairTaskUpdateHealthPolicyDescription, CancellationToken cancellationToken = default(CancellationToken)) { repairTaskUpdateHealthPolicyDescription.ThrowIfNull(nameof(repairTaskUpdateHealthPolicyDescription)); var requestId = Guid.NewGuid().ToString(); var url = "$/UpdateRepairTaskHealthPolicy"; var queryParams = new List <string>(); // Append to queryParams if not null. queryParams.Add("api-version=6.0"); url += "?" + string.Join("&", queryParams); string content; using (var sw = new StringWriter()) { RepairTaskUpdateHealthPolicyDescriptionConverter.Serialize(new JsonTextWriter(sw), repairTaskUpdateHealthPolicyDescription); 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, RepairTaskUpdateInfoConverter.Deserialize, requestId, cancellationToken)); }
/// <inheritdoc/> protected override void ProcessRecordInternal() { var repairTaskUpdateHealthPolicyDescription = new RepairTaskUpdateHealthPolicyDescription( taskId: this.TaskId, version: this.Version, performPreparingHealthCheck: this.PerformPreparingHealthCheck, performRestoringHealthCheck: this.PerformRestoringHealthCheck); var result = this.ServiceFabricClient.Repairs.UpdateRepairTaskHealthPolicyAsync( repairTaskUpdateHealthPolicyDescription: repairTaskUpdateHealthPolicyDescription, cancellationToken: this.CancellationToken).GetAwaiter().GetResult(); if (result != null) { this.WriteObject(this.FormatOutput(result)); } }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="obj">The object to serialize to JSON.</param> internal static void Serialize(JsonWriter writer, RepairTaskUpdateHealthPolicyDescription obj) { // Required properties are always serialized, optional properties are serialized when not null. writer.WriteStartObject(); writer.WriteProperty(obj.TaskId, "TaskId", JsonWriterExtensions.WriteStringValue); if (obj.Version != null) { writer.WriteProperty(obj.Version, "Version", JsonWriterExtensions.WriteStringValue); } if (obj.PerformPreparingHealthCheck != null) { writer.WriteProperty(obj.PerformPreparingHealthCheck, "PerformPreparingHealthCheck", JsonWriterExtensions.WriteBoolValue); } if (obj.PerformRestoringHealthCheck != null) { writer.WriteProperty(obj.PerformRestoringHealthCheck, "PerformRestoringHealthCheck", JsonWriterExtensions.WriteBoolValue); } writer.WriteEndObject(); }