software.amazon.awssdk.services.iot.model.HttpAction Maven / Gradle / Ivy
Show all versions of iot Show documentation
/*
* 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.iot.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
*
* Send data to an HTTPS endpoint.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class HttpAction implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField URL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("url")
.getter(getter(HttpAction::url)).setter(setter(Builder::url))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("url").build()).build();
private static final SdkField CONFIRMATION_URL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("confirmationUrl").getter(getter(HttpAction::confirmationUrl)).setter(setter(Builder::confirmationUrl))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("confirmationUrl").build()).build();
private static final SdkField> HEADERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("headers")
.getter(getter(HttpAction::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(HttpActionHeader::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField AUTH_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("auth").getter(getter(HttpAction::auth)).setter(setter(Builder::auth))
.constructor(HttpAuthorization::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("auth").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(URL_FIELD,
CONFIRMATION_URL_FIELD, HEADERS_FIELD, AUTH_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String url;
private final String confirmationUrl;
private final List headers;
private final HttpAuthorization auth;
private HttpAction(BuilderImpl builder) {
this.url = builder.url;
this.confirmationUrl = builder.confirmationUrl;
this.headers = builder.headers;
this.auth = builder.auth;
}
/**
*
* The endpoint URL. If substitution templates are used in the URL, you must also specify a
* confirmationUrl
. If this is a new destination, a new TopicRuleDestination
is created if
* possible.
*
*
* @return The endpoint URL. If substitution templates are used in the URL, you must also specify a
* confirmationUrl
. If this is a new destination, a new TopicRuleDestination
is
* created if possible.
*/
public final String url() {
return url;
}
/**
*
* The URL to which IoT sends a confirmation message. The value of the confirmation URL must be a prefix of the
* endpoint URL. If you do not specify a confirmation URL IoT uses the endpoint URL as the confirmation URL. If you
* use substitution templates in the confirmationUrl, you must create and enable topic rule destinations that match
* each possible value of the substitution template before traffic is allowed to your endpoint URL.
*
*
* @return The URL to which IoT sends a confirmation message. The value of the confirmation URL must be a prefix of
* the endpoint URL. If you do not specify a confirmation URL IoT uses the endpoint URL as the confirmation
* URL. If you use substitution templates in the confirmationUrl, you must create and enable topic rule
* destinations that match each possible value of the substitution template before traffic is allowed to
* your endpoint URL.
*/
public final String confirmationUrl() {
return confirmationUrl;
}
/**
* For responses, this returns true if the service returned a value for the Headers property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasHeaders() {
return headers != null && !(headers instanceof SdkAutoConstructList);
}
/**
*
* The HTTP headers to send with the message data.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasHeaders} method.
*
*
* @return The HTTP headers to send with the message data.
*/
public final List headers() {
return headers;
}
/**
*
* The authentication method to use when sending data to an HTTPS endpoint.
*
*
* @return The authentication method to use when sending data to an HTTPS endpoint.
*/
public final HttpAuthorization auth() {
return auth;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(url());
hashCode = 31 * hashCode + Objects.hashCode(confirmationUrl());
hashCode = 31 * hashCode + Objects.hashCode(hasHeaders() ? headers() : null);
hashCode = 31 * hashCode + Objects.hashCode(auth());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof HttpAction)) {
return false;
}
HttpAction other = (HttpAction) obj;
return Objects.equals(url(), other.url()) && Objects.equals(confirmationUrl(), other.confirmationUrl())
&& hasHeaders() == other.hasHeaders() && Objects.equals(headers(), other.headers())
&& Objects.equals(auth(), other.auth());
}
/**
* 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 final String toString() {
return ToString.builder("HttpAction").add("Url", url()).add("ConfirmationUrl", confirmationUrl())
.add("Headers", hasHeaders() ? headers() : null).add("Auth", auth()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "url":
return Optional.ofNullable(clazz.cast(url()));
case "confirmationUrl":
return Optional.ofNullable(clazz.cast(confirmationUrl()));
case "headers":
return Optional.ofNullable(clazz.cast(headers()));
case "auth":
return Optional.ofNullable(clazz.cast(auth()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("url", URL_FIELD);
map.put("confirmationUrl", CONFIRMATION_URL_FIELD);
map.put("headers", HEADERS_FIELD);
map.put("auth", AUTH_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function