All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.wafv2.model.HTTPRequest Maven / Gradle / Ivy

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.wafv2.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 
 * 

* This is the latest version of AWS WAF, named AWS WAFV2, released in November, 2019. For information, including * how to migrate your AWS WAF resources from the prior release, see the AWS WAF Developer Guide. *

*
*

* Part of the response from GetSampledRequests. This is a complex type that appears as Request in * the response syntax. HTTPRequest contains information about one of the web requests. *

*/ @Generated("software.amazon.awssdk:codegen") public final class HTTPRequest implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField CLIENT_IP_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ClientIP").getter(getter(HTTPRequest::clientIP)).setter(setter(Builder::clientIP)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientIP").build()).build(); private static final SdkField COUNTRY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Country") .getter(getter(HTTPRequest::country)).setter(setter(Builder::country)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Country").build()).build(); private static final SdkField URI_FIELD = SdkField. builder(MarshallingType.STRING).memberName("URI") .getter(getter(HTTPRequest::uri)).setter(setter(Builder::uri)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("URI").build()).build(); private static final SdkField METHOD_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Method") .getter(getter(HTTPRequest::method)).setter(setter(Builder::method)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Method").build()).build(); private static final SdkField HTTP_VERSION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("HTTPVersion").getter(getter(HTTPRequest::httpVersion)).setter(setter(Builder::httpVersion)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HTTPVersion").build()).build(); private static final SdkField> HEADERS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Headers") .getter(getter(HTTPRequest::headers)) .setter(setter(Builder::headers)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Headers").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(HTTPHeader::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CLIENT_IP_FIELD, COUNTRY_FIELD, URI_FIELD, METHOD_FIELD, HTTP_VERSION_FIELD, HEADERS_FIELD)); private static final long serialVersionUID = 1L; private final String clientIP; private final String country; private final String uri; private final String method; private final String httpVersion; private final List headers; private HTTPRequest(BuilderImpl builder) { this.clientIP = builder.clientIP; this.country = builder.country; this.uri = builder.uri; this.method = builder.method; this.httpVersion = builder.httpVersion; this.headers = builder.headers; } /** *

* The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, * this is the value of one of the following fields in CloudFront access logs: *

*
    *
  • *

    * c-ip, if the viewer did not use an HTTP proxy or a load balancer to send the request *

    *
  • *
  • *

    * x-forwarded-for, if the viewer did use an HTTP proxy or a load balancer to send the request *

    *
  • *
* * @return The IP address that the request originated from. If the web ACL is associated with a CloudFront * distribution, this is the value of one of the following fields in CloudFront access logs:

*
    *
  • *

    * c-ip, if the viewer did not use an HTTP proxy or a load balancer to send the request *

    *
  • *
  • *

    * x-forwarded-for, if the viewer did use an HTTP proxy or a load balancer to send the request *

    *
  • */ public String clientIP() { return clientIP; } /** *

    * The two-letter country code for the country that the request originated from. For a current list of country * codes, see the Wikipedia entry ISO 3166-1 alpha-2. *

    * * @return The two-letter country code for the country that the request originated from. For a current list of * country codes, see the Wikipedia entry ISO * 3166-1 alpha-2. */ public String country() { return country; } /** *

    * The URI path of the request, which identifies the resource, for example, /images/daily-ad.jpg. *

    * * @return The URI path of the request, which identifies the resource, for example, * /images/daily-ad.jpg. */ public String uri() { return uri; } /** *

    * The HTTP method specified in the sampled web request. *

    * * @return The HTTP method specified in the sampled web request. */ public String method() { return method; } /** *

    * The HTTP version specified in the sampled web request, for example, HTTP/1.1. *

    * * @return The HTTP version specified in the sampled web request, for example, HTTP/1.1. */ public String httpVersion() { return httpVersion; } /** * Returns true if the Headers property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public boolean hasHeaders() { return headers != null && !(headers instanceof SdkAutoConstructList); } /** *

    * A complex type that contains the name and value for each header in the sampled web request. *

    *

    * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

    *

    * You can use {@link #hasHeaders()} to see if a value was sent in this field. *

    * * @return A complex type that contains the name and value for each header in the sampled web request. */ public List headers() { return headers; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(clientIP()); hashCode = 31 * hashCode + Objects.hashCode(country()); hashCode = 31 * hashCode + Objects.hashCode(uri()); hashCode = 31 * hashCode + Objects.hashCode(method()); hashCode = 31 * hashCode + Objects.hashCode(httpVersion()); hashCode = 31 * hashCode + Objects.hashCode(headers()); return hashCode; } @Override public boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof HTTPRequest)) { return false; } HTTPRequest other = (HTTPRequest) obj; return Objects.equals(clientIP(), other.clientIP()) && Objects.equals(country(), other.country()) && Objects.equals(uri(), other.uri()) && Objects.equals(method(), other.method()) && Objects.equals(httpVersion(), other.httpVersion()) && Objects.equals(headers(), other.headers()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public String toString() { return ToString.builder("HTTPRequest").add("ClientIP", clientIP()).add("Country", country()).add("URI", uri()) .add("Method", method()).add("HTTPVersion", httpVersion()).add("Headers", headers()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ClientIP": return Optional.ofNullable(clazz.cast(clientIP())); case "Country": return Optional.ofNullable(clazz.cast(country())); case "URI": return Optional.ofNullable(clazz.cast(uri())); case "Method": return Optional.ofNullable(clazz.cast(method())); case "HTTPVersion": return Optional.ofNullable(clazz.cast(httpVersion())); case "Headers": return Optional.ofNullable(clazz.cast(headers())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((HTTPRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

    * The IP address that the request originated from. If the web ACL is associated with a CloudFront distribution, * this is the value of one of the following fields in CloudFront access logs: *

    *
      *
    • *

      * c-ip, if the viewer did not use an HTTP proxy or a load balancer to send the request *

      *
    • *
    • *

      * x-forwarded-for, if the viewer did use an HTTP proxy or a load balancer to send the request *

      *
    • *
    * * @param clientIP * The IP address that the request originated from. If the web ACL is associated with a CloudFront * distribution, this is the value of one of the following fields in CloudFront access logs:

    *
      *
    • *

      * c-ip, if the viewer did not use an HTTP proxy or a load balancer to send the request *

      *
    • *
    • *

      * x-forwarded-for, if the viewer did use an HTTP proxy or a load balancer to send the * request *

      *
    • * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientIP(String clientIP); /** *

      * The two-letter country code for the country that the request originated from. For a current list of country * codes, see the Wikipedia entry ISO 3166-1 * alpha-2. *

      * * @param country * The two-letter country code for the country that the request originated from. For a current list of * country codes, see the Wikipedia entry ISO * 3166-1 alpha-2. * @return Returns a reference to this object so that method calls can be chained together. */ Builder country(String country); /** *

      * The URI path of the request, which identifies the resource, for example, /images/daily-ad.jpg. *

      * * @param uri * The URI path of the request, which identifies the resource, for example, * /images/daily-ad.jpg. * @return Returns a reference to this object so that method calls can be chained together. */ Builder uri(String uri); /** *

      * The HTTP method specified in the sampled web request. *

      * * @param method * The HTTP method specified in the sampled web request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder method(String method); /** *

      * The HTTP version specified in the sampled web request, for example, HTTP/1.1. *

      * * @param httpVersion * The HTTP version specified in the sampled web request, for example, HTTP/1.1. * @return Returns a reference to this object so that method calls can be chained together. */ Builder httpVersion(String httpVersion); /** *

      * A complex type that contains the name and value for each header in the sampled web request. *

      * * @param headers * A complex type that contains the name and value for each header in the sampled web request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder headers(Collection headers); /** *

      * A complex type that contains the name and value for each header in the sampled web request. *

      * * @param headers * A complex type that contains the name and value for each header in the sampled web request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder headers(HTTPHeader... headers); /** *

      * A complex type that contains the name and value for each header in the sampled web request. *

      * This is a convenience that creates an instance of the {@link List.Builder} avoiding the need to * create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its * result is passed to {@link #headers(List)}. * * @param headers * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #headers(List) */ Builder headers(Consumer... headers); } static final class BuilderImpl implements Builder { private String clientIP; private String country; private String uri; private String method; private String httpVersion; private List headers = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(HTTPRequest model) { clientIP(model.clientIP); country(model.country); uri(model.uri); method(model.method); httpVersion(model.httpVersion); headers(model.headers); } public final String getClientIP() { return clientIP; } @Override public final Builder clientIP(String clientIP) { this.clientIP = clientIP; return this; } public final void setClientIP(String clientIP) { this.clientIP = clientIP; } public final String getCountry() { return country; } @Override public final Builder country(String country) { this.country = country; return this; } public final void setCountry(String country) { this.country = country; } public final String getUri() { return uri; } @Override public final Builder uri(String uri) { this.uri = uri; return this; } public final void setUri(String uri) { this.uri = uri; } public final String getMethod() { return method; } @Override public final Builder method(String method) { this.method = method; return this; } public final void setMethod(String method) { this.method = method; } public final String getHttpVersion() { return httpVersion; } @Override public final Builder httpVersion(String httpVersion) { this.httpVersion = httpVersion; return this; } public final void setHttpVersion(String httpVersion) { this.httpVersion = httpVersion; } public final Collection getHeaders() { return headers != null ? headers.stream().map(HTTPHeader::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder headers(Collection headers) { this.headers = HTTPHeadersCopier.copy(headers); return this; } @Override @SafeVarargs public final Builder headers(HTTPHeader... headers) { headers(Arrays.asList(headers)); return this; } @Override @SafeVarargs public final Builder headers(Consumer... headers) { headers(Stream.of(headers).map(c -> HTTPHeader.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setHeaders(Collection headers) { this.headers = HTTPHeadersCopier.copyFromBuilder(headers); } @Override public HTTPRequest build() { return new HTTPRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy