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

software.amazon.awssdk.services.glue.model.Database Maven / Gradle / Ivy

/*
 * 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.glue.model;

import java.io.Serializable;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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;

/**
 * 

* The Database object represents a logical grouping of tables that might reside in a Hive metastore or an * RDBMS. *

*/ @Generated("software.amazon.awssdk:codegen") public final class Database implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name") .getter(getter(Database::name)).setter(setter(Builder::name)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("Description").getter(getter(Database::description)).setter(setter(Builder::description)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build(); private static final SdkField LOCATION_URI_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("LocationUri").getter(getter(Database::locationUri)).setter(setter(Builder::locationUri)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LocationUri").build()).build(); private static final SdkField> PARAMETERS_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Parameters") .getter(getter(Database::parameters)) .setter(setter(Builder::parameters)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Parameters").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 SdkField CREATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("CreateTime").getter(getter(Database::createTime)).setter(setter(Builder::createTime)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreateTime").build()).build(); private static final SdkField> CREATE_TABLE_DEFAULT_PERMISSIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("CreateTableDefaultPermissions") .getter(getter(Database::createTableDefaultPermissions)) .setter(setter(Builder::createTableDefaultPermissions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreateTableDefaultPermissions") .build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(PrincipalPermissions::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField TARGET_DATABASE_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("TargetDatabase") .getter(getter(Database::targetDatabase)).setter(setter(Builder::targetDatabase)) .constructor(DatabaseIdentifier::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetDatabase").build()).build(); private static final SdkField CATALOG_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("CatalogId").getter(getter(Database::catalogId)).setter(setter(Builder::catalogId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CatalogId").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, DESCRIPTION_FIELD, LOCATION_URI_FIELD, PARAMETERS_FIELD, CREATE_TIME_FIELD, CREATE_TABLE_DEFAULT_PERMISSIONS_FIELD, TARGET_DATABASE_FIELD, CATALOG_ID_FIELD)); private static final long serialVersionUID = 1L; private final String name; private final String description; private final String locationUri; private final Map parameters; private final Instant createTime; private final List createTableDefaultPermissions; private final DatabaseIdentifier targetDatabase; private final String catalogId; private Database(BuilderImpl builder) { this.name = builder.name; this.description = builder.description; this.locationUri = builder.locationUri; this.parameters = builder.parameters; this.createTime = builder.createTime; this.createTableDefaultPermissions = builder.createTableDefaultPermissions; this.targetDatabase = builder.targetDatabase; this.catalogId = builder.catalogId; } /** *

* The name of the database. For Hive compatibility, this is folded to lowercase when it is stored. *

* * @return The name of the database. For Hive compatibility, this is folded to lowercase when it is stored. */ public final String name() { return name; } /** *

* A description of the database. *

* * @return A description of the database. */ public final String description() { return description; } /** *

* The location of the database (for example, an HDFS path). *

* * @return The location of the database (for example, an HDFS path). */ public final String locationUri() { return locationUri; } /** * For responses, this returns true if the service returned a value for the Parameters 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 hasParameters() { return parameters != null && !(parameters instanceof SdkAutoConstructMap); } /** *

* These key-value pairs define parameters and properties of the database. *

*

* 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 #hasParameters} method. *

* * @return These key-value pairs define parameters and properties of the database. */ public final Map parameters() { return parameters; } /** *

* The time at which the metadata database was created in the catalog. *

* * @return The time at which the metadata database was created in the catalog. */ public final Instant createTime() { return createTime; } /** * For responses, this returns true if the service returned a value for the CreateTableDefaultPermissions 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 hasCreateTableDefaultPermissions() { return createTableDefaultPermissions != null && !(createTableDefaultPermissions instanceof SdkAutoConstructList); } /** *

* Creates a set of default permissions on the table for principals. *

*

* 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 #hasCreateTableDefaultPermissions} method. *

* * @return Creates a set of default permissions on the table for principals. */ public final List createTableDefaultPermissions() { return createTableDefaultPermissions; } /** *

* A DatabaseIdentifier structure that describes a target database for resource linking. *

* * @return A DatabaseIdentifier structure that describes a target database for resource linking. */ public final DatabaseIdentifier targetDatabase() { return targetDatabase; } /** *

* The ID of the Data Catalog in which the database resides. *

* * @return The ID of the Data Catalog in which the database resides. */ public final String catalogId() { return catalogId; } @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 + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(description()); hashCode = 31 * hashCode + Objects.hashCode(locationUri()); hashCode = 31 * hashCode + Objects.hashCode(hasParameters() ? parameters() : null); hashCode = 31 * hashCode + Objects.hashCode(createTime()); hashCode = 31 * hashCode + Objects.hashCode(hasCreateTableDefaultPermissions() ? createTableDefaultPermissions() : null); hashCode = 31 * hashCode + Objects.hashCode(targetDatabase()); hashCode = 31 * hashCode + Objects.hashCode(catalogId()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Database)) { return false; } Database other = (Database) obj; return Objects.equals(name(), other.name()) && Objects.equals(description(), other.description()) && Objects.equals(locationUri(), other.locationUri()) && hasParameters() == other.hasParameters() && Objects.equals(parameters(), other.parameters()) && Objects.equals(createTime(), other.createTime()) && hasCreateTableDefaultPermissions() == other.hasCreateTableDefaultPermissions() && Objects.equals(createTableDefaultPermissions(), other.createTableDefaultPermissions()) && Objects.equals(targetDatabase(), other.targetDatabase()) && Objects.equals(catalogId(), other.catalogId()); } /** * 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("Database") .add("Name", name()) .add("Description", description()) .add("LocationUri", locationUri()) .add("Parameters", hasParameters() ? parameters() : null) .add("CreateTime", createTime()) .add("CreateTableDefaultPermissions", hasCreateTableDefaultPermissions() ? createTableDefaultPermissions() : null) .add("TargetDatabase", targetDatabase()).add("CatalogId", catalogId()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Name": return Optional.ofNullable(clazz.cast(name())); case "Description": return Optional.ofNullable(clazz.cast(description())); case "LocationUri": return Optional.ofNullable(clazz.cast(locationUri())); case "Parameters": return Optional.ofNullable(clazz.cast(parameters())); case "CreateTime": return Optional.ofNullable(clazz.cast(createTime())); case "CreateTableDefaultPermissions": return Optional.ofNullable(clazz.cast(createTableDefaultPermissions())); case "TargetDatabase": return Optional.ofNullable(clazz.cast(targetDatabase())); case "CatalogId": return Optional.ofNullable(clazz.cast(catalogId())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Database) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The name of the database. For Hive compatibility, this is folded to lowercase when it is stored. *

* * @param name * The name of the database. For Hive compatibility, this is folded to lowercase when it is stored. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** *

* A description of the database. *

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

* The location of the database (for example, an HDFS path). *

* * @param locationUri * The location of the database (for example, an HDFS path). * @return Returns a reference to this object so that method calls can be chained together. */ Builder locationUri(String locationUri); /** *

* These key-value pairs define parameters and properties of the database. *

* * @param parameters * These key-value pairs define parameters and properties of the database. * @return Returns a reference to this object so that method calls can be chained together. */ Builder parameters(Map parameters); /** *

* The time at which the metadata database was created in the catalog. *

* * @param createTime * The time at which the metadata database was created in the catalog. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createTime(Instant createTime); /** *

* Creates a set of default permissions on the table for principals. *

* * @param createTableDefaultPermissions * Creates a set of default permissions on the table for principals. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createTableDefaultPermissions(Collection createTableDefaultPermissions); /** *

* Creates a set of default permissions on the table for principals. *

* * @param createTableDefaultPermissions * Creates a set of default permissions on the table for principals. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createTableDefaultPermissions(PrincipalPermissions... createTableDefaultPermissions); /** *

* Creates a set of default permissions on the table for principals. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.glue.model.PrincipalPermissions.Builder} avoiding the need to create * one manually via {@link software.amazon.awssdk.services.glue.model.PrincipalPermissions#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.glue.model.PrincipalPermissions.Builder#build()} is called immediately * and its result is passed to {@link #createTableDefaultPermissions(List)}. * * @param createTableDefaultPermissions * a consumer that will call methods on * {@link software.amazon.awssdk.services.glue.model.PrincipalPermissions.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #createTableDefaultPermissions(java.util.Collection) */ Builder createTableDefaultPermissions(Consumer... createTableDefaultPermissions); /** *

* A DatabaseIdentifier structure that describes a target database for resource linking. *

* * @param targetDatabase * A DatabaseIdentifier structure that describes a target database for resource linking. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targetDatabase(DatabaseIdentifier targetDatabase); /** *

* A DatabaseIdentifier structure that describes a target database for resource linking. *

* This is a convenience method that creates an instance of the {@link DatabaseIdentifier.Builder} avoiding the * need to create one manually via {@link DatabaseIdentifier#builder()}. * *

* When the {@link Consumer} completes, {@link DatabaseIdentifier.Builder#build()} is called immediately and its * result is passed to {@link #targetDatabase(DatabaseIdentifier)}. * * @param targetDatabase * a consumer that will call methods on {@link DatabaseIdentifier.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #targetDatabase(DatabaseIdentifier) */ default Builder targetDatabase(Consumer targetDatabase) { return targetDatabase(DatabaseIdentifier.builder().applyMutation(targetDatabase).build()); } /** *

* The ID of the Data Catalog in which the database resides. *

* * @param catalogId * The ID of the Data Catalog in which the database resides. * @return Returns a reference to this object so that method calls can be chained together. */ Builder catalogId(String catalogId); } static final class BuilderImpl implements Builder { private String name; private String description; private String locationUri; private Map parameters = DefaultSdkAutoConstructMap.getInstance(); private Instant createTime; private List createTableDefaultPermissions = DefaultSdkAutoConstructList.getInstance(); private DatabaseIdentifier targetDatabase; private String catalogId; private BuilderImpl() { } private BuilderImpl(Database model) { name(model.name); description(model.description); locationUri(model.locationUri); parameters(model.parameters); createTime(model.createTime); createTableDefaultPermissions(model.createTableDefaultPermissions); targetDatabase(model.targetDatabase); catalogId(model.catalogId); } 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 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 String getLocationUri() { return locationUri; } public final void setLocationUri(String locationUri) { this.locationUri = locationUri; } @Override public final Builder locationUri(String locationUri) { this.locationUri = locationUri; return this; } public final Map getParameters() { if (parameters instanceof SdkAutoConstructMap) { return null; } return parameters; } public final void setParameters(Map parameters) { this.parameters = ParametersMapCopier.copy(parameters); } @Override public final Builder parameters(Map parameters) { this.parameters = ParametersMapCopier.copy(parameters); return this; } public final Instant getCreateTime() { return createTime; } public final void setCreateTime(Instant createTime) { this.createTime = createTime; } @Override public final Builder createTime(Instant createTime) { this.createTime = createTime; return this; } public final List getCreateTableDefaultPermissions() { List result = PrincipalPermissionsListCopier .copyToBuilder(this.createTableDefaultPermissions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setCreateTableDefaultPermissions( Collection createTableDefaultPermissions) { this.createTableDefaultPermissions = PrincipalPermissionsListCopier.copyFromBuilder(createTableDefaultPermissions); } @Override public final Builder createTableDefaultPermissions(Collection createTableDefaultPermissions) { this.createTableDefaultPermissions = PrincipalPermissionsListCopier.copy(createTableDefaultPermissions); return this; } @Override @SafeVarargs public final Builder createTableDefaultPermissions(PrincipalPermissions... createTableDefaultPermissions) { createTableDefaultPermissions(Arrays.asList(createTableDefaultPermissions)); return this; } @Override @SafeVarargs public final Builder createTableDefaultPermissions( Consumer... createTableDefaultPermissions) { createTableDefaultPermissions(Stream.of(createTableDefaultPermissions) .map(c -> PrincipalPermissions.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final DatabaseIdentifier.Builder getTargetDatabase() { return targetDatabase != null ? targetDatabase.toBuilder() : null; } public final void setTargetDatabase(DatabaseIdentifier.BuilderImpl targetDatabase) { this.targetDatabase = targetDatabase != null ? targetDatabase.build() : null; } @Override public final Builder targetDatabase(DatabaseIdentifier targetDatabase) { this.targetDatabase = targetDatabase; return this; } public final String getCatalogId() { return catalogId; } public final void setCatalogId(String catalogId) { this.catalogId = catalogId; } @Override public final Builder catalogId(String catalogId) { this.catalogId = catalogId; return this; } @Override public Database build() { return new Database(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy