software.amazon.awssdk.services.ssmsap.model.Database Maven / Gradle / Ivy
Show all versions of ssmsap Show documentation
/*
* 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.ssmsap.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.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.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The SAP HANA database of the application registered with AWS Systems Manager for SAP.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Database implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField APPLICATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ApplicationId").getter(getter(Database::applicationId)).setter(setter(Builder::applicationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApplicationId").build()).build();
private static final SdkField COMPONENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ComponentId").getter(getter(Database::componentId)).setter(setter(Builder::componentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ComponentId").build()).build();
private static final SdkField> CREDENTIALS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Credentials")
.getter(getter(Database::credentials))
.setter(setter(Builder::credentials))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Credentials").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ApplicationCredential::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField DATABASE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseId").getter(getter(Database::databaseId)).setter(setter(Builder::databaseId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseId").build()).build();
private static final SdkField DATABASE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseName").getter(getter(Database::databaseName)).setter(setter(Builder::databaseName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseName").build()).build();
private static final SdkField DATABASE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DatabaseType").getter(getter(Database::databaseTypeAsString)).setter(setter(Builder::databaseType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DatabaseType").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
.getter(getter(Database::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(Database::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField PRIMARY_HOST_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrimaryHost").getter(getter(Database::primaryHost)).setter(setter(Builder::primaryHost))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrimaryHost").build()).build();
private static final SdkField SQL_PORT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("SQLPort").getter(getter(Database::sqlPort)).setter(setter(Builder::sqlPort))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SQLPort").build()).build();
private static final SdkField LAST_UPDATED_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastUpdated").getter(getter(Database::lastUpdated)).setter(setter(Builder::lastUpdated))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastUpdated").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(APPLICATION_ID_FIELD,
COMPONENT_ID_FIELD, CREDENTIALS_FIELD, DATABASE_ID_FIELD, DATABASE_NAME_FIELD, DATABASE_TYPE_FIELD, ARN_FIELD,
STATUS_FIELD, PRIMARY_HOST_FIELD, SQL_PORT_FIELD, LAST_UPDATED_FIELD));
private static final long serialVersionUID = 1L;
private final String applicationId;
private final String componentId;
private final List credentials;
private final String databaseId;
private final String databaseName;
private final String databaseType;
private final String arn;
private final String status;
private final String primaryHost;
private final Integer sqlPort;
private final Instant lastUpdated;
private Database(BuilderImpl builder) {
this.applicationId = builder.applicationId;
this.componentId = builder.componentId;
this.credentials = builder.credentials;
this.databaseId = builder.databaseId;
this.databaseName = builder.databaseName;
this.databaseType = builder.databaseType;
this.arn = builder.arn;
this.status = builder.status;
this.primaryHost = builder.primaryHost;
this.sqlPort = builder.sqlPort;
this.lastUpdated = builder.lastUpdated;
}
/**
*
* The ID of the application.
*
*
* @return The ID of the application.
*/
public final String applicationId() {
return applicationId;
}
/**
*
* The ID of the component.
*
*
* @return The ID of the component.
*/
public final String componentId() {
return componentId;
}
/**
* For responses, this returns true if the service returned a value for the Credentials 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 hasCredentials() {
return credentials != null && !(credentials instanceof SdkAutoConstructList);
}
/**
*
* The credentials 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 #hasCredentials} method.
*
*
* @return The credentials of the database.
*/
public final List credentials() {
return credentials;
}
/**
*
* The ID of the SAP HANA database.
*
*
* @return The ID of the SAP HANA database.
*/
public final String databaseId() {
return databaseId;
}
/**
*
* The name of the database.
*
*
* @return The name of the database.
*/
public final String databaseName() {
return databaseName;
}
/**
*
* The type of the database.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #databaseType} will
* return {@link DatabaseType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #databaseTypeAsString}.
*
*
* @return The type of the database.
* @see DatabaseType
*/
public final DatabaseType databaseType() {
return DatabaseType.fromValue(databaseType);
}
/**
*
* The type of the database.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #databaseType} will
* return {@link DatabaseType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #databaseTypeAsString}.
*
*
* @return The type of the database.
* @see DatabaseType
*/
public final String databaseTypeAsString() {
return databaseType;
}
/**
*
* The Amazon Resource Name (ARN) of the database.
*
*
* @return The Amazon Resource Name (ARN) of the database.
*/
public final String arn() {
return arn;
}
/**
*
* The status of the database.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link DatabaseStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the database.
* @see DatabaseStatus
*/
public final DatabaseStatus status() {
return DatabaseStatus.fromValue(status);
}
/**
*
* The status of the database.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link DatabaseStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the database.
* @see DatabaseStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The primary host of the database.
*
*
* @return The primary host of the database.
*/
public final String primaryHost() {
return primaryHost;
}
/**
*
* The SQL port of the database.
*
*
* @return The SQL port of the database.
*/
public final Integer sqlPort() {
return sqlPort;
}
/**
*
* The time at which the database was last updated.
*
*
* @return The time at which the database was last updated.
*/
public final Instant lastUpdated() {
return lastUpdated;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(applicationId());
hashCode = 31 * hashCode + Objects.hashCode(componentId());
hashCode = 31 * hashCode + Objects.hashCode(hasCredentials() ? credentials() : null);
hashCode = 31 * hashCode + Objects.hashCode(databaseId());
hashCode = 31 * hashCode + Objects.hashCode(databaseName());
hashCode = 31 * hashCode + Objects.hashCode(databaseTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(primaryHost());
hashCode = 31 * hashCode + Objects.hashCode(sqlPort());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdated());
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(applicationId(), other.applicationId()) && Objects.equals(componentId(), other.componentId())
&& hasCredentials() == other.hasCredentials() && Objects.equals(credentials(), other.credentials())
&& Objects.equals(databaseId(), other.databaseId()) && Objects.equals(databaseName(), other.databaseName())
&& Objects.equals(databaseTypeAsString(), other.databaseTypeAsString()) && Objects.equals(arn(), other.arn())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(primaryHost(), other.primaryHost())
&& Objects.equals(sqlPort(), other.sqlPort()) && Objects.equals(lastUpdated(), other.lastUpdated());
}
/**
* 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("ApplicationId", applicationId()).add("ComponentId", componentId())
.add("Credentials", hasCredentials() ? credentials() : null).add("DatabaseId", databaseId())
.add("DatabaseName", databaseName()).add("DatabaseType", databaseTypeAsString()).add("Arn", arn())
.add("Status", statusAsString()).add("PrimaryHost", primaryHost()).add("SQLPort", sqlPort())
.add("LastUpdated", lastUpdated()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ApplicationId":
return Optional.ofNullable(clazz.cast(applicationId()));
case "ComponentId":
return Optional.ofNullable(clazz.cast(componentId()));
case "Credentials":
return Optional.ofNullable(clazz.cast(credentials()));
case "DatabaseId":
return Optional.ofNullable(clazz.cast(databaseId()));
case "DatabaseName":
return Optional.ofNullable(clazz.cast(databaseName()));
case "DatabaseType":
return Optional.ofNullable(clazz.cast(databaseTypeAsString()));
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "PrimaryHost":
return Optional.ofNullable(clazz.cast(primaryHost()));
case "SQLPort":
return Optional.ofNullable(clazz.cast(sqlPort()));
case "LastUpdated":
return Optional.ofNullable(clazz.cast(lastUpdated()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function