pymapadmin

pymapadmin.is_compatible(client_version, server_version)[source]

Check if the given client version is backwards- and forwards-compatible with the server version.

Parameters:
  • client_version (str) – The provided client version string.

  • server_version (str) – The server version string, usually found in pymapadmin.__about__.__version__.

Return type:

bool

pymapadmin.local

class pymapadmin.local.LocalFile(envvar, filename)[source]

Defines a file that is kept on the local filesystem but could be in a number of different places.

Parameters:
  • envvar (str) – The environment variable used to custom the file path.

  • filename (str) – The default filename.

property add_action: type[Action]

Use as an action= in argparse to add command-line arguments as custom paths.

property custom: Sequence[Path]

The custom paths added by add(), followed by any path specified by environment variable.

add(*custom)[source]

Append the custom paths to custom.

Parameters:

custom (None | str | Path) – The custom paths to the file, e.g. from config or command-line.

Return type:

None

get_home(*, mkdir=False)[source]

Returns filename inside ~/.config/pymap/. If custom is not empty, its first value is returned instead.

Parameters:

mkdir (bool) – Whether any intermediate directories should be created.

Return type:

Path

get_temp(*, mkdir=False)[source]

Returns filename inside the pymap/ subdirectory of gettempdir(). If custom is not empty, its first value is returned instead.

Parameters:

mkdir (bool) – Whether any intermediate directories should be created.

Return type:

Path

get_all()[source]

Return all the paths that may contain the file.

Return type:

Sequence[Path]

find()[source]

Return the Path of an existing file, if one exists.

The order of searched paths looks like this:

  1. The custom paths.

  2. A path defined in the envvar environment variable.

  3. filename in ~/.config/pymap/.

  4. filename in the pymap subdirectory of tempfile.gettempdir().

Return type:

Path | None

pymapadmin.local.config_file = <pymapadmin.local.LocalFile object>

The config file for default command-line arguments.

pymapadmin.local.token_file = <pymapadmin.local.LocalFile object>

The token file for pymap-admin authentication.

pymapadmin.local.socket_file = <pymapadmin.local.LocalFile object>

The socket file for connecting to a running pymap server.

pymapadmin.operation

class pymapadmin.operation.CompoundRequestT

Type variable for the compound request in CompoundOperation.

alias of TypeVar(‘CompoundRequestT’)

class pymapadmin.operation.FirstResponseT

Type variable for the first response in CompoundOperation.

alias of TypeVar(‘FirstResponseT’)

class pymapadmin.operation.SecondRequestT

Type variable for the second request in CompoundOperation.

alias of TypeVar(‘SecondRequestT’)

class pymapadmin.operation.Operation[source]

Base class for a GRPC operation.

get_metadata()[source]

Get the GRPC metadata to use for the operation.

Return type:

Mapping[str, str]

abstract async execute(request)[source]

Execute the operation and return the response.

Parameters:

request (RequestT) – The operation request.

Return type:

ResponseT

class pymapadmin.operation.SingleOperation[source]

Implements Operation using a single GRPC call.

abstract property method: MethodProtocol[RequestT, ResponseT]

The GRPC client method.

async execute(request)[source]

Execute the operation and return the response.

Parameters:

request (RequestT) – The operation request.

Return type:

ResponseT

class pymapadmin.operation.CompoundOperation[source]

Implements Operation using two steps. The second step may rely on the response of the first step.

abstract property first: Operation[RequestT, FirstResponseT]

The first step in the compound operation.

abstract property second: Operation[SecondRequestT, ResponseT]

The second step in the compound operation.

abstract build_first(request)[source]

Build the request object for the first step.

Parameters:

request (CompoundRequestT) – The compound operation request.

Return type:

RequestT

abstract build_second(request, first_response)[source]

Build the request object for the second step.

Parameters:
Returns:

If the second step should proceed, returns a two-tuple where the first item is the request object for the second step and the second item is ignored.

If the compound request should be aborted, returns a two-tuple where the first item is None and the second item can be a response to use instead of executing the second step.

If both items in the tuple are None, the compound operation raises a RuntimeError displaying the response to the first step.

Return type:

tuple[SecondRequestT | None, ResponseT | None]

async execute(request)[source]

Execute the operation and return the response.

Parameters:

request (CompoundRequestT) – The operation request.

Return type:

ResponseT

pymapadmin.typing

class pymapadmin.typing.StubT

A type variable corresponding to an admin stub object.

alias of TypeVar(‘StubT’)

class pymapadmin.typing.RequestT

A type variable corresponding to an request object.

alias of TypeVar(‘RequestT’)

class pymapadmin.typing.ResponseT

A type variable corresponding to an response object.

alias of TypeVar(‘ResponseT’)

class pymapadmin.typing.MethodProtocol(*args, **kwargs)[source]

Protocol defining an admin method, for a command.

class pymapadmin.typing.AdminRequestProtocol(*args, **kwargs)[source]

Protocol defining the fields that all admin request objects are expected to have.

Note

There are currently no fields common to all requests.

class pymapadmin.typing.AdminResponseProtocol(*args, **kwargs)[source]

Protocol defining the fields that all admin response objects are expected to have.

abstract property result: Result

The result protobuf, containing a code and additional data.