software.amazon.awssdk.services.devicefarm.model.CreateDevicePoolRequest Maven / Gradle / Ivy
Show all versions of devicefarm 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.devicefarm.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 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.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;
/**
*
* Represents a request to the create device pool operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateDevicePoolRequest extends DeviceFarmRequest implements
ToCopyableBuilder {
private static final SdkField PROJECT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("projectArn").getter(getter(CreateDevicePoolRequest::projectArn)).setter(setter(Builder::projectArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("projectArn").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(CreateDevicePoolRequest::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(CreateDevicePoolRequest::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField> RULES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("rules")
.getter(getter(CreateDevicePoolRequest::rules))
.setter(setter(Builder::rules))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("rules").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Rule::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField MAX_DEVICES_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("maxDevices").getter(getter(CreateDevicePoolRequest::maxDevices)).setter(setter(Builder::maxDevices))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("maxDevices").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PROJECT_ARN_FIELD, NAME_FIELD,
DESCRIPTION_FIELD, RULES_FIELD, MAX_DEVICES_FIELD));
private final String projectArn;
private final String name;
private final String description;
private final List rules;
private final Integer maxDevices;
private CreateDevicePoolRequest(BuilderImpl builder) {
super(builder);
this.projectArn = builder.projectArn;
this.name = builder.name;
this.description = builder.description;
this.rules = builder.rules;
this.maxDevices = builder.maxDevices;
}
/**
*
* The ARN of the project for the device pool.
*
*
* @return The ARN of the project for the device pool.
*/
public String projectArn() {
return projectArn;
}
/**
*
* The device pool's name.
*
*
* @return The device pool's name.
*/
public String name() {
return name;
}
/**
*
* The device pool's description.
*
*
* @return The device pool's description.
*/
public String description() {
return description;
}
/**
* Returns true if the Rules 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 hasRules() {
return rules != null && !(rules instanceof SdkAutoConstructList);
}
/**
*
* The device pool's rules.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasRules()} to see if a value was sent in this field.
*
*
* @return The device pool's rules.
*/
public List rules() {
return rules;
}
/**
*
* The number of devices that Device Farm can add to your device pool. Device Farm adds devices that are available
* and meet the criteria that you assign for the rules
parameter. Depending on how many devices meet
* these constraints, your device pool might contain fewer devices than the value for this parameter.
*
*
* By specifying the maximum number of devices, you can control the costs that you incur by running tests.
*
*
* @return The number of devices that Device Farm can add to your device pool. Device Farm adds devices that are
* available and meet the criteria that you assign for the rules
parameter. Depending on how
* many devices meet these constraints, your device pool might contain fewer devices than the value for this
* parameter.
*
* By specifying the maximum number of devices, you can control the costs that you incur by running tests.
*/
public Integer maxDevices() {
return maxDevices;
}
@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(projectArn());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(hasRules() ? rules() : null);
hashCode = 31 * hashCode + Objects.hashCode(maxDevices());
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 CreateDevicePoolRequest)) {
return false;
}
CreateDevicePoolRequest other = (CreateDevicePoolRequest) obj;
return Objects.equals(projectArn(), other.projectArn()) && Objects.equals(name(), other.name())
&& Objects.equals(description(), other.description()) && hasRules() == other.hasRules()
&& Objects.equals(rules(), other.rules()) && Objects.equals(maxDevices(), other.maxDevices());
}
/**
* 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("CreateDevicePoolRequest").add("ProjectArn", projectArn()).add("Name", name())
.add("Description", description()).add("Rules", hasRules() ? rules() : null).add("MaxDevices", maxDevices())
.build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "projectArn":
return Optional.ofNullable(clazz.cast(projectArn()));
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "rules":
return Optional.ofNullable(clazz.cast(rules()));
case "maxDevices":
return Optional.ofNullable(clazz.cast(maxDevices()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* By specifying the maximum number of devices, you can control the costs that you incur by running
* tests.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder maxDevices(Integer maxDevices);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends DeviceFarmRequest.BuilderImpl implements Builder {
private String projectArn;
private String name;
private String description;
private List rules = DefaultSdkAutoConstructList.getInstance();
private Integer maxDevices;
private BuilderImpl() {
}
private BuilderImpl(CreateDevicePoolRequest model) {
super(model);
projectArn(model.projectArn);
name(model.name);
description(model.description);
rules(model.rules);
maxDevices(model.maxDevices);
}
public final String getProjectArn() {
return projectArn;
}
@Override
public final Builder projectArn(String projectArn) {
this.projectArn = projectArn;
return this;
}
public final void setProjectArn(String projectArn) {
this.projectArn = projectArn;
}
public final String getName() {
return name;
}
@Override
public final Builder name(String name) {
this.name = name;
return this;
}
public final void setName(String name) {
this.name = name;
}
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 Collection getRules() {
if (rules instanceof SdkAutoConstructList) {
return null;
}
return rules != null ? rules.stream().map(Rule::toBuilder).collect(Collectors.toList()) : null;
}
@Override
public final Builder rules(Collection rules) {
this.rules = RulesCopier.copy(rules);
return this;
}
@Override
@SafeVarargs
public final Builder rules(Rule... rules) {
rules(Arrays.asList(rules));
return this;
}
@Override
@SafeVarargs
public final Builder rules(Consumer... rules) {
rules(Stream.of(rules).map(c -> Rule.builder().applyMutation(c).build()).collect(Collectors.toList()));
return this;
}
public final void setRules(Collection rules) {
this.rules = RulesCopier.copyFromBuilder(rules);
}
public final Integer getMaxDevices() {
return maxDevices;
}
@Override
public final Builder maxDevices(Integer maxDevices) {
this.maxDevices = maxDevices;
return this;
}
public final void setMaxDevices(Integer maxDevices) {
this.maxDevices = maxDevices;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public CreateDevicePoolRequest build() {
return new CreateDevicePoolRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}