software.amazon.awssdk.services.ram.model.ResourceShare Maven / Gradle / Ivy
Show all versions of ram 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.ram.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;
/**
*
* Describes a resource share in RAM.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ResourceShare implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField RESOURCE_SHARE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("resourceShareArn").getter(getter(ResourceShare::resourceShareArn))
.setter(setter(Builder::resourceShareArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceShareArn").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(ResourceShare::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField OWNING_ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("owningAccountId").getter(getter(ResourceShare::owningAccountId))
.setter(setter(Builder::owningAccountId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("owningAccountId").build()).build();
private static final SdkField ALLOW_EXTERNAL_PRINCIPALS_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("allowExternalPrincipals").getter(getter(ResourceShare::allowExternalPrincipals))
.setter(setter(Builder::allowExternalPrincipals))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("allowExternalPrincipals").build())
.build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(ResourceShare::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField STATUS_MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("statusMessage").getter(getter(ResourceShare::statusMessage)).setter(setter(Builder::statusMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("statusMessage").build()).build();
private static final SdkField> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("tags")
.getter(getter(ResourceShare::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("creationTime").getter(getter(ResourceShare::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("creationTime").build()).build();
private static final SdkField LAST_UPDATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("lastUpdatedTime").getter(getter(ResourceShare::lastUpdatedTime))
.setter(setter(Builder::lastUpdatedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastUpdatedTime").build()).build();
private static final SdkField FEATURE_SET_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("featureSet").getter(getter(ResourceShare::featureSetAsString)).setter(setter(Builder::featureSet))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("featureSet").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RESOURCE_SHARE_ARN_FIELD,
NAME_FIELD, OWNING_ACCOUNT_ID_FIELD, ALLOW_EXTERNAL_PRINCIPALS_FIELD, STATUS_FIELD, STATUS_MESSAGE_FIELD, TAGS_FIELD,
CREATION_TIME_FIELD, LAST_UPDATED_TIME_FIELD, FEATURE_SET_FIELD));
private static final long serialVersionUID = 1L;
private final String resourceShareArn;
private final String name;
private final String owningAccountId;
private final Boolean allowExternalPrincipals;
private final String status;
private final String statusMessage;
private final List tags;
private final Instant creationTime;
private final Instant lastUpdatedTime;
private final String featureSet;
private ResourceShare(BuilderImpl builder) {
this.resourceShareArn = builder.resourceShareArn;
this.name = builder.name;
this.owningAccountId = builder.owningAccountId;
this.allowExternalPrincipals = builder.allowExternalPrincipals;
this.status = builder.status;
this.statusMessage = builder.statusMessage;
this.tags = builder.tags;
this.creationTime = builder.creationTime;
this.lastUpdatedTime = builder.lastUpdatedTime;
this.featureSet = builder.featureSet;
}
/**
*
* The Amazon Resoure Name
* (ARN) of the resource share
*
*
* @return The Amazon Resoure
* Name (ARN) of the resource share
*/
public final String resourceShareArn() {
return resourceShareArn;
}
/**
*
* The name of the resource share.
*
*
* @return The name of the resource share.
*/
public final String name() {
return name;
}
/**
*
* The ID of the Amazon Web Services account that owns the resource share.
*
*
* @return The ID of the Amazon Web Services account that owns the resource share.
*/
public final String owningAccountId() {
return owningAccountId;
}
/**
*
* Indicates whether principals outside your organization in Organizations can be associated with a resource share.
*
*
* @return Indicates whether principals outside your organization in Organizations can be associated with a resource
* share.
*/
public final Boolean allowExternalPrincipals() {
return allowExternalPrincipals;
}
/**
*
* The current status of the resource share.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link ResourceShareStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The current status of the resource share.
* @see ResourceShareStatus
*/
public final ResourceShareStatus status() {
return ResourceShareStatus.fromValue(status);
}
/**
*
* The current status of the resource share.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link ResourceShareStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The current status of the resource share.
* @see ResourceShareStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* A message about the status of the resource share.
*
*
* @return A message about the status of the resource share.
*/
public final String statusMessage() {
return statusMessage;
}
/**
* 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 SdkAutoConstructList);
}
/**
*
* The tag key and value pairs attached to the resource share.
*
*
* 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 tag key and value pairs attached to the resource share.
*/
public final List tags() {
return tags;
}
/**
*
* The date and time when the resource share was created.
*
*
* @return The date and time when the resource share was created.
*/
public final Instant creationTime() {
return creationTime;
}
/**
*
* The date and time when the resource share was last updated.
*
*
* @return The date and time when the resource share was last updated.
*/
public final Instant lastUpdatedTime() {
return lastUpdatedTime;
}
/**
*
* Indicates how the resource share was created. Possible values include:
*
*
* -
*
* CREATED_FROM_POLICY
- Indicates that the resource share was created from an Identity and Access
* Management (IAM) resource-based permission policy attached to the resource. This type of resource share is
* visible only to the Amazon Web Services account that created it. You can't modify it in RAM unless you promote
* it. For more information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* PROMOTING_TO_STANDARD
- The resource share is in the process of being promoted. For more
* information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* STANDARD
- Indicates that the resource share was created in RAM using the console or APIs. These
* resource shares are visible to all principals you share the resource share with. You can modify these resource
* shares in RAM using the console or APIs.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #featureSet} will
* return {@link ResourceShareFeatureSet#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #featureSetAsString}.
*
*
* @return Indicates how the resource share was created. Possible values include:
*
* -
*
* CREATED_FROM_POLICY
- Indicates that the resource share was created from an Identity and
* Access Management (IAM) resource-based permission policy attached to the resource. This type of resource
* share is visible only to the Amazon Web Services account that created it. You can't modify it in RAM
* unless you promote it. For more information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* PROMOTING_TO_STANDARD
- The resource share is in the process of being promoted. For more
* information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* STANDARD
- Indicates that the resource share was created in RAM using the console or APIs.
* These resource shares are visible to all principals you share the resource share with. You can modify
* these resource shares in RAM using the console or APIs.
*
*
* @see ResourceShareFeatureSet
*/
public final ResourceShareFeatureSet featureSet() {
return ResourceShareFeatureSet.fromValue(featureSet);
}
/**
*
* Indicates how the resource share was created. Possible values include:
*
*
* -
*
* CREATED_FROM_POLICY
- Indicates that the resource share was created from an Identity and Access
* Management (IAM) resource-based permission policy attached to the resource. This type of resource share is
* visible only to the Amazon Web Services account that created it. You can't modify it in RAM unless you promote
* it. For more information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* PROMOTING_TO_STANDARD
- The resource share is in the process of being promoted. For more
* information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* STANDARD
- Indicates that the resource share was created in RAM using the console or APIs. These
* resource shares are visible to all principals you share the resource share with. You can modify these resource
* shares in RAM using the console or APIs.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #featureSet} will
* return {@link ResourceShareFeatureSet#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #featureSetAsString}.
*
*
* @return Indicates how the resource share was created. Possible values include:
*
* -
*
* CREATED_FROM_POLICY
- Indicates that the resource share was created from an Identity and
* Access Management (IAM) resource-based permission policy attached to the resource. This type of resource
* share is visible only to the Amazon Web Services account that created it. You can't modify it in RAM
* unless you promote it. For more information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* PROMOTING_TO_STANDARD
- The resource share is in the process of being promoted. For more
* information, see PromoteResourceShareCreatedFromPolicy.
*
*
* -
*
* STANDARD
- Indicates that the resource share was created in RAM using the console or APIs.
* These resource shares are visible to all principals you share the resource share with. You can modify
* these resource shares in RAM using the console or APIs.
*
*
* @see ResourceShareFeatureSet
*/
public final String featureSetAsString() {
return featureSet;
}
@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(resourceShareArn());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(owningAccountId());
hashCode = 31 * hashCode + Objects.hashCode(allowExternalPrincipals());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusMessage());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedTime());
hashCode = 31 * hashCode + Objects.hashCode(featureSetAsString());
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 ResourceShare)) {
return false;
}
ResourceShare other = (ResourceShare) obj;
return Objects.equals(resourceShareArn(), other.resourceShareArn()) && Objects.equals(name(), other.name())
&& Objects.equals(owningAccountId(), other.owningAccountId())
&& Objects.equals(allowExternalPrincipals(), other.allowExternalPrincipals())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(statusMessage(), other.statusMessage()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags()) && Objects.equals(creationTime(), other.creationTime())
&& Objects.equals(lastUpdatedTime(), other.lastUpdatedTime())
&& Objects.equals(featureSetAsString(), other.featureSetAsString());
}
/**
* 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("ResourceShare").add("ResourceShareArn", resourceShareArn()).add("Name", name())
.add("OwningAccountId", owningAccountId()).add("AllowExternalPrincipals", allowExternalPrincipals())
.add("Status", statusAsString()).add("StatusMessage", statusMessage()).add("Tags", hasTags() ? tags() : null)
.add("CreationTime", creationTime()).add("LastUpdatedTime", lastUpdatedTime())
.add("FeatureSet", featureSetAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "resourceShareArn":
return Optional.ofNullable(clazz.cast(resourceShareArn()));
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "owningAccountId":
return Optional.ofNullable(clazz.cast(owningAccountId()));
case "allowExternalPrincipals":
return Optional.ofNullable(clazz.cast(allowExternalPrincipals()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "statusMessage":
return Optional.ofNullable(clazz.cast(statusMessage()));
case "tags":
return Optional.ofNullable(clazz.cast(tags()));
case "creationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
case "lastUpdatedTime":
return Optional.ofNullable(clazz.cast(lastUpdatedTime()));
case "featureSet":
return Optional.ofNullable(clazz.cast(featureSetAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function