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

software.amazon.awssdk.services.verifiedpermissions.model.GetSchemaResponse 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.verifiedpermissions.model;

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.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.TimestampFormatTrait;
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;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class GetSchemaResponse extends VerifiedPermissionsResponse implements
        ToCopyableBuilder {
    private static final SdkField POLICY_STORE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("policyStoreId").getter(getter(GetSchemaResponse::policyStoreId)).setter(setter(Builder::policyStoreId))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("policyStoreId").build()).build();

    private static final SdkField SCHEMA_FIELD = SdkField. builder(MarshallingType.STRING).memberName("schema")
            .getter(getter(GetSchemaResponse::schema)).setter(setter(Builder::schema))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("schema").build()).build();

    private static final SdkField CREATED_DATE_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("createdDate")
            .getter(getter(GetSchemaResponse::createdDate))
            .setter(setter(Builder::createdDate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdDate").build(),
                    TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();

    private static final SdkField LAST_UPDATED_DATE_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("lastUpdatedDate")
            .getter(getter(GetSchemaResponse::lastUpdatedDate))
            .setter(setter(Builder::lastUpdatedDate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("lastUpdatedDate").build(),
                    TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();

    private static final SdkField> NAMESPACES_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("namespaces")
            .getter(getter(GetSchemaResponse::namespaces))
            .setter(setter(Builder::namespaces))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("namespaces").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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(POLICY_STORE_ID_FIELD,
            SCHEMA_FIELD, CREATED_DATE_FIELD, LAST_UPDATED_DATE_FIELD, NAMESPACES_FIELD));

    private final String policyStoreId;

    private final String schema;

    private final Instant createdDate;

    private final Instant lastUpdatedDate;

    private final List namespaces;

    private GetSchemaResponse(BuilderImpl builder) {
        super(builder);
        this.policyStoreId = builder.policyStoreId;
        this.schema = builder.schema;
        this.createdDate = builder.createdDate;
        this.lastUpdatedDate = builder.lastUpdatedDate;
        this.namespaces = builder.namespaces;
    }

    /**
     * 

* The ID of the policy store that contains the schema. *

* * @return The ID of the policy store that contains the schema. */ public final String policyStoreId() { return policyStoreId; } /** *

* The body of the schema, written in Cedar schema JSON. *

* * @return The body of the schema, written in Cedar schema JSON. */ public final String schema() { return schema; } /** *

* The date and time that the schema was originally created. *

* * @return The date and time that the schema was originally created. */ public final Instant createdDate() { return createdDate; } /** *

* The date and time that the schema was most recently updated. *

* * @return The date and time that the schema was most recently updated. */ public final Instant lastUpdatedDate() { return lastUpdatedDate; } /** * For responses, this returns true if the service returned a value for the Namespaces 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 hasNamespaces() { return namespaces != null && !(namespaces instanceof SdkAutoConstructList); } /** *

* The namespaces of the entities referenced by this schema. *

*

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

* * @return The namespaces of the entities referenced by this schema. */ public final List namespaces() { return namespaces; } @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(policyStoreId()); hashCode = 31 * hashCode + Objects.hashCode(schema()); hashCode = 31 * hashCode + Objects.hashCode(createdDate()); hashCode = 31 * hashCode + Objects.hashCode(lastUpdatedDate()); hashCode = 31 * hashCode + Objects.hashCode(hasNamespaces() ? namespaces() : 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 GetSchemaResponse)) { return false; } GetSchemaResponse other = (GetSchemaResponse) obj; return Objects.equals(policyStoreId(), other.policyStoreId()) && Objects.equals(schema(), other.schema()) && Objects.equals(createdDate(), other.createdDate()) && Objects.equals(lastUpdatedDate(), other.lastUpdatedDate()) && hasNamespaces() == other.hasNamespaces() && Objects.equals(namespaces(), other.namespaces()); } /** * 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("GetSchemaResponse").add("PolicyStoreId", policyStoreId()) .add("Schema", schema() == null ? null : "*** Sensitive Data Redacted ***").add("CreatedDate", createdDate()) .add("LastUpdatedDate", lastUpdatedDate()) .add("Namespaces", namespaces() == null ? null : "*** Sensitive Data Redacted ***").build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "policyStoreId": return Optional.ofNullable(clazz.cast(policyStoreId())); case "schema": return Optional.ofNullable(clazz.cast(schema())); case "createdDate": return Optional.ofNullable(clazz.cast(createdDate())); case "lastUpdatedDate": return Optional.ofNullable(clazz.cast(lastUpdatedDate())); case "namespaces": return Optional.ofNullable(clazz.cast(namespaces())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GetSchemaResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends VerifiedPermissionsResponse.Builder, SdkPojo, CopyableBuilder { /** *

* The ID of the policy store that contains the schema. *

* * @param policyStoreId * The ID of the policy store that contains the schema. * @return Returns a reference to this object so that method calls can be chained together. */ Builder policyStoreId(String policyStoreId); /** *

* The body of the schema, written in Cedar schema JSON. *

* * @param schema * The body of the schema, written in Cedar schema JSON. * @return Returns a reference to this object so that method calls can be chained together. */ Builder schema(String schema); /** *

* The date and time that the schema was originally created. *

* * @param createdDate * The date and time that the schema was originally created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createdDate(Instant createdDate); /** *

* The date and time that the schema was most recently updated. *

* * @param lastUpdatedDate * The date and time that the schema was most recently updated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder lastUpdatedDate(Instant lastUpdatedDate); /** *

* The namespaces of the entities referenced by this schema. *

* * @param namespaces * The namespaces of the entities referenced by this schema. * @return Returns a reference to this object so that method calls can be chained together. */ Builder namespaces(Collection namespaces); /** *

* The namespaces of the entities referenced by this schema. *

* * @param namespaces * The namespaces of the entities referenced by this schema. * @return Returns a reference to this object so that method calls can be chained together. */ Builder namespaces(String... namespaces); } static final class BuilderImpl extends VerifiedPermissionsResponse.BuilderImpl implements Builder { private String policyStoreId; private String schema; private Instant createdDate; private Instant lastUpdatedDate; private List namespaces = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(GetSchemaResponse model) { super(model); policyStoreId(model.policyStoreId); schema(model.schema); createdDate(model.createdDate); lastUpdatedDate(model.lastUpdatedDate); namespaces(model.namespaces); } public final String getPolicyStoreId() { return policyStoreId; } public final void setPolicyStoreId(String policyStoreId) { this.policyStoreId = policyStoreId; } @Override public final Builder policyStoreId(String policyStoreId) { this.policyStoreId = policyStoreId; return this; } public final String getSchema() { return schema; } public final void setSchema(String schema) { this.schema = schema; } @Override public final Builder schema(String schema) { this.schema = schema; 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 getNamespaces() { if (namespaces instanceof SdkAutoConstructList) { return null; } return namespaces; } public final void setNamespaces(Collection namespaces) { this.namespaces = NamespaceListCopier.copy(namespaces); } @Override public final Builder namespaces(Collection namespaces) { this.namespaces = NamespaceListCopier.copy(namespaces); return this; } @Override @SafeVarargs public final Builder namespaces(String... namespaces) { namespaces(Arrays.asList(namespaces)); return this; } @Override public GetSchemaResponse build() { return new GetSchemaResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy