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

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

            // populate Filter
            var requestFilterIsNull = true;

            request.Filter = new Amazon.Glue.Model.TaskRunFilterCriteria();
            System.DateTime?requestFilter_filter_StartedAfter = null;
            if (cmdletContext.Filter_StartedAfter != null)
            {
                requestFilter_filter_StartedAfter = cmdletContext.Filter_StartedAfter.Value;
            }
            if (requestFilter_filter_StartedAfter != null)
            {
                request.Filter.StartedAfter = requestFilter_filter_StartedAfter.Value;
                requestFilterIsNull         = false;
            }
            System.DateTime?requestFilter_filter_StartedBefore = null;
            if (cmdletContext.Filter_StartedBefore != null)
            {
                requestFilter_filter_StartedBefore = cmdletContext.Filter_StartedBefore.Value;
            }
            if (requestFilter_filter_StartedBefore != null)
            {
                request.Filter.StartedBefore = requestFilter_filter_StartedBefore.Value;
                requestFilterIsNull          = false;
            }
            Amazon.Glue.TaskStatusType requestFilter_filter_Status = null;
            if (cmdletContext.Filter_Status != null)
            {
                requestFilter_filter_Status = cmdletContext.Filter_Status;
            }
            if (requestFilter_filter_Status != null)
            {
                request.Filter.Status = requestFilter_filter_Status;
                requestFilterIsNull   = false;
            }
            Amazon.Glue.TaskType requestFilter_filter_TaskRunType = null;
            if (cmdletContext.Filter_TaskRunType != null)
            {
                requestFilter_filter_TaskRunType = cmdletContext.Filter_TaskRunType;
            }
            if (requestFilter_filter_TaskRunType != null)
            {
                request.Filter.TaskRunType = requestFilter_filter_TaskRunType;
                requestFilterIsNull        = false;
            }
            // determine if request.Filter should be set to null
            if (requestFilterIsNull)
            {
                request.Filter = null;
            }

            // populate Sort
            var requestSortIsNull = true;

            request.Sort = new Amazon.Glue.Model.TaskRunSortCriteria();
            Amazon.Glue.TaskRunSortColumnType requestSort_sort_Column = null;
            if (cmdletContext.Sort_Column != null)
            {
                requestSort_sort_Column = cmdletContext.Sort_Column;
            }
            if (requestSort_sort_Column != null)
            {
                request.Sort.Column = requestSort_sort_Column;
                requestSortIsNull   = false;
            }
            Amazon.Glue.SortDirectionType requestSort_sort_SortDirection = null;
            if (cmdletContext.Sort_SortDirection != null)
            {
                requestSort_sort_SortDirection = cmdletContext.Sort_SortDirection;
            }
            if (requestSort_sort_SortDirection != null)
            {
                request.Sort.SortDirection = requestSort_sort_SortDirection;
                requestSortIsNull          = false;
            }
            // determine if request.Sort should be set to null
            if (requestSortIsNull)
            {
                request.Sort = null;
            }
            if (cmdletContext.TransformId != null)
            {
                request.TransformId = cmdletContext.TransformId;
            }

            // Initialize loop variants and commence piping
            System.String _nextToken      = null;
            int?          _emitLimit      = null;
            int           _retrievedSoFar = 0;

            if (AutoIterationHelpers.HasValue(cmdletContext.NextToken))
            {
                _nextToken = cmdletContext.NextToken;
            }
            if (cmdletContext.MaxResult.HasValue)
            {
                // The service has a maximum page size of 1000. If the user has
                // asked for more items than page max, and there is no page size
                // configured, we rely on the service ignoring the set maximum
                // and giving us 1000 items back. If a page size is set, that will
                // be used to configure the pagination.
                // We'll make further calls to satisfy the user's request.
                _emitLimit = cmdletContext.MaxResult;
            }
            var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken));

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

            do
            {
                request.NextToken = _nextToken;
                if (_emitLimit.HasValue)
                {
                    int correctPageSize = Math.Min(1000, _emitLimit.Value);
                    request.MaxResults = AutoIterationHelpers.ConvertEmitLimitToInt32(correctPageSize);
                }

                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
                    };
                    int _receivedThisCall = response.TaskRuns.Count;

                    _nextToken       = response.NextToken;
                    _retrievedSoFar += _receivedThisCall;
                    if (_emitLimit.HasValue)
                    {
                        _emitLimit -= _receivedThisCall;
                    }
                }
                catch (Exception e)
                {
                    if (_retrievedSoFar == 0 || !_emitLimit.HasValue)
                    {
                        output = new CmdletOutput {
                            ErrorResponse = e
                        };
                    }
                    else
                    {
                        break;
                    }
                }

                ProcessOutput(output);
            } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken) && (!_emitLimit.HasValue || _emitLimit.Value >= 1));


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


            return(null);
        }
