Skip to content

cattle_grid.extensions.examples.simple_register

Sample configuration

[[extensions]]
module = "cattle_grid.extensions.examples.simple_register"
api_prefix = "/simple_register"

[[extensions.config.registration_types]]
name = "dev"
permissions = ["dev"]
extra_parameters = ["fediverse"]

extension module-attribute

extension = Extension(
    "simple_register",
    __name__,
    config_class=RegisterConfiguration,
)

Definition of the extension

config

RegisterConfiguration

Bases: BaseModel

Configuration for the register endpoint

Parameters:

Name Type Description Default
registration_types list[RegistrationType]

List of registration types

required
Source code in cattle_grid/extensions/examples/simple_register/config.py
class RegisterConfiguration(BaseModel):
    """Configuration for the register endpoint"""

    registration_types: list[RegistrationType] = Field(
        examples=[
            RegistrationType(name="dev", permissions=["dev"]),
        ],
        description="List of registration types",
    )

RegistrationType

Bases: BaseModel

Configuration for one registration path

Parameters:

Name Type Description Default
name str

name of the registration. Will be part of the path, i.e. /register/{name}

required
permissions list[str]

List of permissions given to the registering account.

required
extra_parameters list[str]

Extra parameters that should be in the request, will be stored in the actors meta information

[]
Source code in cattle_grid/extensions/examples/simple_register/config.py
class RegistrationType(BaseModel):
    """Configuration for one registration path"""

    name: str = Field(
        examples=["dev"],
        description="name of the registration. Will be part of the path, i.e. `/register/{name}`",
    )

    permissions: list[str] = Field(
        examples=["admin"],
        description="List of permissions given to the registering account.",
    )

    extra_parameters: list[str] = Field(
        default=[],
        description="Extra parameters that should be in the request, will be stored in the actors meta information",
        examples=["fediverse"],
    )