001/*
002 *   Copyright 2024 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.application.capabilities;
017
018import com.fasterxml.jackson.annotation.JsonCreator;
019import com.fasterxml.jackson.annotation.JsonValue;
020
021/**
022 * Represents a Vonage region.
023 *
024 * @since 7.7.0
025 */
026public enum Region {
027        /**
028         * api-us-3.vonage.com (Virginia)
029         */
030        NA_EAST,
031
032        /**
033         * api-us-4.vonage.com (Oregon)
034         */
035        NA_WEST,
036
037        /**
038         * api-eu-3.vonage.com (Dublin)
039         */
040        EU_WEST,
041
042        /**
043         * api-eu-4.vonage.com (Frankfurt)
044         */
045        EU_EAST,
046
047        /**
048         * api-ap-3.vonage.com (Singapore)
049         */
050        APAC_SNG,
051
052        /**
053         * api-ap-4.vonage.com (Sydney)
054         */
055        APAC_AUSTRALIA;
056
057        @JsonValue
058        @Override
059        public String toString() {
060                return name().toLowerCase().replace("_", "-");
061        }
062
063        @JsonCreator
064        public static Region fromString(String value) {
065                try {
066                        return Region.valueOf(value.toUpperCase().replace("-", "_"));
067                }
068                catch (NullPointerException | IllegalArgumentException ex) {
069                        return null;
070                }
071        }
072}