001package gudusoft.gsqlparser.lineage.v2.model;
002
003import java.util.Arrays;
004import java.util.Collections;
005import java.util.List;
006import java.util.Map;
007
008/**
009 * The identity of an endpoint (Sections 6.3 and 10.6; algorithms/identity-v1.md, Section 4).
010 * Generated from the schema definition Identity by scripts/sqllr/gen_type_model.py; do not edit.
011 *
012 * @since 4.2.17
013 */
014public final class Identity extends SqllrObject {
015
016    /** The members the schema defines, in schema order. */
017    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("status", "id", "numericKey", "issuer", "algorithmId", "policyId", "comparisonDomain", "value"));
018
019    /** The members the schema requires. */
020    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("status"));
021
022    /** Reads a JSON object as a {@code Identity}. */
023    public static final Reader<Identity> READER = new Reader<Identity>() {
024        @Override
025        public Identity read(Object json) {
026            return fromJson(json);
027        }
028    };
029
030    private Identity(Map<String, Object> members) {
031        super(members);
032    }
033
034    /** A {@code Identity} with the members of a JSON object, all kept. */
035    public static Identity fromJson(Object json) {
036        return new Identity(members(json, "Identity"));
037    }
038
039    public static Builder builder() {
040        return new Builder(null);
041    }
042
043    /** A builder holding every member of this object. */
044    public Builder toBuilder() {
045        return new Builder(toJson());
046    }
047
048    /**
049     * The member {@code status}. The status of an endpoint identity. Registry group
050     * 'identityStatus' (Section 6.3). Null when absent; throws IllegalStateException when the
051     * member holds another JSON type.
052     */
053    public String getStatus() {
054        return string("status");
055    }
056
057    /**
058     * The member {@code id}. Present when status is PORTABLE (identity stage: ID_MISSING when
059     * absent). An id computed by EndpointIdV1: 'ep1-' followed by 64 lowercase hexadecimal
060     * characters of a SHA-256 digest (algorithms/identity-v1.md). Null when absent; throws
061     * IllegalStateException when the member holds another JSON type.
062     */
063    public String getId() {
064        return string("id");
065    }
066
067    /**
068     * The member {@code numericKey}. A 128-bit numeric key (NumericKeyV1): the first 16 bytes of
069     * the SHA-256 digest of an id, big-endian, as 32 lowercase hexadecimal characters, which are
070     * the first 32 hexadecimal characters of the id (Section 11.5; algorithms/identity-v1.md,
071     * Section 5.10). Consumers keep the full id as the authority. Null when absent; throws
072     * IllegalStateException when the member holds another JSON type.
073     */
074    public String getNumericKey() {
075        return string("numericKey");
076    }
077
078    /**
079     * The member {@code issuer}. Null when absent; throws IllegalStateException when the member
080     * holds another JSON type.
081     */
082    public String getIssuer() {
083        return string("issuer");
084    }
085
086    /**
087     * The member {@code algorithmId}. Null when absent; throws IllegalStateException when the
088     * member holds another JSON type.
089     */
090    public String getAlgorithmId() {
091        return string("algorithmId");
092    }
093
094    /**
095     * The member {@code policyId}. Null when absent; throws IllegalStateException when the member
096     * holds another JSON type.
097     */
098    public String getPolicyId() {
099        return string("policyId");
100    }
101
102    /**
103     * The member {@code comparisonDomain}. Null when absent; throws IllegalStateException when the
104     * member holds another JSON type.
105     */
106    public String getComparisonDomain() {
107        return string("comparisonDomain");
108    }
109
110    /**
111     * The member {@code value}. The opaque producer-local identity. Null when absent; throws
112     * IllegalStateException when the member holds another JSON type.
113     */
114    public String getValue() {
115        return string("value");
116    }
117
118    /** An endpoint with a portable identity (identity-v1, Section 4): its {@code ep1} id. */
119    public static Identity portable(String id) {
120        return builder().status("PORTABLE").id(id).build();
121    }
122
123    /** An endpoint whose identity is document-local (Section 3.2, rule 6). */
124    public static Identity local() {
125        return builder().status("LOCAL").build();
126    }
127
128    /**
129     * An endpoint whose portable identity is unavailable: {@code UNAVAILABLE_COLLATION} or
130     * {@code UNAVAILABLE_MIXED_PROFILE}.
131     */
132    public static Identity unavailable(String status) {
133        if (!"UNAVAILABLE_COLLATION".equals(status) && !"UNAVAILABLE_MIXED_PROFILE".equals(status)) {
134            throw new IllegalArgumentException("not an UNAVAILABLE_ status: " + status);
135        }
136        return builder().status(status).build();
137    }
138
139    /** An endpoint with an opaque producer-local identity, comparable only within its comparison domain. */
140    public static Identity opaque(String issuer, String algorithmId, String policyId, String comparisonDomain,
141                                  String value) {
142        return builder().status("OPAQUE_PRODUCER_LOCAL").issuer(issuer).algorithmId(algorithmId).policyId(policyId)
143                .comparisonDomain(comparisonDomain).value(value).build();
144    }
145
146    /** Collects the members of a new {@code Identity}. */
147    public static final class Builder extends SqllrObject.Builder<Identity, Builder> {
148        private Builder(Map<String, Object> from) {
149            super(from);
150        }
151
152        /** Sets the member {@code status}; null removes it. */
153        public Builder status(String value) {
154            return set("status", value);
155        }
156
157        /** Sets the member {@code id}; null removes it. */
158        public Builder id(String value) {
159            return set("id", value);
160        }
161
162        /** Sets the member {@code numericKey}; null removes it. */
163        public Builder numericKey(String value) {
164            return set("numericKey", value);
165        }
166
167        /** Sets the member {@code issuer}; null removes it. */
168        public Builder issuer(String value) {
169            return set("issuer", value);
170        }
171
172        /** Sets the member {@code algorithmId}; null removes it. */
173        public Builder algorithmId(String value) {
174            return set("algorithmId", value);
175        }
176
177        /** Sets the member {@code policyId}; null removes it. */
178        public Builder policyId(String value) {
179            return set("policyId", value);
180        }
181
182        /** Sets the member {@code comparisonDomain}; null removes it. */
183        public Builder comparisonDomain(String value) {
184            return set("comparisonDomain", value);
185        }
186
187        /** Sets the member {@code value}; null removes it. */
188        public Builder value(String value) {
189            return set("value", value);
190        }
191
192        @Override
193        public Identity build() {
194            return new Identity(frozenMembers());
195        }
196    }
197}