All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.apigateway.model.CreateApiKeyResponse Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon API Gateway module holds the client classes that are used for communicating with Amazon API Gateway

There is a newer version: 2.28.3
Show newest version
/*
 * 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.apigateway.model;

import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
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.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* A resource that can be distributed to callers for executing Method resources that require an API key. API keys can be * mapped to any Stage on any RestApi, which indicates that the callers with the API key can make requests to that * stage. *

*/ @Generated("software.amazon.awssdk:codegen") public final class CreateApiKeyResponse extends ApiGatewayResponse implements ToCopyableBuilder { private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id") .getter(getter(CreateApiKeyResponse::id)).setter(setter(Builder::id)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build(); private static final SdkField VALUE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("value") .getter(getter(CreateApiKeyResponse::value)).setter(setter(Builder::value)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("value").build()).build(); private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name") .getter(getter(CreateApiKeyResponse::name)).setter(setter(Builder::name)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build(); private static final SdkField CUSTOMER_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("customerId").getter(getter(CreateApiKeyResponse::customerId)).setter(setter(Builder::customerId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("customerId").build()).build(); private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("description").getter(getter(CreateApiKeyResponse::description)).setter(setter(Builder::description)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build(); private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .memberName("enabled").getter(getter(CreateApiKeyResponse::enabled)).setter(setter(Builder::enabled)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("enabled").build()).build(); private static final SdkField CREATED_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("createdDate").getter(getter(CreateApiKeyResponse::createdDate)).setter(setter(Builder::createdDate)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdDate").build()).build(); private static final SdkField LAST_UPDATED_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("lastUpdatedDate").getter(getter(CreateApiKeyResponse::lastUpdatedDate)) .setter(setter(Builder::lastUpdatedDate)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastUpdatedDate").build()).build(); private static final SdkField> STAGE_KEYS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("stageKeys") .getter(getter(CreateApiKeyResponse::stageKeys)) .setter(setter(Builder::stageKeys)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("stageKeys").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> TAGS_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("tags") .getter(getter(CreateApiKeyResponse::tags)) .setter(setter(Builder::tags)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, VALUE_FIELD, NAME_FIELD, CUSTOMER_ID_FIELD, DESCRIPTION_FIELD, ENABLED_FIELD, CREATED_DATE_FIELD, LAST_UPDATED_DATE_FIELD, STAGE_KEYS_FIELD, TAGS_FIELD)); private final String id; private final String value; private final String name; private final String customerId; private final String description; private final Boolean enabled; private final Instant createdDate; private final Instant lastUpdatedDate; private final List stageKeys; private final Map tags; private CreateApiKeyResponse(BuilderImpl builder) { super(builder); this.id = builder.id; this.value = builder.value; this.name = builder.name; this.customerId = builder.customerId; this.description = builder.description; this.enabled = builder.enabled; this.createdDate = builder.createdDate; this.lastUpdatedDate = builder.lastUpdatedDate; this.stageKeys = builder.stageKeys; this.tags = builder.tags; } /** *

* The identifier of the API Key. *

* * @return The identifier of the API Key. */ public final String id() { return id; } /** *

* The value of the API Key. *

* * @return The value of the API Key. */ public final String value() { return value; } /** *

* The name of the API Key. *

* * @return The name of the API Key. */ public final String name() { return name; } /** *

* An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS * Marketplace. *

* * @return An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services * SaaS Marketplace. */ public final String customerId() { return customerId; } /** *

* The description of the API Key. *

* * @return The description of the API Key. */ public final String description() { return description; } /** *

* Specifies whether the API Key can be used by callers. *

* * @return Specifies whether the API Key can be used by callers. */ public final Boolean enabled() { return enabled; } /** *

* The timestamp when the API Key was created. *

* * @return The timestamp when the API Key was created. */ public final Instant createdDate() { return createdDate; } /** *

* The timestamp when the API Key was last updated. *

* * @return The timestamp when the API Key was last updated. */ public final Instant lastUpdatedDate() { return lastUpdatedDate; } /** * For responses, this returns true if the service returned a value for the StageKeys property. This DOES NOT check * that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is * useful because the SDK will never return a null collection or map, but you may need to differentiate between the * service returning nothing (or null) and the service returning an empty collection or map. For requests, this * returns true if a value for the property was specified in the request builder, and false if a value was not * specified. */ public final boolean hasStageKeys() { return stageKeys != null && !(stageKeys instanceof SdkAutoConstructList); } /** *

* A list of Stage resources that are associated with the ApiKey resource. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasStageKeys} method. *

* * @return A list of Stage resources that are associated with the ApiKey resource. */ public final List stageKeys() { return stageKeys; } /** * For responses, this returns true if the service returned a value for the Tags property. This DOES NOT check that * the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is useful * because the SDK will never return a null collection or map, but you may need to differentiate between the service * returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true * if a value for the property was specified in the request builder, and false if a value was not specified. */ public final boolean hasTags() { return tags != null && !(tags instanceof SdkAutoConstructMap); } /** *

* The collection of tags. Each tag element is associated with a given resource. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasTags} method. *

* * @return The collection of tags. Each tag element is associated with a given resource. */ public final Map tags() { return tags; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(id()); hashCode = 31 * hashCode + Objects.hashCode(value()); hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(customerId()); hashCode = 31 * hashCode + Objects.hashCode(description()); hashCode = 31 * hashCode + Objects.hashCode(enabled()); hashCode = 31 * hashCode + Objects.hashCode(createdDate()); hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedDate()); hashCode = 31 * hashCode + Objects.hashCode(hasStageKeys() ? stageKeys() : null); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateApiKeyResponse)) { return false; } CreateApiKeyResponse other = (CreateApiKeyResponse) obj; return Objects.equals(id(), other.id()) && Objects.equals(value(), other.value()) && Objects.equals(name(), other.name()) && Objects.equals(customerId(), other.customerId()) && Objects.equals(description(), other.description()) && Objects.equals(enabled(), other.enabled()) && Objects.equals(createdDate(), other.createdDate()) && Objects.equals(lastUpdatedDate(), other.lastUpdatedDate()) && hasStageKeys() == other.hasStageKeys() && Objects.equals(stageKeys(), other.stageKeys()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()); } /** * 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 final String toString() { return ToString.builder("CreateApiKeyResponse").add("Id", id()).add("Value", value()).add("Name", name()) .add("CustomerId", customerId()).add("Description", description()).add("Enabled", enabled()) .add("CreatedDate", createdDate()).add("LastUpdatedDate", lastUpdatedDate()) .add("StageKeys", hasStageKeys() ? stageKeys() : null).add("Tags", hasTags() ? tags() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "id": return Optional.ofNullable(clazz.cast(id())); case "value": return Optional.ofNullable(clazz.cast(value())); case "name": return Optional.ofNullable(clazz.cast(name())); case "customerId": return Optional.ofNullable(clazz.cast(customerId())); case "description": return Optional.ofNullable(clazz.cast(description())); case "enabled": return Optional.ofNullable(clazz.cast(enabled())); case "createdDate": return Optional.ofNullable(clazz.cast(createdDate())); case "lastUpdatedDate": return Optional.ofNullable(clazz.cast(lastUpdatedDate())); case "stageKeys": return Optional.ofNullable(clazz.cast(stageKeys())); case "tags": return Optional.ofNullable(clazz.cast(tags())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateApiKeyResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends ApiGatewayResponse.Builder, SdkPojo, CopyableBuilder { /** *

* The identifier of the API Key. *

* * @param id * The identifier of the API Key. * @return Returns a reference to this object so that method calls can be chained together. */ Builder id(String id); /** *

* The value of the API Key. *

* * @param value * The value of the API Key. * @return Returns a reference to this object so that method calls can be chained together. */ Builder value(String value); /** *

* The name of the API Key. *

* * @param name * The name of the API Key. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** *

* An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS * Marketplace. *

* * @param customerId * An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services * SaaS Marketplace. * @return Returns a reference to this object so that method calls can be chained together. */ Builder customerId(String customerId); /** *

* The description of the API Key. *

* * @param description * The description of the API Key. * @return Returns a reference to this object so that method calls can be chained together. */ Builder description(String description); /** *

* Specifies whether the API Key can be used by callers. *

* * @param enabled * Specifies whether the API Key can be used by callers. * @return Returns a reference to this object so that method calls can be chained together. */ Builder enabled(Boolean enabled); /** *

* The timestamp when the API Key was created. *

* * @param createdDate * The timestamp when the API Key was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createdDate(Instant createdDate); /** *

* The timestamp when the API Key was last updated. *

* * @param lastUpdatedDate * The timestamp when the API Key was last updated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastUpdatedDate(Instant lastUpdatedDate); /** *

* A list of Stage resources that are associated with the ApiKey resource. *

* * @param stageKeys * A list of Stage resources that are associated with the ApiKey resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder stageKeys(Collection stageKeys); /** *

* A list of Stage resources that are associated with the ApiKey resource. *

* * @param stageKeys * A list of Stage resources that are associated with the ApiKey resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder stageKeys(String... stageKeys); /** *

* The collection of tags. Each tag element is associated with a given resource. *

* * @param tags * The collection of tags. Each tag element is associated with a given resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Map tags); } static final class BuilderImpl extends ApiGatewayResponse.BuilderImpl implements Builder { private String id; private String value; private String name; private String customerId; private String description; private Boolean enabled; private Instant createdDate; private Instant lastUpdatedDate; private List stageKeys = DefaultSdkAutoConstructList.getInstance(); private Map tags = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateApiKeyResponse model) { super(model); id(model.id); value(model.value); name(model.name); customerId(model.customerId); description(model.description); enabled(model.enabled); createdDate(model.createdDate); lastUpdatedDate(model.lastUpdatedDate); stageKeys(model.stageKeys); tags(model.tags); } public final String getId() { return id; } public final void setId(String id) { this.id = id; } @Override public final Builder id(String id) { this.id = id; return this; } public final String getValue() { return value; } public final void setValue(String value) { this.value = value; } @Override public final Builder value(String value) { this.value = value; return this; } public final String getName() { return name; } public final void setName(String name) { this.name = name; } @Override public final Builder name(String name) { this.name = name; return this; } public final String getCustomerId() { return customerId; } public final void setCustomerId(String customerId) { this.customerId = customerId; } @Override public final Builder customerId(String customerId) { this.customerId = customerId; return this; } public final String getDescription() { return description; } public final void setDescription(String description) { this.description = description; } @Override public final Builder description(String description) { this.description = description; return this; } public final Boolean getEnabled() { return enabled; } public final void setEnabled(Boolean enabled) { this.enabled = enabled; } @Override public final Builder enabled(Boolean enabled) { this.enabled = enabled; return this; } public final Instant getCreatedDate() { return createdDate; } public final void setCreatedDate(Instant createdDate) { this.createdDate = createdDate; } @Override public final Builder createdDate(Instant createdDate) { this.createdDate = createdDate; return this; } public final Instant getLastUpdatedDate() { return lastUpdatedDate; } public final void setLastUpdatedDate(Instant lastUpdatedDate) { this.lastUpdatedDate = lastUpdatedDate; } @Override public final Builder lastUpdatedDate(Instant lastUpdatedDate) { this.lastUpdatedDate = lastUpdatedDate; return this; } public final Collection getStageKeys() { if (stageKeys instanceof SdkAutoConstructList) { return null; } return stageKeys; } public final void setStageKeys(Collection stageKeys) { this.stageKeys = ListOfStringCopier.copy(stageKeys); } @Override public final Builder stageKeys(Collection stageKeys) { this.stageKeys = ListOfStringCopier.copy(stageKeys); return this; } @Override @SafeVarargs public final Builder stageKeys(String... stageKeys) { stageKeys(Arrays.asList(stageKeys)); return this; } public final Map getTags() { if (tags instanceof SdkAutoConstructMap) { return null; } return tags; } public final void setTags(Map tags) { this.tags = MapOfStringToStringCopier.copy(tags); } @Override public final Builder tags(Map tags) { this.tags = MapOfStringToStringCopier.copy(tags); return this; } @Override public CreateApiKeyResponse build() { return new CreateApiKeyResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy