private void HandleOutput(DbNodeActionRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case StatusParamSet: response = client.Waiters.ForDbNodeAction(request, waiterConfig, WaitForStatus).Execute(); break; case Default: response = client.DbNodeAction(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.DbNode); }
protected override void ProcessRecord() { base.ProcessRecord(); DbNodeActionRequest request; try { request = new DbNodeActionRequest { DbNodeId = DbNodeId, Action = Action, OpcRetryToken = OpcRetryToken, IfMatch = IfMatch }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Stopping a node affects billing differently, depending on the type of DB system: /// Bare metal and Exadata DB systems - The stop state has no effect on the resources you consume.Billing /// continues for DB nodes that you stop, and related resources continue to apply against any relevant quotas. /// You must terminate the DB system (TerminateDbSystem) to remove its resources from billing and quotas. /// Virtual machine DB systems - Stopping a node stops billing for all OCPUs associated with that node, /// and billing resumes when you restart the node. /// </summary> /// <param name="request"></param> /// <returns></returns> public DbNodeActionResponse DbNodeAction(DbNodeActionRequest request) { var uri = new Uri($"{GetEndPoint(DatabaseServices.DbNodes, this.Region)}/{request.DbNodeId}?action={request.Action.Value}"); var headParam = new HttpRequestHeaderParam() { OpcRetryToken = request.OpcRetryToken, IfMatch = request.IfMatch }; var webResponse = this.RestClient.Post(uri, null, headParam); using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new DbNodeActionResponse() { DbNode = this.JsonSerializer.Deserialize <DbNodeDetails>(response), OpcRequestId = webResponse.Headers.Get("opc-request-id"), ETag = webResponse.Headers.Get("ETag") }); } }