Ejemplo n.º 1
0
        /// <summary>
        /// Gets information about the specified database node.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <GetDbNodeResponse> GetDbNode(GetDbNodeRequest request)
        {
            var uri = new Uri($"{GetEndPoint(DatabaseServices.DbNodes, this.Region)}/{request.DbNodeId}");

            using (var webResponse = await this.RestClientAsync.Get(uri))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = await reader.ReadToEndAsync();

                        return(new GetDbNodeResponse()
                        {
                            DbNode = this.JsonSerializer.Deserialize <DbNodeDetails>(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            ETag = webResponse.Headers.Get("ETag")
                        });
                    }
        }
Ejemplo n.º 2
0
        private void HandleOutput(GetDbNodeRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForDbNode(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetDbNode(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.DbNode);
        }
Ejemplo n.º 3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetDbNodeRequest request;

            try
            {
                request = new GetDbNodeRequest
                {
                    DbNodeId = DbNodeId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }