/* * 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.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 AppSync GraphQL API operations with API keys as an identity mechanism. There are two key versions: *
** da1: We introduced this version at launch in November 2017. These keys always expire after 7 days. Amazon * DynamoDB TTL manages key expiration. These keys ceased to be valid after February 21, 2018, and they should no longer * be used. *
*
* 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 deleted these keys from the table * on February 21, 2018. *
** da2: We introduced this version in February 2018 when AppSync added support to extend key expiration. *
*
* ListApiKeys
returns the expiration time and deletion time in seconds.
*
* CreateApiKey
returns the expiration time and deletion time in seconds and accepts a user-provided
* expiration time in seconds.
*
* UpdateApiKey
returns the expiration time and and deletion time in seconds and accepts a user-provided
* expiration time in seconds. Expired API keys are kept for 60 days after the expiration time. You can update the key
* expiration time as long as the key isn't deleted.
*
* DeleteApiKey
deletes the item from the table.
*
* Expiration is stored in DynamoDB as seconds. After the expiration time, using the key to authenticate will fail. * However, you can reinstate the key before deletion. *
** Deletion is stored in DynamoDB as seconds. The key is deleted after deletion time. *
** 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 time after which the API key is deleted. The date is represented as seconds since the epoch, rounded down to * the nearest hour. *
*/ private Long deletes; /** ** 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; } /** ** The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded down to * the nearest hour. *
* * @param deletes * The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded * down to the nearest hour. */ public void setDeletes(Long deletes) { this.deletes = deletes; } /** ** The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded down to * the nearest hour. *
* * @return The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded * down to the nearest hour. */ public Long getDeletes() { return this.deletes; } /** ** The time after which the API key is deleted. The date is represented as seconds since the epoch, rounded down to * the nearest hour. *
* * @param deletes * The time after which the API key is deleted. 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 withDeletes(Long deletes) { setDeletes(deletes); 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 (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()).append(","); if (getDeletes() != null) sb.append("Deletes: ").append(getDeletes()); 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; if (other.getDeletes() == null ^ this.getDeletes() == null) return false; if (other.getDeletes() != null && other.getDeletes().equals(this.getDeletes()) == 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()); hashCode = prime * hashCode + ((getDeletes() == null) ? 0 : getDeletes().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); } }