Container for the parameters to the ListAttacks operation. Returns all ongoing DDoS attacks or all DDoS attacks during a specified time period.
상속: AmazonShieldRequest
 /// <summary>
 /// Paginator for ListAttacks operation
 ///</summary>
 public IListAttacksPaginator ListAttacks(ListAttacksRequest request)
 {
     return(new ListAttacksPaginator(this.client, request));
 }
예제 #2
0
 private Amazon.Shield.Model.ListAttacksResponse CallAWSServiceOperation(IAmazonShield client, Amazon.Shield.Model.ListAttacksRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Shield", "ListAttacks");
     try
     {
         #if DESKTOP
         return(client.ListAttacks(request));
         #elif CORECLR
         return(client.ListAttacksAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
예제 #3
0
 internal ListAttacksPaginator(IAmazonShield client, ListAttacksRequest request)
 {
     this._client  = client;
     this._request = request;
 }
예제 #4
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.Shield.Model.ListAttacksRequest();

            // populate EndTime
            var requestEndTimeIsNull = true;

            request.EndTime = new Amazon.Shield.Model.TimeRange();
            System.DateTime?requestEndTime_endTime_FromInclusive = null;
            if (cmdletContext.EndTime_FromInclusive != null)
            {
                requestEndTime_endTime_FromInclusive = cmdletContext.EndTime_FromInclusive.Value;
            }
            if (requestEndTime_endTime_FromInclusive != null)
            {
                request.EndTime.FromInclusive = requestEndTime_endTime_FromInclusive.Value;
                requestEndTimeIsNull          = false;
            }
            System.DateTime?requestEndTime_endTime_ToExclusive = null;
            if (cmdletContext.EndTime_ToExclusive != null)
            {
                requestEndTime_endTime_ToExclusive = cmdletContext.EndTime_ToExclusive.Value;
            }
            if (requestEndTime_endTime_ToExclusive != null)
            {
                request.EndTime.ToExclusive = requestEndTime_endTime_ToExclusive.Value;
                requestEndTimeIsNull        = false;
            }
            // determine if request.EndTime should be set to null
            if (requestEndTimeIsNull)
            {
                request.EndTime = null;
            }
            if (cmdletContext.ResourceArn != null)
            {
                request.ResourceArns = cmdletContext.ResourceArn;
            }

            // populate StartTime
            var requestStartTimeIsNull = true;

            request.StartTime = new Amazon.Shield.Model.TimeRange();
            System.DateTime?requestStartTime_startTime_FromInclusive = null;
            if (cmdletContext.StartTime_FromInclusive != null)
            {
                requestStartTime_startTime_FromInclusive = cmdletContext.StartTime_FromInclusive.Value;
            }
            if (requestStartTime_startTime_FromInclusive != null)
            {
                request.StartTime.FromInclusive = requestStartTime_startTime_FromInclusive.Value;
                requestStartTimeIsNull          = false;
            }
            System.DateTime?requestStartTime_startTime_ToExclusive = null;
            if (cmdletContext.StartTime_ToExclusive != null)
            {
                requestStartTime_startTime_ToExclusive = cmdletContext.StartTime_ToExclusive.Value;
            }
            if (requestStartTime_startTime_ToExclusive != null)
            {
                request.StartTime.ToExclusive = requestStartTime_startTime_ToExclusive.Value;
                requestStartTimeIsNull        = false;
            }
            // determine if request.StartTime should be set to null
            if (requestStartTimeIsNull)
            {
                request.StartTime = 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)
            {
                // The service has a maximum page size of 10000. 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 10000 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(10000, _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.AttackSummaries.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 >= 0));


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


            return(null);
        }
예제 #5
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.Shield.Model.ListAttacksRequest();


            // populate EndTime
            var requestEndTimeIsNull = true;

            request.EndTime = new Amazon.Shield.Model.TimeRange();
            System.DateTime?requestEndTime_endTime_FromInclusive = null;
            if (cmdletContext.EndTime_FromInclusive != null)
            {
                requestEndTime_endTime_FromInclusive = cmdletContext.EndTime_FromInclusive.Value;
            }
            if (requestEndTime_endTime_FromInclusive != null)
            {
                request.EndTime.FromInclusive = requestEndTime_endTime_FromInclusive.Value;
                requestEndTimeIsNull          = false;
            }
            System.DateTime?requestEndTime_endTime_ToExclusive = null;
            if (cmdletContext.EndTime_ToExclusive != null)
            {
                requestEndTime_endTime_ToExclusive = cmdletContext.EndTime_ToExclusive.Value;
            }
            if (requestEndTime_endTime_ToExclusive != null)
            {
                request.EndTime.ToExclusive = requestEndTime_endTime_ToExclusive.Value;
                requestEndTimeIsNull        = false;
            }
            // determine if request.EndTime should be set to null
            if (requestEndTimeIsNull)
            {
                request.EndTime = null;
            }
            if (cmdletContext.MaxResult != null)
            {
                request.MaxResults = AutoIterationHelpers.ConvertEmitLimitToServiceTypeInt32(cmdletContext.MaxResult.Value);
            }
            if (cmdletContext.ResourceArn != null)
            {
                request.ResourceArns = cmdletContext.ResourceArn;
            }

            // populate StartTime
            var requestStartTimeIsNull = true;

            request.StartTime = new Amazon.Shield.Model.TimeRange();
            System.DateTime?requestStartTime_startTime_FromInclusive = null;
            if (cmdletContext.StartTime_FromInclusive != null)
            {
                requestStartTime_startTime_FromInclusive = cmdletContext.StartTime_FromInclusive.Value;
            }
            if (requestStartTime_startTime_FromInclusive != null)
            {
                request.StartTime.FromInclusive = requestStartTime_startTime_FromInclusive.Value;
                requestStartTimeIsNull          = false;
            }
            System.DateTime?requestStartTime_startTime_ToExclusive = null;
            if (cmdletContext.StartTime_ToExclusive != null)
            {
                requestStartTime_startTime_ToExclusive = cmdletContext.StartTime_ToExclusive.Value;
            }
            if (requestStartTime_startTime_ToExclusive != null)
            {
                request.StartTime.ToExclusive = requestStartTime_startTime_ToExclusive.Value;
                requestStartTimeIsNull        = false;
            }
            // determine if request.StartTime should be set to null
            if (requestStartTimeIsNull)
            {
                request.StartTime = null;
            }

            // 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);
        }
예제 #6
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListAttacks operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ListAttacks operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<ListAttacksResponse> ListAttacksAsync(ListAttacksRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ListAttacksRequestMarshaller();
            var unmarshaller = ListAttacksResponseUnmarshaller.Instance;

            return InvokeAsync<ListAttacksRequest,ListAttacksResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
예제 #7
0
        /// <summary>
        /// Returns all ongoing DDoS attacks or all DDoS attacks during a specified time period.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListAttacks service method.</param>
        /// 
        /// <returns>The response from the ListAttacks service method, as returned by Shield.</returns>
        /// <exception cref="Amazon.Shield.Model.InternalErrorException">
        /// Exception that indicates that a problem occurred with the service infrastructure.
        /// You can retry the request.
        /// </exception>
        /// <exception cref="Amazon.Shield.Model.InvalidOperationException">
        /// Exception that indicates that the operation would not cause any change to occur.
        /// </exception>
        /// <exception cref="Amazon.Shield.Model.InvalidParameterException">
        /// Exception that indicates that the parameters passed to the API are invalid.
        /// </exception>
        public ListAttacksResponse ListAttacks(ListAttacksRequest request)
        {
            var marshaller = new ListAttacksRequestMarshaller();
            var unmarshaller = ListAttacksResponseUnmarshaller.Instance;

            return Invoke<ListAttacksRequest,ListAttacksResponse>(request, marshaller, unmarshaller);
        }
예제 #8
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListAttacks operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ListAttacks operation on AmazonShieldClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListAttacks
        ///         operation.</returns>
        public IAsyncResult BeginListAttacks(ListAttacksRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new ListAttacksRequestMarshaller();
            var unmarshaller = ListAttacksResponseUnmarshaller.Instance;

            return BeginInvoke<ListAttacksRequest>(request, marshaller, unmarshaller,
                callback, state);
        }