The Enumeration Base Class

The base class of Smarter’s enumerations.

class smarter_types.enum.SmarterEnumAbstract(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

The base class of Smarter’s enumerations, whose values are strings.

It adds class methods that list the values, and the url slugs made from them. str() of a member is its value.

from smarter_types import SAMKinds

SAMKinds.all()  # ["Plugin", "ApiPlugin", ...]
str(SAMKinds.SECRET)  # "Secret"
classmethod all() → list[str][source]

Return every member’s value.

Returns:

The values, in the order in which the members are defined.

Return type:

list[str]

classmethod list_all() → str[source]

Return every member’s value, as one comma-separated string, e.g. for an error message.

Returns:

The values, separated by ", ".

Return type:

str

classmethod all_slugs() → list[str][source]

Return the url slugs of every value, singular and plural.

Returns:

singular_slugs(), then plural_slugs().

Return type:

list[str]

classmethod singular_slugs() → list[str][source]

Return the singular url slug of every value: the value, in lower case.

Returns:

The slugs, e.g. ["plugin", "apiplugin", ...].

Return type:

list[str]

classmethod plural_slugs() → list[str][source]

Return the plural url slug of every value: the value, in lower case, with an s.

Returns:

The slugs, e.g. ["plugins", "apiplugins", ...].

Return type:

list[str]

classmethod from_url(url: str | bytes) → str | None[source]

Return the first slug of a Smarter api url that is one of this enumeration’s slugs.

SAMKinds.from_url("http://localhost:9357/api/v1/cli/example_manifest/Account/")  # "account"
SAMKinds.from_url("http://localhost:9357/api/v1/cli/whoami/")  # None
Parameters:

url (str | bytes) – The url.

Returns:

The slug, in lower case, or None for a url that is not an api url, that is the whoami, status or version endpoint, or that has none of the slugs.

Return type:

str | None