protected override void ProcessRecord() { base.ProcessRecord(); UpdateZoneRequest request; try { request = new UpdateZoneRequest { ZoneNameOrId = ZoneNameOrId, UpdateZoneDetails = UpdateZoneDetails, IfMatch = IfMatch, IfUnmodifiedSince = IfUnmodifiedSince, OpcRequestId = OpcRequestId, Scope = Scope, ViewId = ViewId, CompartmentId = CompartmentId }; response = client.UpdateZone(request).GetAwaiter().GetResult(); WriteOutput(response, response.Zone); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Updates the specified secondary zone with your new external master server information. /// For more information about secondary zone, see Manage DNS Service Zone. /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <UpdateZoneResponse> UpdateZone(UpdateZoneRequest request) { var uriStr = $"{GetEndPoint(DNSServices.Zones, this.Region)}/{request.ZoneNameOrId}"; if (!string.IsNullOrEmpty(request.CompartmentId)) { uriStr = $"{uriStr}?compartmentId={request.CompartmentId}"; } var uri = new Uri(uriStr); var httpRequestHeaderParam = new HttpRequestHeaderParam() { IfMatch = request.IfMatch, IfUnmodifiedSince = request.IfUnmodifiedSince }; var webResponse = await this.RestClientAsync.Put(uri, request.UpdateZoneDetails, httpRequestHeaderParam); using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new UpdateZoneResponse() { Zone = this.JsonSerializer.Deserialize <ZoneDetails>(response), OpcRequestId = webResponse.Headers.Get("opc-request-id"), ETag = webResponse.Headers.Get("ETag") }); } }
public async Task UpdateZoneAsync(string zoneName, UpdateZoneRequest req) { if (string.IsNullOrEmpty(zoneName)) { throw new Client.Exception.ANSClientValidationException("Invalid zone name"); } await this.Client.PatchAsync($"/safedns/v1/zones/{zoneName}", req); }
public async Task UpdateZoneAsync_ValidParameters_ExpectedClientCall() { UpdateZoneRequest req = new UpdateZoneRequest() { Description = "test description 1" }; IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); var ops = new ZoneOperations <Zone>(client); await ops.UpdateZoneAsync("example.com", req); await client.Received().PatchAsync("/safedns/v1/zones/example.com", req); }