protected override void ProcessRecord() { base.ProcessRecord(); ChangeZoneCompartmentRequest request; try { request = new ChangeZoneCompartmentRequest { ZoneId = ZoneId, ChangeZoneCompartmentDetails = ChangeZoneCompartmentDetails, IfMatch = IfMatch, OpcRetryToken = OpcRetryToken, OpcRequestId = OpcRequestId, Scope = Scope }; response = client.ChangeZoneCompartment(request).GetAwaiter().GetResult(); WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId)); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Moves a zone into a different compartment. When provided, If-Match is checked against ETag values of the resource. /// Note: All SteeringPolicyAttachment objects associated with this zone will also be moved into the provided compartment. /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <ChangeZoneCompartmentResponse> ChangeZoneCompartment(ChangeZoneCompartmentRequest request) { var uri = new Uri($"{GetEndPoint(DNSServices.Zones, this.Region)}/{request.ZoneId}/actions/changeCompartment"); var httpRequestHeaderParam = new HttpRequestHeaderParam() { OpcRetryToken = request.OpcRetryToken, IfMatch = request.IfMatch }; var webResponse = await this.RestClientAsync.Post(uri, request.ChangeZoneCompartmentDetails, httpRequestHeaderParam); using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new ChangeZoneCompartmentResponse() { OpcRequestId = webResponse.Headers.Get("opc-request-id") }); } }