
com.amazonaws.services.ec2.model.PurchaseScheduledInstancesRequest Maven / Gradle / Ivy
Show all versions of aws-android-sdk-ec2 Show documentation
/*
* Copyright 2010-2016 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 com.amazonaws.services.ec2.model;
import java.io.Serializable;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.Request;
import com.amazonaws.services.ec2.model.transform.PurchaseScheduledInstancesRequestMarshaller;
/**
* Container for the parameters to the {@link com.amazonaws.services.ec2.AmazonEC2#purchaseScheduledInstances(PurchaseScheduledInstancesRequest) PurchaseScheduledInstances operation}.
*
* Purchases one or more Scheduled Instances with the specified schedule.
*
*
* Scheduled Instances enable you to purchase Amazon EC2 compute capacity
* by the hour for a one-year term. Before you can purchase a Scheduled
* Instance, you must call DescribeScheduledInstanceAvailability to check
* for available schedules and obtain a purchase token.
*
*
* @see com.amazonaws.services.ec2.AmazonEC2#purchaseScheduledInstances(PurchaseScheduledInstancesRequest)
*/
public class PurchaseScheduledInstancesRequest extends AmazonWebServiceRequest implements Serializable, DryRunSupportedRequest {
/**
* Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*/
private String clientToken;
/**
* One or more purchase requests.
*
* Constraints:
* Length: 1 -
*/
private com.amazonaws.internal.ListWithAutoConstructFlag purchaseRequests;
/**
* Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*
* @return Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*/
public String getClientToken() {
return clientToken;
}
/**
* Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*
* @param clientToken Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*/
public void setClientToken(String clientToken) {
this.clientToken = clientToken;
}
/**
* Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*
* Returns a reference to this object so that method calls can be chained together.
*
* @param clientToken Unique, case-sensitive identifier that ensures the idempotency of the
* request. For more information, see Ensuring
* Idempotency.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PurchaseScheduledInstancesRequest withClientToken(String clientToken) {
this.clientToken = clientToken;
return this;
}
/**
* One or more purchase requests.
*
* Constraints:
* Length: 1 -
*
* @return One or more purchase requests.
*/
public java.util.List getPurchaseRequests() {
if (purchaseRequests == null) {
purchaseRequests = new com.amazonaws.internal.ListWithAutoConstructFlag();
purchaseRequests.setAutoConstruct(true);
}
return purchaseRequests;
}
/**
* One or more purchase requests.
*
* Constraints:
* Length: 1 -
*
* @param purchaseRequests One or more purchase requests.
*/
public void setPurchaseRequests(java.util.Collection purchaseRequests) {
if (purchaseRequests == null) {
this.purchaseRequests = null;
return;
}
com.amazonaws.internal.ListWithAutoConstructFlag purchaseRequestsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(purchaseRequests.size());
purchaseRequestsCopy.addAll(purchaseRequests);
this.purchaseRequests = purchaseRequestsCopy;
}
/**
* One or more purchase requests.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 1 -
*
* @param purchaseRequests One or more purchase requests.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PurchaseScheduledInstancesRequest withPurchaseRequests(PurchaseRequest... purchaseRequests) {
if (getPurchaseRequests() == null) setPurchaseRequests(new java.util.ArrayList(purchaseRequests.length));
for (PurchaseRequest value : purchaseRequests) {
getPurchaseRequests().add(value);
}
return this;
}
/**
* One or more purchase requests.
*
* Returns a reference to this object so that method calls can be chained together.
*
* Constraints:
* Length: 1 -
*
* @param purchaseRequests One or more purchase requests.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public PurchaseScheduledInstancesRequest withPurchaseRequests(java.util.Collection purchaseRequests) {
if (purchaseRequests == null) {
this.purchaseRequests = null;
} else {
com.amazonaws.internal.ListWithAutoConstructFlag purchaseRequestsCopy = new com.amazonaws.internal.ListWithAutoConstructFlag(purchaseRequests.size());
purchaseRequestsCopy.addAll(purchaseRequests);
this.purchaseRequests = purchaseRequestsCopy;
}
return this;
}
/**
* This method is intended for internal use only.
* Returns the marshaled request configured with additional parameters to
* enable operation dry-run.
*/
@Override
public Request getDryRunRequest() {
Request request = new PurchaseScheduledInstancesRequestMarshaller().marshall(this);
request.addParameter("DryRun", Boolean.toString(true));
return request;
}
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getClientToken() != null) sb.append("ClientToken: " + getClientToken() + ",");
if (getPurchaseRequests() != null) sb.append("PurchaseRequests: " + getPurchaseRequests() );
sb.append("}");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getClientToken() == null) ? 0 : getClientToken().hashCode());
hashCode = prime * hashCode + ((getPurchaseRequests() == null) ? 0 : getPurchaseRequests().hashCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (obj instanceof PurchaseScheduledInstancesRequest == false) return false;
PurchaseScheduledInstancesRequest other = (PurchaseScheduledInstancesRequest)obj;
if (other.getClientToken() == null ^ this.getClientToken() == null) return false;
if (other.getClientToken() != null && other.getClientToken().equals(this.getClientToken()) == false) return false;
if (other.getPurchaseRequests() == null ^ this.getPurchaseRequests() == null) return false;
if (other.getPurchaseRequests() != null && other.getPurchaseRequests().equals(this.getPurchaseRequests()) == false) return false;
return true;
}
}