software.amazon.awssdk.services.iam.model.UpdateRoleRequest Maven / Gradle / Ivy
Show all versions of iam 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.iam.model;
import java.util.Arrays;
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.LocationTrait;
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 UpdateRoleRequest extends IamRequest implements
ToCopyableBuilder {
private static final SdkField ROLE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(UpdateRoleRequest::roleName)).setter(setter(Builder::roleName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RoleName").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(UpdateRoleRequest::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField MAX_SESSION_DURATION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(UpdateRoleRequest::maxSessionDuration)).setter(setter(Builder::maxSessionDuration))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxSessionDuration").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ROLE_NAME_FIELD,
DESCRIPTION_FIELD, MAX_SESSION_DURATION_FIELD));
private final String roleName;
private final String description;
private final Integer maxSessionDuration;
private UpdateRoleRequest(BuilderImpl builder) {
super(builder);
this.roleName = builder.roleName;
this.description = builder.description;
this.maxSessionDuration = builder.maxSessionDuration;
}
/**
*
* The name of the role that you want to modify.
*
*
* @return The name of the role that you want to modify.
*/
public String roleName() {
return roleName;
}
/**
*
* The new description that you want to apply to the specified role.
*
*
* @return The new description that you want to apply to the specified role.
*/
public String description() {
return description;
}
/**
*
* The maximum session duration (in seconds) that you want to set for the specified role. If you do not specify a
* value for this setting, the default maximum of one hour is applied. This setting can have a value from 1 hour to
* 12 hours.
*
*
* Anyone who assumes the role from the AWS CLI or API can use the DurationSeconds
API parameter or the
* duration-seconds
CLI parameter to request a longer session. The MaxSessionDuration
* setting determines the maximum duration that can be requested using the DurationSeconds
parameter.
* If users don't specify a value for the DurationSeconds
parameter, their security credentials are
* valid for one hour by default. This applies when you use the AssumeRole*
API operations or the
* assume-role*
CLI operations but does not apply when you use those operations to create a console
* URL. For more information, see Using
* IAM Roles in the IAM User Guide.
*
*
* @return The maximum session duration (in seconds) that you want to set for the specified role. If you do not
* specify a value for this setting, the default maximum of one hour is applied. This setting can have a
* value from 1 hour to 12 hours.
*
* Anyone who assumes the role from the AWS CLI or API can use the DurationSeconds
API
* parameter or the duration-seconds
CLI parameter to request a longer session. The
* MaxSessionDuration
setting determines the maximum duration that can be requested using the
* DurationSeconds
parameter. If users don't specify a value for the
* DurationSeconds
parameter, their security credentials are valid for one hour by default.
* This applies when you use the AssumeRole*
API operations or the assume-role*
* CLI operations but does not apply when you use those operations to create a console URL. For more
* information, see Using IAM
* Roles in the IAM User Guide.
*/
public Integer maxSessionDuration() {
return maxSessionDuration;
}
@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(roleName());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(maxSessionDuration());
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 UpdateRoleRequest)) {
return false;
}
UpdateRoleRequest other = (UpdateRoleRequest) obj;
return Objects.equals(roleName(), other.roleName()) && Objects.equals(description(), other.description())
&& Objects.equals(maxSessionDuration(), other.maxSessionDuration());
}
/**
* 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("UpdateRoleRequest").add("RoleName", roleName()).add("Description", description())
.add("MaxSessionDuration", maxSessionDuration()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RoleName":
return Optional.ofNullable(clazz.cast(roleName()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "MaxSessionDuration":
return Optional.ofNullable(clazz.cast(maxSessionDuration()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* Anyone who assumes the role from the AWS CLI or API can use the DurationSeconds
API
* parameter or the duration-seconds
CLI parameter to request a longer session. The
* MaxSessionDuration
setting determines the maximum duration that can be requested using
* the DurationSeconds
parameter. If users don't specify a value for the
* DurationSeconds
parameter, their security credentials are valid for one hour by default.
* This applies when you use the AssumeRole*
API operations or the assume-role*
* CLI operations but does not apply when you use those operations to create a console URL. For more
* information, see Using
* IAM Roles in the IAM User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder maxSessionDuration(Integer maxSessionDuration);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends IamRequest.BuilderImpl implements Builder {
private String roleName;
private String description;
private Integer maxSessionDuration;
private BuilderImpl() {
}
private BuilderImpl(UpdateRoleRequest model) {
super(model);
roleName(model.roleName);
description(model.description);
maxSessionDuration(model.maxSessionDuration);
}
public final String getRoleName() {
return roleName;
}
@Override
public final Builder roleName(String roleName) {
this.roleName = roleName;
return this;
}
public final void setRoleName(String roleName) {
this.roleName = roleName;
}
public final String getDescription() {
return description;
}
@Override
public final Builder description(String description) {
this.description = description;
return this;
}
public final void setDescription(String description) {
this.description = description;
}
public final Integer getMaxSessionDuration() {
return maxSessionDuration;
}
@Override
public final Builder maxSessionDuration(Integer maxSessionDuration) {
this.maxSessionDuration = maxSessionDuration;
return this;
}
public final void setMaxSessionDuration(Integer maxSessionDuration) {
this.maxSessionDuration = maxSessionDuration;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public UpdateRoleRequest build() {
return new UpdateRoleRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}