Container for the parameters to the CreateByteMatchSet operation. Creates a ByteMatchSet. You then use UpdateByteMatchSet to identify the part of a web request that you want AWS WAF to inspect, such as the values of the User-Agent header or the query string. For example, you can create a ByteMatchSet that matches any requests with User-Agent headers that contain the string BadBot. You can then configure AWS WAF to reject those requests.

To create and configure a ByteMatchSet, perform the following steps:

  1. Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateByteMatchSet request.

  2. Submit a CreateByteMatchSet request.

  3. Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateByteMatchSet request.

  4. Submit an UpdateByteMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

Inheritance: AmazonWAFRequest
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.WAF.Model.CreateByteMatchSetRequest();

            if (cmdletContext.ChangeToken != null)
            {
                request.ChangeToken = cmdletContext.ChangeToken;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }

            CmdletOutput output;

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

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
示例#2
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateByteMatchSet operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateByteMatchSet operation on AmazonWAFClient.</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 EndCreateByteMatchSet
        ///         operation.</returns>
        public IAsyncResult BeginCreateByteMatchSet(CreateByteMatchSetRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CreateByteMatchSetRequestMarshaller();
            var unmarshaller = CreateByteMatchSetResponseUnmarshaller.Instance;

            return BeginInvoke<CreateByteMatchSetRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
示例#3
0
        /// <summary>
        /// Creates a <code>ByteMatchSet</code>. You then use <a>UpdateByteMatchSet</a> to identify
        /// the part of a web request that you want AWS WAF to inspect, such as the values of
        /// the <code>User-Agent</code> header or the query string. For example, you can create
        /// a <code>ByteMatchSet</code> that matches any requests with <code>User-Agent</code>
        /// headers that contain the string <code>BadBot</code>. You can then configure AWS WAF
        /// to reject those requests.
        /// 
        ///  
        /// <para>
        /// To create and configure a <code>ByteMatchSet</code>, perform the following steps:
        /// </para>
        ///  <ol> <li>Use <a>GetChangeToken</a> to get the change token that you provide in the
        /// <code>ChangeToken</code> parameter of a <code>CreateByteMatchSet</code> request.</li>
        /// <li>Submit a <code>CreateByteMatchSet</code> request.</li> <li>Use <code>GetChangeToken</code>
        /// to get the change token that you provide in the <code>ChangeToken</code> parameter
        /// of an <code>UpdateByteMatchSet</code> request.</li> <li>Submit an <a>UpdateByteMatchSet</a>
        /// request to specify the part of the request that you want AWS WAF to inspect (for example,
        /// the header or the URI) and the value that you want AWS WAF to watch for.</li> </ol>
        /// 
        /// <para>
        /// For more information about how to use the AWS WAF API to allow or block HTTP requests,
        /// see the <a href="http://docs.aws.amazon.com/waf/latest/developerguide/">AWS WAF Developer
        /// Guide</a>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateByteMatchSet service method.</param>
        /// 
        /// <returns>The response from the CreateByteMatchSet service method, as returned by WAF.</returns>
        /// <exception cref="Amazon.WAF.Model.WAFDisallowedNameException">
        /// The name specified is invalid.
        /// </exception>
        /// <exception cref="Amazon.WAF.Model.WAFInternalErrorException">
        /// The operation failed because of a system problem, even though the request was valid.
        /// Retry your request.
        /// </exception>
        /// <exception cref="Amazon.WAF.Model.WAFInvalidAccountException">
        /// The operation failed because you tried to create, update, or delete an object by using
        /// an invalid account identifier.
        /// </exception>
        /// <exception cref="Amazon.WAF.Model.WAFInvalidParameterException">
        /// The operation failed because AWS WAF didn't recognize a parameter in the request.
        /// For example:
        /// 
        ///  <ul> <li>You specified an invalid parameter name.</li> <li>You specified an invalid
        /// value.</li> <li>You tried to update an object (<code>ByteMatchSet</code>, <code>IPSet</code>,
        /// <code>Rule</code>, or <code>WebACL</code>) using an action other than <code>INSERT</code>
        /// or <code>DELETE</code>.</li> <li>You tried to create a <code>WebACL</code> with a
        /// <code>DefaultAction</code> <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>,
        /// or <code>COUNT</code>.</li> <li>You tried to update a <code>WebACL</code> with a <code>WafAction</code>
        /// <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>, or <code>COUNT</code>.</li>
        /// <li>You tried to update a <code>ByteMatchSet</code> with a <code>FieldToMatch</code>
        /// <code>Type</code> other than HEADER, QUERY_STRING, or URI.</li> <li>You tried to update
        /// a <code>ByteMatchSet</code> with a <code>Field</code> of <code>HEADER</code> but no
        /// value for <code>Data</code>.</li> </ul>
        /// </exception>
        /// <exception cref="Amazon.WAF.Model.WAFLimitsExceededException">
        /// The operation exceeds a resource limit, for example, the maximum number of <code>WebACL</code>
        /// objects that you can create for an AWS account. For more information, see <a href="http://docs.aws.amazon.com/waf/latest/DeveloperGuide/limits.html">Limits</a>
        /// in the <i>AWS WAF Developer Guide</i>.
        /// </exception>
        /// <exception cref="Amazon.WAF.Model.WAFStaleDataException">
        /// The operation failed because you tried to create, update, or delete an object by using
        /// a change token that has already been used.
        /// </exception>
        public CreateByteMatchSetResponse CreateByteMatchSet(CreateByteMatchSetRequest request)
        {
            var marshaller = new CreateByteMatchSetRequestMarshaller();
            var unmarshaller = CreateByteMatchSetResponseUnmarshaller.Instance;

            return Invoke<CreateByteMatchSetRequest,CreateByteMatchSetResponse>(request, marshaller, unmarshaller);
        }
示例#4
0
 /// <summary>
 /// Creates a <code>ByteMatchSet</code>. You then use <a>UpdateByteMatchSet</a> to identify
 /// the part of a web request that you want AWS WAF to inspect, such as the values of
 /// the <code>User-Agent</code> header or the query string. For example, you can create
 /// a <code>ByteMatchSet</code> that matches any requests with <code>User-Agent</code>
 /// headers that contain the string <code>BadBot</code>. You can then configure AWS WAF
 /// to reject those requests.
 /// 
 ///  
 /// <para>
 /// To create and configure a <code>ByteMatchSet</code>, perform the following steps:
 /// </para>
 ///  <ol> <li>Use <a>GetChangeToken</a> to get the change token that you provide in the
 /// <code>ChangeToken</code> parameter of a <code>CreateByteMatchSet</code> request.</li>
 /// <li>Submit a <code>CreateByteMatchSet</code> request.</li> <li>Use <code>GetChangeToken</code>
 /// to get the change token that you provide in the <code>ChangeToken</code> parameter
 /// of an <code>UpdateByteMatchSet</code> request.</li> <li>Submit an <a>UpdateByteMatchSet</a>
 /// request to specify the part of the request that you want AWS WAF to inspect (for example,
 /// the header or the URI) and the value that you want AWS WAF to watch for.</li> </ol>
 /// 
 /// <para>
 /// For more information about how to use the AWS WAF API to allow or block HTTP requests,
 /// see the <a href="http://docs.aws.amazon.com/waf/latest/developerguide/">AWS WAF Developer
 /// Guide</a>.
 /// </para>
 /// </summary>
 /// <param name="name">A friendly name or description of the <a>ByteMatchSet</a>. You can't change <code>Name</code> after you create a <code>ByteMatchSet</code>.</param>
 /// <param name="changeToken">The value returned by the most recent call to <a>GetChangeToken</a>.</param>
 /// 
 /// <returns>The response from the CreateByteMatchSet service method, as returned by WAF.</returns>
 /// <exception cref="Amazon.WAF.Model.WAFDisallowedNameException">
 /// The name specified is invalid.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFInternalErrorException">
 /// The operation failed because of a system problem, even though the request was valid.
 /// Retry your request.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFInvalidAccountException">
 /// The operation failed because you tried to create, update, or delete an object by using
 /// an invalid account identifier.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFInvalidParameterException">
 /// The operation failed because AWS WAF didn't recognize a parameter in the request.
 /// For example:
 /// 
 ///  <ul> <li>You specified an invalid parameter name.</li> <li>You specified an invalid
 /// value.</li> <li>You tried to update an object (<code>ByteMatchSet</code>, <code>IPSet</code>,
 /// <code>Rule</code>, or <code>WebACL</code>) using an action other than <code>INSERT</code>
 /// or <code>DELETE</code>.</li> <li>You tried to create a <code>WebACL</code> with a
 /// <code>DefaultAction</code> <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>,
 /// or <code>COUNT</code>.</li> <li>You tried to update a <code>WebACL</code> with a <code>WafAction</code>
 /// <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>, or <code>COUNT</code>.</li>
 /// <li>You tried to update a <code>ByteMatchSet</code> with a <code>FieldToMatch</code>
 /// <code>Type</code> other than HEADER, QUERY_STRING, or URI.</li> <li>You tried to update
 /// a <code>ByteMatchSet</code> with a <code>Field</code> of <code>HEADER</code> but no
 /// value for <code>Data</code>.</li> </ul>
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFLimitsExceededException">
 /// The operation exceeds a resource limit, for example, the maximum number of <code>WebACL</code>
 /// objects that you can create for an AWS account. For more information, see <a href="http://docs.aws.amazon.com/waf/latest/DeveloperGuide/limits.html">Limits</a>
 /// in the <i>AWS WAF Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFStaleDataException">
 /// The operation failed because you tried to create, update, or delete an object by using
 /// a change token that has already been used.
 /// </exception>
 public CreateByteMatchSetResponse CreateByteMatchSet(string name, string changeToken)
 {
     var request = new CreateByteMatchSetRequest();
     request.Name = name;
     request.ChangeToken = changeToken;
     return CreateByteMatchSet(request);
 }
示例#5
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateByteMatchSet operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateByteMatchSet 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<CreateByteMatchSetResponse> CreateByteMatchSetAsync(CreateByteMatchSetRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateByteMatchSetRequestMarshaller();
            var unmarshaller = CreateByteMatchSetResponseUnmarshaller.Instance;

            return InvokeAsync<CreateByteMatchSetRequest,CreateByteMatchSetResponse>(request, marshaller,
                unmarshaller, cancellationToken);
        }
示例#6
0
 /// <summary>
 /// Creates a <code>ByteMatchSet</code>. You then use <a>UpdateByteMatchSet</a> to identify
 /// the part of a web request that you want AWS WAF to inspect, such as the values of
 /// the <code>User-Agent</code> header or the query string. For example, you can create
 /// a <code>ByteMatchSet</code> that matches any requests with <code>User-Agent</code>
 /// headers that contain the string <code>BadBot</code>. You can then configure AWS WAF
 /// to reject those requests.
 /// 
 ///  
 /// <para>
 /// To create and configure a <code>ByteMatchSet</code>, perform the following steps:
 /// </para>
 ///  <ol> <li>Use <a>GetChangeToken</a> to get the change token that you provide in the
 /// <code>ChangeToken</code> parameter of a <code>CreateByteMatchSet</code> request.</li>
 /// <li>Submit a <code>CreateByteMatchSet</code> request.</li> <li>Use <code>GetChangeToken</code>
 /// to get the change token that you provide in the <code>ChangeToken</code> parameter
 /// of an <code>UpdateByteMatchSet</code> request.</li> <li>Submit an <a>UpdateByteMatchSet</a>
 /// request to specify the part of the request that you want AWS WAF to inspect (for example,
 /// the header or the URI) and the value that you want AWS WAF to watch for.</li> </ol>
 /// 
 /// <para>
 /// For more information about how to use the AWS WAF API to allow or block HTTP requests,
 /// see the <a href="http://docs.aws.amazon.com/waf/latest/developerguide/">AWS WAF Developer
 /// Guide</a>.
 /// </para>
 /// </summary>
 /// <param name="name">A friendly name or description of the <a>ByteMatchSet</a>. You can't change <code>Name</code> after you create a <code>ByteMatchSet</code>.</param>
 /// <param name="changeToken">The value returned by the most recent call to <a>GetChangeToken</a>.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the CreateByteMatchSet service method, as returned by WAF.</returns>
 /// <exception cref="Amazon.WAF.Model.WAFDisallowedNameException">
 /// The name specified is invalid.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFInternalErrorException">
 /// The operation failed because of a system problem, even though the request was valid.
 /// Retry your request.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFInvalidAccountException">
 /// The operation failed because you tried to create, update, or delete an object by using
 /// an invalid account identifier.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFInvalidParameterException">
 /// The operation failed because AWS WAF didn't recognize a parameter in the request.
 /// For example:
 /// 
 ///  <ul> <li>You specified an invalid parameter name.</li> <li>You specified an invalid
 /// value.</li> <li>You tried to update an object (<code>ByteMatchSet</code>, <code>IPSet</code>,
 /// <code>Rule</code>, or <code>WebACL</code>) using an action other than <code>INSERT</code>
 /// or <code>DELETE</code>.</li> <li>You tried to create a <code>WebACL</code> with a
 /// <code>DefaultAction</code> <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>,
 /// or <code>COUNT</code>.</li> <li>You tried to update a <code>WebACL</code> with a <code>WafAction</code>
 /// <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>, or <code>COUNT</code>.</li>
 /// <li>You tried to update a <code>ByteMatchSet</code> with a <code>FieldToMatch</code>
 /// <code>Type</code> other than HEADER, QUERY_STRING, or URI.</li> <li>You tried to update
 /// a <code>ByteMatchSet</code> with a <code>Field</code> of <code>HEADER</code> but no
 /// value for <code>Data</code>.</li> </ul>
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFLimitsExceededException">
 /// The operation exceeds a resource limit, for example, the maximum number of <code>WebACL</code>
 /// objects that you can create for an AWS account. For more information, see <a href="http://docs.aws.amazon.com/waf/latest/developerguide/limits.html">Limits</a>
 /// in the <i>AWS WAF Developer Guide</i>.
 /// </exception>
 /// <exception cref="Amazon.WAF.Model.WAFStaleDataException">
 /// The operation failed because you tried to create, update, or delete an object by using
 /// a change token that has already been used.
 /// </exception>
 public Task<CreateByteMatchSetResponse> CreateByteMatchSetAsync(string name, string changeToken, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new CreateByteMatchSetRequest();
     request.Name = name;
     request.ChangeToken = changeToken;
     return CreateByteMatchSetAsync(request, cancellationToken);
 }
 private Amazon.WAF.Model.CreateByteMatchSetResponse CallAWSServiceOperation(IAmazonWAF client, Amazon.WAF.Model.CreateByteMatchSetRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS WAF", "CreateByteMatchSet");
     try
     {
         #if DESKTOP
         return(client.CreateByteMatchSet(request));
         #elif CORECLR
         return(client.CreateByteMatchSetAsync(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;
     }
 }