protected override void ProcessRecord() { base.ProcessRecord(); ChangeWaasPolicyCompartmentRequest request; try { request = new ChangeWaasPolicyCompartmentRequest { WaasPolicyId = WaasPolicyId, ChangeWaasPolicyCompartmentDetails = ChangeWaasPolicyCompartmentDetails, IfMatch = IfMatch, OpcRequestId = OpcRequestId, OpcRetryToken = OpcRetryToken }; response = client.ChangeWaasPolicyCompartment(request).GetAwaiter().GetResult(); WriteOutput(response); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Moves WAAS policy into a different compartment. When provided, If-Match is checked against ETag values of the WAAS policy. /// For information about moving resources between compartments, see Moving Resources to a Different Compartment. /// </summary> /// <param name="request"></param> /// <returns></returns> public ChangeWaasPolicyCompartmentResponse ChangeWaasPolicyCompartment(ChangeWaasPolicyCompartmentRequest request) { var uri = new Uri($"{GetEndPoint(WaasServices.WaasPolicies, this.Region)}/{request.WaasPolicyId}/actions/changeCompartment"); var httpRequestHeaderParam = new HttpRequestHeaderParam() { OpcRetryToken = request.OpcRetryToken, OpcRequestId = request.OpcRequestId, IfMatch = request.IfMatch }; using (var webResponse = this.RestClient.Post(uri, request.ChangeWaasPolicyCompartmentDetails, httpRequestHeaderParam)) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new ChangeWaasPolicyCompartmentResponse() { OpcRequestId = webResponse.Headers.Get("opc-request-id") }); } }