
com.amazonaws.services.appsync.model.ApiKey Maven / Gradle / Ivy
/*
* Copyright 2013-2018 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.appsync.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* Describes an API key.
*
*
* Customers invoke AWS AppSync GraphQL APIs with API keys as an identity mechanism. There are two key versions:
*
*
* da1: This version was introduced at launch in November 2017. These keys always expire after 7 days. Key
* expiration is managed by DynamoDB TTL. The keys will cease to be valid after Feb 21, 2018 and should not be used
* after that date.
*
*
* -
*
* ListApiKeys
returns the expiration time in milliseconds.
*
*
* -
*
* CreateApiKey
returns the expiration time in milliseconds.
*
*
* -
*
* UpdateApiKey
is not available for this key version.
*
*
* -
*
* DeleteApiKey
deletes the item from the table.
*
*
* -
*
* Expiration is stored in DynamoDB as milliseconds. This results in a bug where keys are not automatically deleted
* because DynamoDB expects the TTL to be stored in seconds. As a one-time action, we will delete these keys from the
* table after Feb 21, 2018.
*
*
*
*
* da2: This version was introduced in February 2018 when AppSync added support to extend key expiration.
*
*
* -
*
* ListApiKeys
returns the expiration time in seconds.
*
*
* -
*
* CreateApiKey
returns the expiration time in seconds and accepts a user-provided expiration time in
* seconds.
*
*
* -
*
* UpdateApiKey
returns the expiration time in seconds and accepts a user-provided expiration time in
* seconds. Key expiration can only be updated while the key has not expired.
*
*
* -
*
* DeleteApiKey
deletes the item from the table.
*
*
* -
*
* Expiration is stored in DynamoDB as seconds.
*
*
*
*
* @see AWS API
* Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class ApiKey implements Serializable, Cloneable, StructuredPojo {
/**
*
* The API key ID.
*
*/
private String id;
/**
*
* A description of the purpose of the API key.
*
*/
private String description;
/**
*
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the
* nearest hour.
*
*/
private Long expires;
/**
*
* The API key ID.
*
*
* @param id
* The API key ID.
*/
public void setId(String id) {
this.id = id;
}
/**
*
* The API key ID.
*
*
* @return The API key ID.
*/
public String getId() {
return this.id;
}
/**
*
* The API key ID.
*
*
* @param id
* The API key ID.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ApiKey withId(String id) {
setId(id);
return this;
}
/**
*
* A description of the purpose of the API key.
*
*
* @param description
* A description of the purpose of the API key.
*/
public void setDescription(String description) {
this.description = description;
}
/**
*
* A description of the purpose of the API key.
*
*
* @return A description of the purpose of the API key.
*/
public String getDescription() {
return this.description;
}
/**
*
* A description of the purpose of the API key.
*
*
* @param description
* A description of the purpose of the API key.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ApiKey withDescription(String description) {
setDescription(description);
return this;
}
/**
*
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the
* nearest hour.
*
*
* @param expires
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down
* to the nearest hour.
*/
public void setExpires(Long expires) {
this.expires = expires;
}
/**
*
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the
* nearest hour.
*
*
* @return The time after which the API key expires. The date is represented as seconds since the epoch, rounded
* down to the nearest hour.
*/
public Long getExpires() {
return this.expires;
}
/**
*
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down to the
* nearest hour.
*
*
* @param expires
* The time after which the API key expires. The date is represented as seconds since the epoch, rounded down
* to the nearest hour.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public ApiKey withExpires(Long expires) {
setExpires(expires);
return this;
}
/**
* 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 (getId() != null)
sb.append("Id: ").append(getId()).append(",");
if (getDescription() != null)
sb.append("Description: ").append(getDescription()).append(",");
if (getExpires() != null)
sb.append("Expires: ").append(getExpires());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof ApiKey == false)
return false;
ApiKey other = (ApiKey) obj;
if (other.getId() == null ^ this.getId() == null)
return false;
if (other.getId() != null && other.getId().equals(this.getId()) == false)
return false;
if (other.getDescription() == null ^ this.getDescription() == null)
return false;
if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false)
return false;
if (other.getExpires() == null ^ this.getExpires() == null)
return false;
if (other.getExpires() != null && other.getExpires().equals(this.getExpires()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode());
hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode());
hashCode = prime * hashCode + ((getExpires() == null) ? 0 : getExpires().hashCode());
return hashCode;
}
@Override
public ApiKey clone() {
try {
return (ApiKey) 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.appsync.model.transform.ApiKeyMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}