/// <inheritdoc /> public Task <RepairTaskUpdateInfo> ForceApproveRepairTaskAsync( RepairTaskApproveDescription repairTaskApproveDescription, CancellationToken cancellationToken = default(CancellationToken)) { repairTaskApproveDescription.ThrowIfNull(nameof(repairTaskApproveDescription)); var requestId = Guid.NewGuid().ToString(); var url = "$/ForceApproveRepairTask"; 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()) { RepairTaskApproveDescriptionConverter.Serialize(new JsonTextWriter(sw), repairTaskApproveDescription); 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)); }
/// <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, RepairTaskApproveDescription 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); } writer.WriteEndObject(); }
/// <inheritdoc/> protected override void ProcessRecordInternal() { var repairTaskApproveDescription = new RepairTaskApproveDescription( taskId: this.TaskId, version: this.Version); var result = this.ServiceFabricClient.Repairs.ForceApproveRepairTaskAsync( repairTaskApproveDescription: repairTaskApproveDescription, cancellationToken: this.CancellationToken).GetAwaiter().GetResult(); if (result != null) { this.WriteObject(this.FormatOutput(result)); } }