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.Arrays;
010
011/**
012 * Select AI provider identifiers currently recognized by the SDK.
013 * <p>
014 * This enum is used for creation and update validation. Existing database
015 * profiles may contain provider values introduced by a newer database release;
016 * profile metadata hydration preserves those values as strings instead of
017 * requiring them to be present in this enum.
018 *
019 * @see <a href="https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/select-ai-manage-profiles.html">
020 *      Select AI profile provider configuration</a>
021 */
022public enum Provider {
023    /** OpenAI provider. */
024    openai,
025    /** Cohere provider. */
026    cohere,
027    /** Azure OpenAI provider. */
028    azure,
029    /** In-database Select AI provider. */
030    database,
031    /** OCI Generative AI provider. */
032    oci,
033    /** Google provider. */
034    google,
035    /** Anthropic provider. */
036    anthropic,
037    /** Hugging Face provider. */
038    huggingface,
039    /** AWS Bedrock provider. */
040    aws;
041
042    /**
043     * Parses a provider name using case-insensitive matching.
044     *
045     * @param value provider name supplied to a creation or update builder
046     * @return matching provider enum constant, or {@code null} when input is null/blank
047     */
048    public static Provider fromValue(String value) {
049        if (value == null || value.isBlank()) {
050            return null;
051        }
052        return Arrays.stream(values())
053                .filter(provider -> provider.name().equalsIgnoreCase(value))
054                .findFirst()
055                .orElseThrow(() -> new IllegalArgumentException("Unsupported provider: " + value));
056    }
057}