
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 extends Builder> 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