Beispiel #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.Glue.Model.GetMLTaskRunsRequest();


            // populate Filter
            var requestFilterIsNull = true;
            request.Filter = new Amazon.Glue.Model.TaskRunFilterCriteria();
            System.DateTime?requestFilter_filter_StartedAfter = null;
            if (cmdletContext.Filter_StartedAfter != null)
            {
                requestFilter_filter_StartedAfter = cmdletContext.Filter_StartedAfter.Value;
            }
            if (requestFilter_filter_StartedAfter != null)
            {
                request.Filter.StartedAfter = requestFilter_filter_StartedAfter.Value;
                requestFilterIsNull         = false;
            }
            System.DateTime?requestFilter_filter_StartedBefore = null;
            if (cmdletContext.Filter_StartedBefore != null)
            {
                requestFilter_filter_StartedBefore = cmdletContext.Filter_StartedBefore.Value;
            }
            if (requestFilter_filter_StartedBefore != null)
            {
                request.Filter.StartedBefore = requestFilter_filter_StartedBefore.Value;
                requestFilterIsNull          = false;
            }
            Amazon.Glue.TaskStatusType requestFilter_filter_Status = null;
            if (cmdletContext.Filter_Status != null)
            {
                requestFilter_filter_Status = cmdletContext.Filter_Status;
            }
            if (requestFilter_filter_Status != null)
            {
                request.Filter.Status = requestFilter_filter_Status;
                requestFilterIsNull   = false;
            }
            Amazon.Glue.TaskType requestFilter_filter_TaskRunType = null;
            if (cmdletContext.Filter_TaskRunType != null)
            {
                requestFilter_filter_TaskRunType = cmdletContext.Filter_TaskRunType;
            }
            if (requestFilter_filter_TaskRunType != null)
            {
                request.Filter.TaskRunType = requestFilter_filter_TaskRunType;
                requestFilterIsNull        = false;
            }
            // determine if request.Filter should be set to null
            if (requestFilterIsNull)
            {
                request.Filter = null;
            }
            if (cmdletContext.MaxResult != null)
            {
                request.MaxResults = AutoIterationHelpers.ConvertEmitLimitToServiceTypeInt32(cmdletContext.MaxResult.Value);
            }

            // populate Sort
            var requestSortIsNull = true;
            request.Sort = new Amazon.Glue.Model.TaskRunSortCriteria();
            Amazon.Glue.TaskRunSortColumnType requestSort_sort_Column = null;
            if (cmdletContext.Sort_Column != null)
            {
                requestSort_sort_Column = cmdletContext.Sort_Column;
            }
            if (requestSort_sort_Column != null)
            {
                request.Sort.Column = requestSort_sort_Column;
                requestSortIsNull   = false;
            }
            Amazon.Glue.SortDirectionType requestSort_sort_SortDirection = null;
            if (cmdletContext.Sort_SortDirection != null)
            {
                requestSort_sort_SortDirection = cmdletContext.Sort_SortDirection;
            }
            if (requestSort_sort_SortDirection != null)
            {
                request.Sort.SortDirection = requestSort_sort_SortDirection;
                requestSortIsNull          = false;
            }
            // determine if request.Sort should be set to null
            if (requestSortIsNull)
            {
                request.Sort = null;
            }
            if (cmdletContext.TransformId != null)
            {
                request.TransformId = cmdletContext.TransformId;
            }

            // 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);
        }