001package com.nimbusds.infinispan.persistence.dynamodb.config;
002
003
004import java.util.HashMap;
005import java.util.Map;
006
007
008/**
009 * DynamoDB store XML configuration attributes.
010 */
011public enum Attribute {
012        
013        
014        /**
015         * Unknown XML attribute.
016         */
017        UNKNOWN(null), // must be first
018        
019        
020        /**
021         * The XML attribute for the DynamoDB endpoint. If set region is
022         * overridden.
023         */
024        ENDPOINT("endpoint"),
025        
026        
027        /**
028         * The XML attribute for the DynamoDB region.
029         */
030        REGION("region"),
031        
032        
033        /**
034         * The XML attribute for the DynamoDB item transformer.
035         */
036        ITEM_TRANSFORMER("item-transformer"),
037        
038        
039        /**
040         * The XML attribute for the DynamoDB query executor.
041         */
042        QUERY_EXECUTOR("query-executor"),
043        
044        
045        /**
046         * The XML attribute for the indexed DynamoDB table attributes.
047         */
048        INDEXED_ATTRIBUTES("indexed-attributes"),
049        
050        
051        /**
052         * The XML attribute consistent reads, defaults to
053         * {@code false}.
054         */
055        CONSISTENT_READS("consistent-reads"),
056        
057        
058        /**
059         * The XML attribute for the read capacity to provision when creating
060         * a new DynamoDB table and indices.
061         */
062        READ_CAPACITY("read-capacity"),
063        
064        
065        /**
066         * The XML attribute for the write capacity to provision when creating
067         * a new DynamoDB table and indices.
068         */
069        WRITE_CAPACITY("write-capacity"),
070        
071        
072        /**
073         * The XML attribute for creating the DynamoDB table with encryption at
074         * rest.
075         */
076        ENCRYPTION_AT_REST("encryption-at-rest"),
077        
078        
079        /**
080         * The XML attribute for the optional DynamoDB table prefix to use.
081         */
082        TABLE_PREFIX("table-prefix"),
083        
084        
085        /**
086         * The XML attribute for the optional range key to apply to all
087         * DynamoDB operations.
088         */
089        APPLY_RANGE_KEY("apply-range-key"),
090        
091        
092        /**
093         * The XML attribute for the optional value of the range key.
094         */
095        RANGE_KEY_VALUE("range-key-value"),
096        
097        
098        /**
099         * The XML attribute to enable a stream for a global table, defaults to
100         * {@code false}.
101         */
102        ENABLE_STREAM("enable-stream"),
103        
104        
105        /**
106         * The XML attribute to enable continuous backups / point in time
107         * recovery, defaults to {@code false}.
108         */
109        ENABLE_CONTINUOUS_BACKUPS("enable-continuous-backups"),
110        
111        
112        /**
113         * The XML attribute to enable DynamoDB item expiration, defaults to
114         * {@code false}.
115         */
116        ENABLE_TTL("enable-ttl"),
117        
118        
119        /**
120         * The XML attribute for limiting the number of expired entries per run
121         * of the purge task.
122         */
123        PURGE_LIMIT("purge-limit"),
124        
125        
126        /**
127         * The XML attribute for specifying an HTTP proxy host.
128         */
129        HTTP_PROXY_HOST("http-proxy-host"),
130        
131        
132        /**
133         * The XML attribute for specifying an HTTP proxy port.
134         */
135        HTTP_PROXY_PORT("http-proxy-port"),
136        
137        
138        /**
139         * The HMAC SHA-256 key, BASE-64 encoded.
140         */
141        HMAC_SHA256_KEY("hmac-sha256-key");
142        
143        
144        /**
145         * The attribute name.
146         */
147        private final String name;
148        
149        
150        /**
151         * Creates a new attribute with the specified name.
152         *
153         * @param name The attribute name.
154         */
155        Attribute(final String name) {
156                this.name = name;
157        }
158        
159        
160        /**
161         * Gets the local name of this attribute.
162         *
163         * @return The local name.
164         */
165        public String getLocalName() {
166                return name;
167        }
168        
169        
170        /**
171         * The enumerated attributes as map.
172         */
173        private static final Map<String, Attribute> attributes;
174        
175        
176        static {
177                final Map<String, Attribute> map = new HashMap<>();
178                for (Attribute attribute : values()) {
179                        final String name = attribute.getLocalName();
180                        if (name != null) {
181                                map.put(name, attribute);
182                        }
183                }
184                attributes = map;
185        }
186        
187        
188        /**
189         * Returns the matching attribute for the specified local name.
190         *
191         * @param localName The local name.
192         *
193         * @return The attribute.
194         */
195        public static Attribute forName(final String localName) {
196                final Attribute attribute = attributes.get(localName);
197                return attribute == null ? UNKNOWN : attribute;
198        }
199}