
com.amazonaws.services.dlm.model.CreateRule Maven / Gradle / Ivy
/*
* Copyright 2018-2023 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.dlm.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* [Snapshot and AMI policies only] Specifies when the policy should create snapshots or AMIs.
*
*
*
* -
*
* You must specify either CronExpression, or Interval, IntervalUnit, and Times.
*
*
* -
*
* If you need to specify an ArchiveRule for the schedule, then you must specify a creation frequency of at least
* 28 days.
*
*
*
*
*
* @see AWS API
* Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class CreateRule implements Serializable, Cloneable, StructuredPojo {
/**
*
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on the same
* Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the same
* Region as the source resource. If the policy targets resources on an Outpost, then you can create snapshots on
* the same Outpost as the source resource, or in the Region of that Outpost.
*
*/
private String location;
/**
*
* The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
*
*/
private Integer interval;
/**
*
* The interval unit.
*
*/
private String intervalUnit;
/**
*
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time, Amazon
* Data Lifecycle Manager selects a time within the next 24 hours.
*
*/
private java.util.List times;
/**
*
* The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron
* expressions in the Amazon CloudWatch User Guide.
*
*/
private String cronExpression;
/**
*
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on the same
* Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the same
* Region as the source resource. If the policy targets resources on an Outpost, then you can create snapshots on
* the same Outpost as the source resource, or in the Region of that Outpost.
*
*
* @param location
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on
* the same Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the
* same Region as the source resource. If the policy targets resources on an Outpost, then you can create
* snapshots on the same Outpost as the source resource, or in the Region of that Outpost.
* @see LocationValues
*/
public void setLocation(String location) {
this.location = location;
}
/**
*
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on the same
* Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the same
* Region as the source resource. If the policy targets resources on an Outpost, then you can create snapshots on
* the same Outpost as the source resource, or in the Region of that Outpost.
*
*
* @return [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on
* the same Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the
* same Region as the source resource. If the policy targets resources on an Outpost, then you can create
* snapshots on the same Outpost as the source resource, or in the Region of that Outpost.
* @see LocationValues
*/
public String getLocation() {
return this.location;
}
/**
*
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on the same
* Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the same
* Region as the source resource. If the policy targets resources on an Outpost, then you can create snapshots on
* the same Outpost as the source resource, or in the Region of that Outpost.
*
*
* @param location
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on
* the same Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the
* same Region as the source resource. If the policy targets resources on an Outpost, then you can create
* snapshots on the same Outpost as the source resource, or in the Region of that Outpost.
* @return Returns a reference to this object so that method calls can be chained together.
* @see LocationValues
*/
public CreateRule withLocation(String location) {
setLocation(location);
return this;
}
/**
*
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on the same
* Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the same
* Region as the source resource. If the policy targets resources on an Outpost, then you can create snapshots on
* the same Outpost as the source resource, or in the Region of that Outpost.
*
*
* @param location
* [Snapshot policies only] Specifies the destination for snapshots created by the policy. To create
* snapshots in the same Region as the source resource, specify CLOUD
. To create snapshots on
* the same Outpost as the source resource, specify OUTPOST_LOCAL
. If you omit this parameter,
* CLOUD
is used by default.
*
* If the policy targets resources in an Amazon Web Services Region, then you must create snapshots in the
* same Region as the source resource. If the policy targets resources on an Outpost, then you can create
* snapshots on the same Outpost as the source resource, or in the Region of that Outpost.
* @return Returns a reference to this object so that method calls can be chained together.
* @see LocationValues
*/
public CreateRule withLocation(LocationValues location) {
this.location = location.toString();
return this;
}
/**
*
* The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
*
*
* @param interval
* The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
*/
public void setInterval(Integer interval) {
this.interval = interval;
}
/**
*
* The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
*
*
* @return The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
*/
public Integer getInterval() {
return this.interval;
}
/**
*
* The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
*
*
* @param interval
* The interval between snapshots. The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateRule withInterval(Integer interval) {
setInterval(interval);
return this;
}
/**
*
* The interval unit.
*
*
* @param intervalUnit
* The interval unit.
* @see IntervalUnitValues
*/
public void setIntervalUnit(String intervalUnit) {
this.intervalUnit = intervalUnit;
}
/**
*
* The interval unit.
*
*
* @return The interval unit.
* @see IntervalUnitValues
*/
public String getIntervalUnit() {
return this.intervalUnit;
}
/**
*
* The interval unit.
*
*
* @param intervalUnit
* The interval unit.
* @return Returns a reference to this object so that method calls can be chained together.
* @see IntervalUnitValues
*/
public CreateRule withIntervalUnit(String intervalUnit) {
setIntervalUnit(intervalUnit);
return this;
}
/**
*
* The interval unit.
*
*
* @param intervalUnit
* The interval unit.
* @return Returns a reference to this object so that method calls can be chained together.
* @see IntervalUnitValues
*/
public CreateRule withIntervalUnit(IntervalUnitValues intervalUnit) {
this.intervalUnit = intervalUnit.toString();
return this;
}
/**
*
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time, Amazon
* Data Lifecycle Manager selects a time within the next 24 hours.
*
*
* @return The time, in UTC, to start the operation. The supported format is hh:mm.
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time,
* Amazon Data Lifecycle Manager selects a time within the next 24 hours.
*/
public java.util.List getTimes() {
return times;
}
/**
*
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time, Amazon
* Data Lifecycle Manager selects a time within the next 24 hours.
*
*
* @param times
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time,
* Amazon Data Lifecycle Manager selects a time within the next 24 hours.
*/
public void setTimes(java.util.Collection times) {
if (times == null) {
this.times = null;
return;
}
this.times = new java.util.ArrayList(times);
}
/**
*
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time, Amazon
* Data Lifecycle Manager selects a time within the next 24 hours.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setTimes(java.util.Collection)} or {@link #withTimes(java.util.Collection)} if you want to override the
* existing values.
*
*
* @param times
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time,
* Amazon Data Lifecycle Manager selects a time within the next 24 hours.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateRule withTimes(String... times) {
if (this.times == null) {
setTimes(new java.util.ArrayList(times.length));
}
for (String ele : times) {
this.times.add(ele);
}
return this;
}
/**
*
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time, Amazon
* Data Lifecycle Manager selects a time within the next 24 hours.
*
*
* @param times
* The time, in UTC, to start the operation. The supported format is hh:mm.
*
* The operation occurs within a one-hour window following the specified time. If you do not specify a time,
* Amazon Data Lifecycle Manager selects a time within the next 24 hours.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateRule withTimes(java.util.Collection times) {
setTimes(times);
return this;
}
/**
*
* The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron
* expressions in the Amazon CloudWatch User Guide.
*
*
* @param cronExpression
* The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron expressions in the Amazon CloudWatch User Guide.
*/
public void setCronExpression(String cronExpression) {
this.cronExpression = cronExpression;
}
/**
*
* The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron
* expressions in the Amazon CloudWatch User Guide.
*
*
* @return The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron expressions in the Amazon CloudWatch User Guide.
*/
public String getCronExpression() {
return this.cronExpression;
}
/**
*
* The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron
* expressions in the Amazon CloudWatch User Guide.
*
*
* @param cronExpression
* The schedule, as a Cron expression. The schedule interval must be between 1 hour and 1 year. For more
* information, see Cron expressions in the Amazon CloudWatch User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateRule withCronExpression(String cronExpression) {
setCronExpression(cronExpression);
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getLocation() != null)
sb.append("Location: ").append(getLocation()).append(",");
if (getInterval() != null)
sb.append("Interval: ").append(getInterval()).append(",");
if (getIntervalUnit() != null)
sb.append("IntervalUnit: ").append(getIntervalUnit()).append(",");
if (getTimes() != null)
sb.append("Times: ").append(getTimes()).append(",");
if (getCronExpression() != null)
sb.append("CronExpression: ").append(getCronExpression());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof CreateRule == false)
return false;
CreateRule other = (CreateRule) obj;
if (other.getLocation() == null ^ this.getLocation() == null)
return false;
if (other.getLocation() != null && other.getLocation().equals(this.getLocation()) == false)
return false;
if (other.getInterval() == null ^ this.getInterval() == null)
return false;
if (other.getInterval() != null && other.getInterval().equals(this.getInterval()) == false)
return false;
if (other.getIntervalUnit() == null ^ this.getIntervalUnit() == null)
return false;
if (other.getIntervalUnit() != null && other.getIntervalUnit().equals(this.getIntervalUnit()) == false)
return false;
if (other.getTimes() == null ^ this.getTimes() == null)
return false;
if (other.getTimes() != null && other.getTimes().equals(this.getTimes()) == false)
return false;
if (other.getCronExpression() == null ^ this.getCronExpression() == null)
return false;
if (other.getCronExpression() != null && other.getCronExpression().equals(this.getCronExpression()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getLocation() == null) ? 0 : getLocation().hashCode());
hashCode = prime * hashCode + ((getInterval() == null) ? 0 : getInterval().hashCode());
hashCode = prime * hashCode + ((getIntervalUnit() == null) ? 0 : getIntervalUnit().hashCode());
hashCode = prime * hashCode + ((getTimes() == null) ? 0 : getTimes().hashCode());
hashCode = prime * hashCode + ((getCronExpression() == null) ? 0 : getCronExpression().hashCode());
return hashCode;
}
@Override
public CreateRule clone() {
try {
return (CreateRule) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.dlm.model.transform.CreateRuleMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}