예제 #1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext      = context as CmdletContext;
            var useParameterSelect = this.Select.StartsWith("^");

            // create request and set iteration invariants
            var request = new Amazon.ApiGatewayV2.Model.GetDomainNamesRequest();

            if (cmdletContext.MaxResult != null)
            {
                request.MaxResults = AutoIterationHelpers.ConvertEmitLimitToServiceTypeString(cmdletContext.MaxResult.Value);
            }

            // Initialize loop variant and commence piping
            var _nextToken             = cmdletContext.NextToken;
            var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken));

            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            do
            {
                request.NextToken = _nextToken;

                CmdletOutput output;

                try
                {
                    var response = CallAWSServiceOperation(client, request);

                    object pipelineOutput = null;
                    if (!useParameterSelect)
                    {
                        pipelineOutput = cmdletContext.Select(response, this);
                    }
                    output = new CmdletOutput
                    {
                        PipelineOutput  = pipelineOutput,
                        ServiceResponse = response
                    };

                    _nextToken = response.NextToken;
                }
                catch (Exception e)
                {
                    output = new CmdletOutput {
                        ErrorResponse = e
                    };
                }

                ProcessOutput(output);
            } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken));

            if (useParameterSelect)
            {
                WriteObject(cmdletContext.Select(null, this));
            }


            return(null);
        }
예제 #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;

            #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
            var useParameterSelect = this.Select.StartsWith("^") || this.PassThru.IsPresent;
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute

            // create request and set iteration invariants
            var request = new Amazon.Route53.Model.ListQueryLoggingConfigsRequest();

            if (cmdletContext.HostedZoneId != null)
            {
                request.HostedZoneId = cmdletContext.HostedZoneId;
            }
            if (cmdletContext.MaxResult != null)
            {
                request.MaxResults = AutoIterationHelpers.ConvertEmitLimitToServiceTypeString(cmdletContext.MaxResult.Value);
            }

            // Initialize loop variant and commence piping
            var _nextToken             = cmdletContext.NextToken;
            var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken));

            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
            do
            {
                request.NextToken = _nextToken;

                CmdletOutput output;

                try
                {
                    var response = CallAWSServiceOperation(client, request);

                    object pipelineOutput = null;
                    if (!useParameterSelect)
                    {
                        pipelineOutput = cmdletContext.Select(response, this);
                    }
                    output = new CmdletOutput
                    {
                        PipelineOutput  = pipelineOutput,
                        ServiceResponse = response
                    };

                    _nextToken = response.NextToken;
                }
                catch (Exception e)
                {
                    output = new CmdletOutput {
                        ErrorResponse = e
                    };
                }

                ProcessOutput(output);
            } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken));

            if (useParameterSelect)
            {
                WriteObject(cmdletContext.Select(null, this));
            }


            return(null);
        }
예제 #3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext      = context as CmdletContext;
            var useParameterSelect = this.Select.StartsWith(".");

            // create request and set iteration invariants
            var request = new Amazon.Route53.Model.ListHostedZonesByNameRequest();

            if (cmdletContext.MaxItem != null)
            {
                request.MaxItems = AutoIterationHelpers.ConvertEmitLimitToServiceTypeString(cmdletContext.MaxItem.Value);
            }

            // Initialize loop variant and commence piping
            string _nextDNSName           = cmdletContext.DNSName;
            string _nextHostedZoneId      = cmdletContext.HostedZoneId;
            var    _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.DNSName)) || ParameterWasBound(nameof(this.HostedZoneId));

            try
            {
                var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
                do
                {
                    request.DNSName      = _nextDNSName;
                    request.HostedZoneId = _nextHostedZoneId;

                    CmdletOutput output;

                    try
                    {
                        var response = CallAWSServiceOperation(client, request);

                        object pipelineOutput = null;
                        if (!useParameterSelect)
                        {
                            pipelineOutput = cmdletContext.Select(response, this);
                        }
                        output = new CmdletOutput
                        {
                            PipelineOutput  = pipelineOutput,
                            ServiceResponse = response
                        };
                        if (_userControllingPaging)
                        {
                            int _receivedThisCall = (pipelineOutput as System.Collections.ICollection)?.Count ?? 1;
                            WriteProgressRecord("Retrieving", $"Retrieved {_receivedThisCall} records starting from marker '{request.DNSName ?? "null"}, {request.HostedZoneId ?? "null"}'");
                        }

                        _nextDNSName      = response.NextDNSName;
                        _nextHostedZoneId = response.NextHostedZoneId;
                    }
                    catch (Exception e)
                    {
                        output = new CmdletOutput {
                            ErrorResponse = e
                        };
                    }

                    ProcessOutput(output);
                } while (!_userControllingPaging && (AutoIterationHelpers.HasValue(_nextDNSName) || AutoIterationHelpers.HasValue(_nextHostedZoneId)));
            }
            finally
            {
                if (_userControllingPaging)
                {
                    WriteProgressCompleteRecord("Retrieving", "Retrieved records");
                }
            }

            if (useParameterSelect)
            {
                WriteObject(cmdletContext.Select(null, this));
            }


            return(null);
        }