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

software.amazon.awssdk.services.ssooidc.model.CreateTokenRequest Maven / Gradle / Ivy

/*
 * Copyright 2015-2020 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.ssooidc.model;

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 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.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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateTokenRequest extends SsoOidcRequest implements
        ToCopyableBuilder {
    private static final SdkField CLIENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::clientId)).setter(setter(Builder::clientId))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clientId").build()).build();

    private static final SdkField CLIENT_SECRET_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::clientSecret)).setter(setter(Builder::clientSecret))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clientSecret").build()).build();

    private static final SdkField GRANT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::grantType)).setter(setter(Builder::grantType))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("grantType").build()).build();

    private static final SdkField DEVICE_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::deviceCode)).setter(setter(Builder::deviceCode))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("deviceCode").build()).build();

    private static final SdkField CODE_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::code)).setter(setter(Builder::code))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("code").build()).build();

    private static final SdkField REFRESH_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::refreshToken)).setter(setter(Builder::refreshToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("refreshToken").build()).build();

    private static final SdkField> SCOPE_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .getter(getter(CreateTokenRequest::scope))
            .setter(setter(Builder::scope))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("scope").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField REDIRECT_URI_FIELD = SdkField. builder(MarshallingType.STRING)
            .getter(getter(CreateTokenRequest::redirectUri)).setter(setter(Builder::redirectUri))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("redirectUri").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CLIENT_ID_FIELD,
            CLIENT_SECRET_FIELD, GRANT_TYPE_FIELD, DEVICE_CODE_FIELD, CODE_FIELD, REFRESH_TOKEN_FIELD, SCOPE_FIELD,
            REDIRECT_URI_FIELD));

    private final String clientId;

    private final String clientSecret;

    private final String grantType;

    private final String deviceCode;

    private final String code;

    private final String refreshToken;

    private final List scope;

    private final String redirectUri;

    private CreateTokenRequest(BuilderImpl builder) {
        super(builder);
        this.clientId = builder.clientId;
        this.clientSecret = builder.clientSecret;
        this.grantType = builder.grantType;
        this.deviceCode = builder.deviceCode;
        this.code = builder.code;
        this.refreshToken = builder.refreshToken;
        this.scope = builder.scope;
        this.redirectUri = builder.redirectUri;
    }

    /**
     * 

* The unique identifier string for each client. This value should come from the persisted result of the * RegisterClient API. *

* * @return The unique identifier string for each client. This value should come from the persisted result of the * RegisterClient API. */ public String clientId() { return clientId; } /** *

* A secret string generated for the client. This value should come from the persisted result of the * RegisterClient API. *

* * @return A secret string generated for the client. This value should come from the persisted result of the * RegisterClient API. */ public String clientSecret() { return clientSecret; } /** *

* Supports grant types for authorization code, refresh token, and device code request. *

* * @return Supports grant types for authorization code, refresh token, and device code request. */ public String grantType() { return grantType; } /** *

* Used only when calling this API for the device code grant type. This short-term code is used to identify this * authentication attempt. This should come from an in-memory reference to the result of the * StartDeviceAuthorization API. *

* * @return Used only when calling this API for the device code grant type. This short-term code is used to identify * this authentication attempt. This should come from an in-memory reference to the result of the * StartDeviceAuthorization API. */ public String deviceCode() { return deviceCode; } /** *

* The authorization code received from the authorization service. This parameter is required to perform an * authorization grant request to get access to a token. *

* * @return The authorization code received from the authorization service. This parameter is required to perform an * authorization grant request to get access to a token. */ public String code() { return code; } /** *

* The token used to obtain an access token in the event that the access token is invalid or expired. This token is * not issued by the service. *

* * @return The token used to obtain an access token in the event that the access token is invalid or expired. This * token is not issued by the service. */ public String refreshToken() { return refreshToken; } /** * Returns true if the Scope 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 hasScope() { return scope != null && !(scope instanceof SdkAutoConstructList); } /** *

* The list of scopes that is defined by the client. Upon authorization, this list is used to restrict permissions * when granting an access token. *

*

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

*

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

* * @return The list of scopes that is defined by the client. Upon authorization, this list is used to restrict * permissions when granting an access token. */ public List scope() { return scope; } /** *

* The location of the application that will receive the authorization code. Users authorize the service to send the * request to this location. *

* * @return The location of the application that will receive the authorization code. Users authorize the service to * send the request to this location. */ public String redirectUri() { return redirectUri; } @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 + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(clientId()); hashCode = 31 * hashCode + Objects.hashCode(clientSecret()); hashCode = 31 * hashCode + Objects.hashCode(grantType()); hashCode = 31 * hashCode + Objects.hashCode(deviceCode()); hashCode = 31 * hashCode + Objects.hashCode(code()); hashCode = 31 * hashCode + Objects.hashCode(refreshToken()); hashCode = 31 * hashCode + Objects.hashCode(scope()); hashCode = 31 * hashCode + Objects.hashCode(redirectUri()); return hashCode; } @Override public boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateTokenRequest)) { return false; } CreateTokenRequest other = (CreateTokenRequest) obj; return Objects.equals(clientId(), other.clientId()) && Objects.equals(clientSecret(), other.clientSecret()) && Objects.equals(grantType(), other.grantType()) && Objects.equals(deviceCode(), other.deviceCode()) && Objects.equals(code(), other.code()) && Objects.equals(refreshToken(), other.refreshToken()) && Objects.equals(scope(), other.scope()) && Objects.equals(redirectUri(), other.redirectUri()); } /** * 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("CreateTokenRequest").add("ClientId", clientId()).add("ClientSecret", clientSecret()) .add("GrantType", grantType()).add("DeviceCode", deviceCode()).add("Code", code()) .add("RefreshToken", refreshToken()).add("Scope", scope()).add("RedirectUri", redirectUri()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "clientId": return Optional.ofNullable(clazz.cast(clientId())); case "clientSecret": return Optional.ofNullable(clazz.cast(clientSecret())); case "grantType": return Optional.ofNullable(clazz.cast(grantType())); case "deviceCode": return Optional.ofNullable(clazz.cast(deviceCode())); case "code": return Optional.ofNullable(clazz.cast(code())); case "refreshToken": return Optional.ofNullable(clazz.cast(refreshToken())); case "scope": return Optional.ofNullable(clazz.cast(scope())); case "redirectUri": return Optional.ofNullable(clazz.cast(redirectUri())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateTokenRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SsoOidcRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The unique identifier string for each client. This value should come from the persisted result of the * RegisterClient API. *

* * @param clientId * The unique identifier string for each client. This value should come from the persisted result of the * RegisterClient API. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientId(String clientId); /** *

* A secret string generated for the client. This value should come from the persisted result of the * RegisterClient API. *

* * @param clientSecret * A secret string generated for the client. This value should come from the persisted result of the * RegisterClient API. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientSecret(String clientSecret); /** *

* Supports grant types for authorization code, refresh token, and device code request. *

* * @param grantType * Supports grant types for authorization code, refresh token, and device code request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder grantType(String grantType); /** *

* Used only when calling this API for the device code grant type. This short-term code is used to identify this * authentication attempt. This should come from an in-memory reference to the result of the * StartDeviceAuthorization API. *

* * @param deviceCode * Used only when calling this API for the device code grant type. This short-term code is used to * identify this authentication attempt. This should come from an in-memory reference to the result of * the StartDeviceAuthorization API. * @return Returns a reference to this object so that method calls can be chained together. */ Builder deviceCode(String deviceCode); /** *

* The authorization code received from the authorization service. This parameter is required to perform an * authorization grant request to get access to a token. *

* * @param code * The authorization code received from the authorization service. This parameter is required to perform * an authorization grant request to get access to a token. * @return Returns a reference to this object so that method calls can be chained together. */ Builder code(String code); /** *

* The token used to obtain an access token in the event that the access token is invalid or expired. This token * is not issued by the service. *

* * @param refreshToken * The token used to obtain an access token in the event that the access token is invalid or expired. * This token is not issued by the service. * @return Returns a reference to this object so that method calls can be chained together. */ Builder refreshToken(String refreshToken); /** *

* The list of scopes that is defined by the client. Upon authorization, this list is used to restrict * permissions when granting an access token. *

* * @param scope * The list of scopes that is defined by the client. Upon authorization, this list is used to restrict * permissions when granting an access token. * @return Returns a reference to this object so that method calls can be chained together. */ Builder scope(Collection scope); /** *

* The list of scopes that is defined by the client. Upon authorization, this list is used to restrict * permissions when granting an access token. *

* * @param scope * The list of scopes that is defined by the client. Upon authorization, this list is used to restrict * permissions when granting an access token. * @return Returns a reference to this object so that method calls can be chained together. */ Builder scope(String... scope); /** *

* The location of the application that will receive the authorization code. Users authorize the service to send * the request to this location. *

* * @param redirectUri * The location of the application that will receive the authorization code. Users authorize the service * to send the request to this location. * @return Returns a reference to this object so that method calls can be chained together. */ Builder redirectUri(String redirectUri); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends SsoOidcRequest.BuilderImpl implements Builder { private String clientId; private String clientSecret; private String grantType; private String deviceCode; private String code; private String refreshToken; private List scope = DefaultSdkAutoConstructList.getInstance(); private String redirectUri; private BuilderImpl() { } private BuilderImpl(CreateTokenRequest model) { super(model); clientId(model.clientId); clientSecret(model.clientSecret); grantType(model.grantType); deviceCode(model.deviceCode); code(model.code); refreshToken(model.refreshToken); scope(model.scope); redirectUri(model.redirectUri); } public final String getClientId() { return clientId; } @Override public final Builder clientId(String clientId) { this.clientId = clientId; return this; } public final void setClientId(String clientId) { this.clientId = clientId; } public final String getClientSecret() { return clientSecret; } @Override public final Builder clientSecret(String clientSecret) { this.clientSecret = clientSecret; return this; } public final void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } public final String getGrantType() { return grantType; } @Override public final Builder grantType(String grantType) { this.grantType = grantType; return this; } public final void setGrantType(String grantType) { this.grantType = grantType; } public final String getDeviceCode() { return deviceCode; } @Override public final Builder deviceCode(String deviceCode) { this.deviceCode = deviceCode; return this; } public final void setDeviceCode(String deviceCode) { this.deviceCode = deviceCode; } public final String getCode() { return code; } @Override public final Builder code(String code) { this.code = code; return this; } public final void setCode(String code) { this.code = code; } public final String getRefreshToken() { return refreshToken; } @Override public final Builder refreshToken(String refreshToken) { this.refreshToken = refreshToken; return this; } public final void setRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } public final Collection getScope() { return scope; } @Override public final Builder scope(Collection scope) { this.scope = ScopesCopier.copy(scope); return this; } @Override @SafeVarargs public final Builder scope(String... scope) { scope(Arrays.asList(scope)); return this; } public final void setScope(Collection scope) { this.scope = ScopesCopier.copy(scope); } public final String getRedirectUri() { return redirectUri; } @Override public final Builder redirectUri(String redirectUri) { this.redirectUri = redirectUri; return this; } public final void setRedirectUri(String redirectUri) { this.redirectUri = redirectUri; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateTokenRequest build() { return new CreateTokenRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy