// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.security.keyvault.administration.models;

import com.azure.core.util.ExpandableStringEnum;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;

/** The role scope. */
public final class KeyVaultRoleScope extends ExpandableStringEnum<KeyVaultRoleScope> {

    /** Global scope. */
    public static final KeyVaultRoleScope GLOBAL = fromString("/");

    /** Keys scope. */
    public static final KeyVaultRoleScope KEYS = fromString("/keys");

    /**
     * Creates a new instance of KeyVaultRoleScope value.
     *
     * @deprecated Use the {@link #fromString(String)} factory method.
     */
    @Deprecated
    public KeyVaultRoleScope() {}

    /**
     * Creates or finds a KeyVaultRoleScope from its string representation.
     *
     * @param name a name to look for.
     * @return the corresponding KeyVaultRoleScope.
     */
    public static KeyVaultRoleScope fromString(String name) {
        return fromString(name, KeyVaultRoleScope.class);
    }

    /**
     * Gets known KeyVaultRoleScope values.
     *
     * @return known KeyVaultRoleScope values.
     */
    public static Collection<KeyVaultRoleScope> values() {
        return values(KeyVaultRoleScope.class);
    }

    /**
     * /** Creates of finds a {@link KeyVaultRoleScope} from its string representation.
     *
     * @param url A string representing a URL containing the name of the scope to look for.
     * @return The corresponding {@link KeyVaultRoleScope}.
     * @throws IllegalArgumentException If the given {@code url} is malformed. /
     */
    public static KeyVaultRoleScope fromUrl(String url) {
        try {
            return fromString(new URL(url).getPath());
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(e);
        }
    }

    /**
     * /** Creates of finds a {@link KeyVaultRoleScope} from its string representation.
     *
     * @param url A URL containing the name of the scope to look for.
     * @return The corresponding {@link KeyVaultRoleScope}. /
     */
    public static KeyVaultRoleScope fromUrl(URL url) {
        return fromString(url.getPath());
    }
}
