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

software.amazon.awssdk.services.iot.model.CreateAuthorizerRequest 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.iot.model;

import java.beans.Transient;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
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.awscore.AwsRequestOverrideConfiguration;
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.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateAuthorizerRequest extends IotRequest implements
        ToCopyableBuilder {
    private static final SdkField AUTHORIZER_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("authorizerName").getter(getter(CreateAuthorizerRequest::authorizerName))
            .setter(setter(Builder::authorizerName))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("authorizerName").build()).build();

    private static final SdkField AUTHORIZER_FUNCTION_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("authorizerFunctionArn").getter(getter(CreateAuthorizerRequest::authorizerFunctionArn))
            .setter(setter(Builder::authorizerFunctionArn))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("authorizerFunctionArn").build())
            .build();

    private static final SdkField TOKEN_KEY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("tokenKeyName").getter(getter(CreateAuthorizerRequest::tokenKeyName))
            .setter(setter(Builder::tokenKeyName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tokenKeyName").build()).build();

    private static final SdkField> TOKEN_SIGNING_PUBLIC_KEYS_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("tokenSigningPublicKeys")
            .getter(getter(CreateAuthorizerRequest::tokenSigningPublicKeys))
            .setter(setter(Builder::tokenSigningPublicKeys))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tokenSigningPublicKeys").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
            .getter(getter(CreateAuthorizerRequest::statusAsString)).setter(setter(Builder::status))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();

    private static final SdkField> TAGS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("tags")
            .getter(getter(CreateAuthorizerRequest::tags))
            .setter(setter(Builder::tags))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(Tag::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField SIGNING_DISABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
            .memberName("signingDisabled").getter(getter(CreateAuthorizerRequest::signingDisabled))
            .setter(setter(Builder::signingDisabled))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("signingDisabled").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AUTHORIZER_NAME_FIELD,
            AUTHORIZER_FUNCTION_ARN_FIELD, TOKEN_KEY_NAME_FIELD, TOKEN_SIGNING_PUBLIC_KEYS_FIELD, STATUS_FIELD, TAGS_FIELD,
            SIGNING_DISABLED_FIELD));

    private final String authorizerName;

    private final String authorizerFunctionArn;

    private final String tokenKeyName;

    private final Map tokenSigningPublicKeys;

    private final String status;

    private final List tags;

    private final Boolean signingDisabled;

    private CreateAuthorizerRequest(BuilderImpl builder) {
        super(builder);
        this.authorizerName = builder.authorizerName;
        this.authorizerFunctionArn = builder.authorizerFunctionArn;
        this.tokenKeyName = builder.tokenKeyName;
        this.tokenSigningPublicKeys = builder.tokenSigningPublicKeys;
        this.status = builder.status;
        this.tags = builder.tags;
        this.signingDisabled = builder.signingDisabled;
    }

    /**
     * 

* The authorizer name. *

* * @return The authorizer name. */ public final String authorizerName() { return authorizerName; } /** *

* The ARN of the authorizer's Lambda function. *

* * @return The ARN of the authorizer's Lambda function. */ public final String authorizerFunctionArn() { return authorizerFunctionArn; } /** *

* The name of the token key used to extract the token from the HTTP headers. *

* * @return The name of the token key used to extract the token from the HTTP headers. */ public final String tokenKeyName() { return tokenKeyName; } /** * For responses, this returns true if the service returned a value for the TokenSigningPublicKeys 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 hasTokenSigningPublicKeys() { return tokenSigningPublicKeys != null && !(tokenSigningPublicKeys instanceof SdkAutoConstructMap); } /** *

* The public keys used to verify the digital signature returned by your custom authentication service. *

*

* 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 #hasTokenSigningPublicKeys} method. *

* * @return The public keys used to verify the digital signature returned by your custom authentication service. */ public final Map tokenSigningPublicKeys() { return tokenSigningPublicKeys; } /** *

* The status of the create authorizer request. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link AuthorizerStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusAsString}. *

* * @return The status of the create authorizer request. * @see AuthorizerStatus */ public final AuthorizerStatus status() { return AuthorizerStatus.fromValue(status); } /** *

* The status of the create authorizer request. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link AuthorizerStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusAsString}. *

* * @return The status of the create authorizer request. * @see AuthorizerStatus */ public final String statusAsString() { return status; } /** * For responses, this returns true if the service returned a value for the Tags 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 hasTags() { return tags != null && !(tags instanceof SdkAutoConstructList); } /** *

* Metadata which can be used to manage the custom authorizer. *

* *

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

*
*

* 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 #hasTags} method. *

* * @return Metadata which can be used to manage the custom authorizer.

*

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

*/ public final List tags() { return tags; } /** *

* Specifies whether AWS IoT validates the token signature in an authorization request. *

* * @return Specifies whether AWS IoT validates the token signature in an authorization request. */ public final Boolean signingDisabled() { return signingDisabled; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(authorizerName()); hashCode = 31 * hashCode + Objects.hashCode(authorizerFunctionArn()); hashCode = 31 * hashCode + Objects.hashCode(tokenKeyName()); hashCode = 31 * hashCode + Objects.hashCode(hasTokenSigningPublicKeys() ? tokenSigningPublicKeys() : null); hashCode = 31 * hashCode + Objects.hashCode(statusAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); hashCode = 31 * hashCode + Objects.hashCode(signingDisabled()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateAuthorizerRequest)) { return false; } CreateAuthorizerRequest other = (CreateAuthorizerRequest) obj; return Objects.equals(authorizerName(), other.authorizerName()) && Objects.equals(authorizerFunctionArn(), other.authorizerFunctionArn()) && Objects.equals(tokenKeyName(), other.tokenKeyName()) && hasTokenSigningPublicKeys() == other.hasTokenSigningPublicKeys() && Objects.equals(tokenSigningPublicKeys(), other.tokenSigningPublicKeys()) && Objects.equals(statusAsString(), other.statusAsString()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()) && Objects.equals(signingDisabled(), other.signingDisabled()); } /** * 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("CreateAuthorizerRequest").add("AuthorizerName", authorizerName()) .add("AuthorizerFunctionArn", authorizerFunctionArn()).add("TokenKeyName", tokenKeyName()) .add("TokenSigningPublicKeys", hasTokenSigningPublicKeys() ? tokenSigningPublicKeys() : null) .add("Status", statusAsString()).add("Tags", hasTags() ? tags() : null).add("SigningDisabled", signingDisabled()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "authorizerName": return Optional.ofNullable(clazz.cast(authorizerName())); case "authorizerFunctionArn": return Optional.ofNullable(clazz.cast(authorizerFunctionArn())); case "tokenKeyName": return Optional.ofNullable(clazz.cast(tokenKeyName())); case "tokenSigningPublicKeys": return Optional.ofNullable(clazz.cast(tokenSigningPublicKeys())); case "status": return Optional.ofNullable(clazz.cast(statusAsString())); case "tags": return Optional.ofNullable(clazz.cast(tags())); case "signingDisabled": return Optional.ofNullable(clazz.cast(signingDisabled())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateAuthorizerRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends IotRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The authorizer name. *

* * @param authorizerName * The authorizer name. * @return Returns a reference to this object so that method calls can be chained together. */ Builder authorizerName(String authorizerName); /** *

* The ARN of the authorizer's Lambda function. *

* * @param authorizerFunctionArn * The ARN of the authorizer's Lambda function. * @return Returns a reference to this object so that method calls can be chained together. */ Builder authorizerFunctionArn(String authorizerFunctionArn); /** *

* The name of the token key used to extract the token from the HTTP headers. *

* * @param tokenKeyName * The name of the token key used to extract the token from the HTTP headers. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tokenKeyName(String tokenKeyName); /** *

* The public keys used to verify the digital signature returned by your custom authentication service. *

* * @param tokenSigningPublicKeys * The public keys used to verify the digital signature returned by your custom authentication service. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tokenSigningPublicKeys(Map tokenSigningPublicKeys); /** *

* The status of the create authorizer request. *

* * @param status * The status of the create authorizer request. * @see AuthorizerStatus * @return Returns a reference to this object so that method calls can be chained together. * @see AuthorizerStatus */ Builder status(String status); /** *

* The status of the create authorizer request. *

* * @param status * The status of the create authorizer request. * @see AuthorizerStatus * @return Returns a reference to this object so that method calls can be chained together. * @see AuthorizerStatus */ Builder status(AuthorizerStatus status); /** *

* Metadata which can be used to manage the custom authorizer. *

* *

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

*
* * @param tags * Metadata which can be used to manage the custom authorizer.

*

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

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

* Metadata which can be used to manage the custom authorizer. *

* *

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

*
* * @param tags * Metadata which can be used to manage the custom authorizer.

*

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

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

* Metadata which can be used to manage the custom authorizer. *

* *

* For URI Request parameters use format: ...key1=value1&key2=value2... *

*

* For the CLI command-line parameter use format: &&tags "key1=value1&key2=value2..." *

*

* For the cli-input-json file use format: "tags": "key1=value1&key2=value2..." *

*
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 #tags(List)}. * * @param tags * 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 #tags(List) */ Builder tags(Consumer... tags); /** *

* Specifies whether AWS IoT validates the token signature in an authorization request. *

* * @param signingDisabled * Specifies whether AWS IoT validates the token signature in an authorization request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder signingDisabled(Boolean signingDisabled); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends IotRequest.BuilderImpl implements Builder { private String authorizerName; private String authorizerFunctionArn; private String tokenKeyName; private Map tokenSigningPublicKeys = DefaultSdkAutoConstructMap.getInstance(); private String status; private List tags = DefaultSdkAutoConstructList.getInstance(); private Boolean signingDisabled; private BuilderImpl() { } private BuilderImpl(CreateAuthorizerRequest model) { super(model); authorizerName(model.authorizerName); authorizerFunctionArn(model.authorizerFunctionArn); tokenKeyName(model.tokenKeyName); tokenSigningPublicKeys(model.tokenSigningPublicKeys); status(model.status); tags(model.tags); signingDisabled(model.signingDisabled); } public final String getAuthorizerName() { return authorizerName; } public final void setAuthorizerName(String authorizerName) { this.authorizerName = authorizerName; } @Override @Transient public final Builder authorizerName(String authorizerName) { this.authorizerName = authorizerName; return this; } public final String getAuthorizerFunctionArn() { return authorizerFunctionArn; } public final void setAuthorizerFunctionArn(String authorizerFunctionArn) { this.authorizerFunctionArn = authorizerFunctionArn; } @Override @Transient public final Builder authorizerFunctionArn(String authorizerFunctionArn) { this.authorizerFunctionArn = authorizerFunctionArn; return this; } public final String getTokenKeyName() { return tokenKeyName; } public final void setTokenKeyName(String tokenKeyName) { this.tokenKeyName = tokenKeyName; } @Override @Transient public final Builder tokenKeyName(String tokenKeyName) { this.tokenKeyName = tokenKeyName; return this; } public final Map getTokenSigningPublicKeys() { if (tokenSigningPublicKeys instanceof SdkAutoConstructMap) { return null; } return tokenSigningPublicKeys; } public final void setTokenSigningPublicKeys(Map tokenSigningPublicKeys) { this.tokenSigningPublicKeys = PublicKeyMapCopier.copy(tokenSigningPublicKeys); } @Override @Transient public final Builder tokenSigningPublicKeys(Map tokenSigningPublicKeys) { this.tokenSigningPublicKeys = PublicKeyMapCopier.copy(tokenSigningPublicKeys); return this; } public final String getStatus() { return status; } public final void setStatus(String status) { this.status = status; } @Override @Transient public final Builder status(String status) { this.status = status; return this; } @Override @Transient public final Builder status(AuthorizerStatus status) { this.status(status == null ? null : status.toString()); return this; } public final List getTags() { List result = TagListCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = TagListCopier.copyFromBuilder(tags); } @Override @Transient public final Builder tags(Collection tags) { this.tags = TagListCopier.copy(tags); return this; } @Override @Transient @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @Transient @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final Boolean getSigningDisabled() { return signingDisabled; } public final void setSigningDisabled(Boolean signingDisabled) { this.signingDisabled = signingDisabled; } @Override @Transient public final Builder signingDisabled(Boolean signingDisabled) { this.signingDisabled = signingDisabled; return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateAuthorizerRequest build() { return new CreateAuthorizerRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy