001/*
002 * Copyright (c) 2026, Oracle and/or its affiliates.
003 *
004 * Licensed under the Universal Permissive License Version 1.0 as shown at
005 * https://oss.oracle.com/licenses/upl/
006 */
007package com.oracle.database.selectai.model;
008
009import java.util.Locale;
010
011/**
012 * Initial status values accepted by {@code DBMS_CLOUD_AI.CREATE_PROFILE}.
013 *
014 * @see <a href="https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/dbms-cloud-ai-package.html">
015 *      DBMS_CLOUD_AI.CREATE_PROFILE reference</a>
016 */
017public enum ProfileStatus {
018    /** Profile is enabled after creation. */
019    ENABLED("ENABLED"),
020    /** Profile is disabled after creation. */
021    DISABLED("DISABLED");
022
023    /** DBMS_CLOUD_AI status value. */
024    private final String value;
025
026    ProfileStatus(String value) {
027        this.value = value;
028    }
029
030    /**
031     * Returns the DBMS_CLOUD_AI status value.
032     *
033     * @return status value passed to CREATE_PROFILE
034     */
035    public String getValue() {
036        return value;
037    }
038
039    /**
040     * Parses a status value.
041     *
042     * @param value status text
043     * @return matching profile status, or {@code null} when input is null/blank
044     * @throws IllegalArgumentException when value is not enabled or disabled
045     */
046    public static ProfileStatus fromValue(String value) {
047        if (value == null || value.isBlank()) {
048            return null;
049        }
050        String normalized = value.trim().toUpperCase(Locale.ROOT);
051        return switch (normalized) {
052            case "ENABLED" -> ENABLED;
053            case "DISABLED" -> DISABLED;
054            default -> throw new IllegalArgumentException("status must be either ENABLED or DISABLED");
055        };
056    }
057}