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.Inspector.Model.ListFindingsRequest(); if (cmdletContext.AssessmentRunArn != null) { request.AssessmentRunArns = cmdletContext.AssessmentRunArn; } // populate Filter var requestFilterIsNull = true; request.Filter = new Amazon.Inspector.Model.FindingFilter(); List <System.String> requestFilter_filter_AgentId = null; if (cmdletContext.Filter_AgentId != null) { requestFilter_filter_AgentId = cmdletContext.Filter_AgentId; } if (requestFilter_filter_AgentId != null) { request.Filter.AgentIds = requestFilter_filter_AgentId; requestFilterIsNull = false; } List <Amazon.Inspector.Model.Attribute> requestFilter_filter_Attribute = null; if (cmdletContext.Filter_Attribute != null) { requestFilter_filter_Attribute = cmdletContext.Filter_Attribute; } if (requestFilter_filter_Attribute != null) { request.Filter.Attributes = requestFilter_filter_Attribute; requestFilterIsNull = false; } List <System.String> requestFilter_filter_AutoScalingGroup = null; if (cmdletContext.Filter_AutoScalingGroup != null) { requestFilter_filter_AutoScalingGroup = cmdletContext.Filter_AutoScalingGroup; } if (requestFilter_filter_AutoScalingGroup != null) { request.Filter.AutoScalingGroups = requestFilter_filter_AutoScalingGroup; requestFilterIsNull = false; } List <System.String> requestFilter_filter_RuleName = null; if (cmdletContext.Filter_RuleName != null) { requestFilter_filter_RuleName = cmdletContext.Filter_RuleName; } if (requestFilter_filter_RuleName != null) { request.Filter.RuleNames = requestFilter_filter_RuleName; requestFilterIsNull = false; } List <System.String> requestFilter_filter_RulesPackageArn = null; if (cmdletContext.Filter_RulesPackageArn != null) { requestFilter_filter_RulesPackageArn = cmdletContext.Filter_RulesPackageArn; } if (requestFilter_filter_RulesPackageArn != null) { request.Filter.RulesPackageArns = requestFilter_filter_RulesPackageArn; requestFilterIsNull = false; } List <System.String> requestFilter_filter_Severity = null; if (cmdletContext.Filter_Severity != null) { requestFilter_filter_Severity = cmdletContext.Filter_Severity; } if (requestFilter_filter_Severity != null) { request.Filter.Severities = requestFilter_filter_Severity; requestFilterIsNull = false; } List <Amazon.Inspector.Model.Attribute> requestFilter_filter_UserAttribute = null; if (cmdletContext.Filter_UserAttribute != null) { requestFilter_filter_UserAttribute = cmdletContext.Filter_UserAttribute; } if (requestFilter_filter_UserAttribute != null) { request.Filter.UserAttributes = requestFilter_filter_UserAttribute; requestFilterIsNull = false; } Amazon.Inspector.Model.TimestampRange requestFilter_filter_CreationTimeRange = null; // populate CreationTimeRange var requestFilter_filter_CreationTimeRangeIsNull = true; requestFilter_filter_CreationTimeRange = new Amazon.Inspector.Model.TimestampRange(); System.DateTime?requestFilter_filter_CreationTimeRange_creationTimeRange_BeginDate = null; if (cmdletContext.CreationTimeRange_BeginDate != null) { requestFilter_filter_CreationTimeRange_creationTimeRange_BeginDate = cmdletContext.CreationTimeRange_BeginDate.Value; } if (requestFilter_filter_CreationTimeRange_creationTimeRange_BeginDate != null) { requestFilter_filter_CreationTimeRange.BeginDate = requestFilter_filter_CreationTimeRange_creationTimeRange_BeginDate.Value; requestFilter_filter_CreationTimeRangeIsNull = false; } System.DateTime?requestFilter_filter_CreationTimeRange_creationTimeRange_EndDate = null; if (cmdletContext.CreationTimeRange_EndDate != null) { requestFilter_filter_CreationTimeRange_creationTimeRange_EndDate = cmdletContext.CreationTimeRange_EndDate.Value; } if (requestFilter_filter_CreationTimeRange_creationTimeRange_EndDate != null) { requestFilter_filter_CreationTimeRange.EndDate = requestFilter_filter_CreationTimeRange_creationTimeRange_EndDate.Value; requestFilter_filter_CreationTimeRangeIsNull = false; } // determine if requestFilter_filter_CreationTimeRange should be set to null if (requestFilter_filter_CreationTimeRangeIsNull) { requestFilter_filter_CreationTimeRange = null; } if (requestFilter_filter_CreationTimeRange != null) { request.Filter.CreationTimeRange = requestFilter_filter_CreationTimeRange; requestFilterIsNull = false; } // determine if request.Filter should be set to null if (requestFilterIsNull) { request.Filter = null; } // 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) { _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) { request.MaxResults = AutoIterationHelpers.ConvertEmitLimitToInt32(_emitLimit.Value); } 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.FindingArns.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); }
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.Inspector.Model.ListAssessmentRunsRequest(); if (cmdletContext.AssessmentTemplateArn != null) { request.AssessmentTemplateArns = cmdletContext.AssessmentTemplateArn; } // populate Filter var requestFilterIsNull = true; request.Filter = new Amazon.Inspector.Model.AssessmentRunFilter(); System.String requestFilter_filter_NamePattern = null; if (cmdletContext.Filter_NamePattern != null) { requestFilter_filter_NamePattern = cmdletContext.Filter_NamePattern; } if (requestFilter_filter_NamePattern != null) { request.Filter.NamePattern = requestFilter_filter_NamePattern; requestFilterIsNull = false; } List <System.String> requestFilter_filter_RulesPackageArn = null; if (cmdletContext.Filter_RulesPackageArn != null) { requestFilter_filter_RulesPackageArn = cmdletContext.Filter_RulesPackageArn; } if (requestFilter_filter_RulesPackageArn != null) { request.Filter.RulesPackageArns = requestFilter_filter_RulesPackageArn; requestFilterIsNull = false; } List <System.String> requestFilter_filter_State = null; if (cmdletContext.Filter_State != null) { requestFilter_filter_State = cmdletContext.Filter_State; } if (requestFilter_filter_State != null) { request.Filter.States = requestFilter_filter_State; requestFilterIsNull = false; } Amazon.Inspector.Model.TimestampRange requestFilter_filter_CompletionTimeRange = null; // populate CompletionTimeRange var requestFilter_filter_CompletionTimeRangeIsNull = true; requestFilter_filter_CompletionTimeRange = new Amazon.Inspector.Model.TimestampRange(); System.DateTime?requestFilter_filter_CompletionTimeRange_completionTimeRange_BeginDate = null; if (cmdletContext.CompletionTimeRange_BeginDate != null) { requestFilter_filter_CompletionTimeRange_completionTimeRange_BeginDate = cmdletContext.CompletionTimeRange_BeginDate.Value; } if (requestFilter_filter_CompletionTimeRange_completionTimeRange_BeginDate != null) { requestFilter_filter_CompletionTimeRange.BeginDate = requestFilter_filter_CompletionTimeRange_completionTimeRange_BeginDate.Value; requestFilter_filter_CompletionTimeRangeIsNull = false; } System.DateTime?requestFilter_filter_CompletionTimeRange_completionTimeRange_EndDate = null; if (cmdletContext.CompletionTimeRange_EndDate != null) { requestFilter_filter_CompletionTimeRange_completionTimeRange_EndDate = cmdletContext.CompletionTimeRange_EndDate.Value; } if (requestFilter_filter_CompletionTimeRange_completionTimeRange_EndDate != null) { requestFilter_filter_CompletionTimeRange.EndDate = requestFilter_filter_CompletionTimeRange_completionTimeRange_EndDate.Value; requestFilter_filter_CompletionTimeRangeIsNull = false; } // determine if requestFilter_filter_CompletionTimeRange should be set to null if (requestFilter_filter_CompletionTimeRangeIsNull) { requestFilter_filter_CompletionTimeRange = null; } if (requestFilter_filter_CompletionTimeRange != null) { request.Filter.CompletionTimeRange = requestFilter_filter_CompletionTimeRange; requestFilterIsNull = false; } Amazon.Inspector.Model.DurationRange requestFilter_filter_DurationRange = null; // populate DurationRange var requestFilter_filter_DurationRangeIsNull = true; requestFilter_filter_DurationRange = new Amazon.Inspector.Model.DurationRange(); System.Int32?requestFilter_filter_DurationRange_durationRange_MaxSecond = null; if (cmdletContext.DurationRange_MaxSecond != null) { requestFilter_filter_DurationRange_durationRange_MaxSecond = cmdletContext.DurationRange_MaxSecond.Value; } if (requestFilter_filter_DurationRange_durationRange_MaxSecond != null) { requestFilter_filter_DurationRange.MaxSeconds = requestFilter_filter_DurationRange_durationRange_MaxSecond.Value; requestFilter_filter_DurationRangeIsNull = false; } System.Int32?requestFilter_filter_DurationRange_durationRange_MinSecond = null; if (cmdletContext.DurationRange_MinSecond != null) { requestFilter_filter_DurationRange_durationRange_MinSecond = cmdletContext.DurationRange_MinSecond.Value; } if (requestFilter_filter_DurationRange_durationRange_MinSecond != null) { requestFilter_filter_DurationRange.MinSeconds = requestFilter_filter_DurationRange_durationRange_MinSecond.Value; requestFilter_filter_DurationRangeIsNull = false; } // determine if requestFilter_filter_DurationRange should be set to null if (requestFilter_filter_DurationRangeIsNull) { requestFilter_filter_DurationRange = null; } if (requestFilter_filter_DurationRange != null) { request.Filter.DurationRange = requestFilter_filter_DurationRange; requestFilterIsNull = false; } Amazon.Inspector.Model.TimestampRange requestFilter_filter_StartTimeRange = null; // populate StartTimeRange var requestFilter_filter_StartTimeRangeIsNull = true; requestFilter_filter_StartTimeRange = new Amazon.Inspector.Model.TimestampRange(); System.DateTime?requestFilter_filter_StartTimeRange_startTimeRange_BeginDate = null; if (cmdletContext.StartTimeRange_BeginDate != null) { requestFilter_filter_StartTimeRange_startTimeRange_BeginDate = cmdletContext.StartTimeRange_BeginDate.Value; } if (requestFilter_filter_StartTimeRange_startTimeRange_BeginDate != null) { requestFilter_filter_StartTimeRange.BeginDate = requestFilter_filter_StartTimeRange_startTimeRange_BeginDate.Value; requestFilter_filter_StartTimeRangeIsNull = false; } System.DateTime?requestFilter_filter_StartTimeRange_startTimeRange_EndDate = null; if (cmdletContext.StartTimeRange_EndDate != null) { requestFilter_filter_StartTimeRange_startTimeRange_EndDate = cmdletContext.StartTimeRange_EndDate.Value; } if (requestFilter_filter_StartTimeRange_startTimeRange_EndDate != null) { requestFilter_filter_StartTimeRange.EndDate = requestFilter_filter_StartTimeRange_startTimeRange_EndDate.Value; requestFilter_filter_StartTimeRangeIsNull = false; } // determine if requestFilter_filter_StartTimeRange should be set to null if (requestFilter_filter_StartTimeRangeIsNull) { requestFilter_filter_StartTimeRange = null; } if (requestFilter_filter_StartTimeRange != null) { request.Filter.StartTimeRange = requestFilter_filter_StartTimeRange; requestFilterIsNull = false; } Amazon.Inspector.Model.TimestampRange requestFilter_filter_StateChangeTimeRange = null; // populate StateChangeTimeRange var requestFilter_filter_StateChangeTimeRangeIsNull = true; requestFilter_filter_StateChangeTimeRange = new Amazon.Inspector.Model.TimestampRange(); System.DateTime?requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_BeginDate = null; if (cmdletContext.StateChangeTimeRange_BeginDate != null) { requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_BeginDate = cmdletContext.StateChangeTimeRange_BeginDate.Value; } if (requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_BeginDate != null) { requestFilter_filter_StateChangeTimeRange.BeginDate = requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_BeginDate.Value; requestFilter_filter_StateChangeTimeRangeIsNull = false; } System.DateTime?requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_EndDate = null; if (cmdletContext.StateChangeTimeRange_EndDate != null) { requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_EndDate = cmdletContext.StateChangeTimeRange_EndDate.Value; } if (requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_EndDate != null) { requestFilter_filter_StateChangeTimeRange.EndDate = requestFilter_filter_StateChangeTimeRange_stateChangeTimeRange_EndDate.Value; requestFilter_filter_StateChangeTimeRangeIsNull = false; } // determine if requestFilter_filter_StateChangeTimeRange should be set to null if (requestFilter_filter_StateChangeTimeRangeIsNull) { requestFilter_filter_StateChangeTimeRange = null; } if (requestFilter_filter_StateChangeTimeRange != null) { request.Filter.StateChangeTimeRange = requestFilter_filter_StateChangeTimeRange; 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); } // 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); }