pymapadmin.commands

pymapadmin.commands.load_commands(group='pymapadmin.commands')[source]

Load and return a map of command name to implementation class.

Parameters:

group (str) – The entry point group used to register commands.

Return type:

Mapping[str, type[Command]]

pymapadmin.commands.base

class pymapadmin.commands.base.Command(args, channel)[source]

Interface for command implementations.

Parameters:
  • args (Namespace) – The command-line arguments.

  • channel (Channel) – The GRPC channel for executing commands.

abstract classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

class pymapadmin.commands.base.ClientCommand(args, channel)[source]

Interface for client command implementations.

Parameters:
  • args (Namespace) – The command line arguments.

  • client – The client object.

  • channel (Channel) –

abstract property client: StubT

Get the client object for the command.

Parameters:

channel – The GRPC channel for executing commands.

abstract build_request()[source]

Build the request.

Return type:

RequestT

abstract handle_response(response, outfile, errfile)[source]

Handle each response. For streaming responses, this will be called once for each streamed response as long as 0 is returned.

Parameters:
  • response (ResponseT) – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

int

handle_exception(exc, outfile, errfile)[source]

Handle an exception that occurred while calling the RPC function.

Parameters:
  • exc (Exception) – The raised exception object.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

int

class pymapadmin.commands.base.AdminCommand(args, channel)[source]

Interface for admin command implementations.

The request and response must conform to the AdminRequestProtocol and AdminResponseProtocol protocols, respectively.

The default handle_response() implementation calls handle_success() or handle_failure() depending on the result code.

Parameters:
  • args (Namespace) – The command line arguments.

  • client – The client object.

  • channel (Channel) –

handle_response(response, outfile, errfile)[source]

Handle each response. For streaming responses, this will be called once for each streamed response as long as 0 is returned.

Parameters:
  • response (AdminResponseT) – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

int

handle_success(response, outfile, errfile)[source]

Print a successful response.

Parameters:
  • response (AdminResponseT) – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

None

handle_failure(response, outfile, errfile)[source]

Print a failure response.

Parameters:
  • response (AdminResponseT) – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

None

pymapadmin.commands.health

class pymapadmin.commands.health.CheckCommand(args, channel)[source]

Check the health of the server.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[HealthCheckRequest, HealthCheckResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

HealthCheckRequest

handle_response(response, outfile, errfile)[source]

Handle each response. For streaming responses, this will be called once for each streamed response as long as 0 is returned.

Parameters:
  • response (HealthCheckResponse) – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

int

pymapadmin.commands.system

class pymapadmin.commands.system.SaveArgsCommand(args, channel)[source]

Save the connection settings given as command-line arguments (e.g. –host, –port, etc) to a config file.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

class pymapadmin.commands.system.LoginCommand(args, channel)[source]

Login as a user for future requests.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[LoginRequest, LoginResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

LoginRequest

handle_success(response, outfile, errfile)[source]

Print a successful response.

Parameters:
  • response (LoginResponse) – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

None

class pymapadmin.commands.system.PingCommand(args, channel)[source]

Ping the server.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[PingRequest, PingResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

PingRequest

pymapadmin.commands.mailbox

class pymapadmin.commands.mailbox.AppendCommand(args, channel)[source]

Append a message directly to a user’s mailbox.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[AppendRequest, AppendResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

AppendRequest

handle_success(res, outfile, errfile)[source]

Print a successful response.

Parameters:
  • response – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

  • res (AppendResponse) –

Return type:

None

handle_failure(res, outfile, errfile)[source]

Print a failure response.

Parameters:
  • response – The response from the server.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

  • res (AppendResponse) –

Return type:

None

handle_exception(exc, outfile, errfile)[source]

Handle an exception that occurred while calling the RPC function.

Parameters:
  • exc (Exception) – The raised exception object.

  • outfile (TextIO) – The file object to print the output to.

  • errfile (TextIO) – The file object to print errors to.

Return type:

int

pymapadmin.commands.user

class pymapadmin.commands.user.GetUserCommand(args, channel)[source]

Print a user and its metadata.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[GetUserRequest, UserResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

GetUserRequest

class pymapadmin.commands.user.SetUserCommand(args, channel)[source]

Set the metadata for a user, creating it if it does not exist.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[SetUserRequest, UserResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

SetUserRequest

class pymapadmin.commands.user.ChangePasswordCommand(args, channel)[source]

Change a password for an existing user, without modifying any other metadata.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property first: GetUserCommand

The first step in the compound operation.

property second: SetUserCommand

The second step in the compound operation.

build_first(request)[source]

Build the request object for the first step.

Parameters:

request (_ChangePasswordRequest) – The compound operation request.

Return type:

GetUserRequest

build_second(request, first_response)[source]

Build the request object for the second step.

Parameters:
  • request (_ChangePasswordRequest) – The compound operation request.

  • first_response (UserResponse) – The response received by the first step.

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[SetUserRequest | None, UserResponse | None]

build_request()[source]

Build the request.

Return type:

_ChangePasswordRequest

class pymapadmin.commands.user.DeleteUserCommand(args, channel)[source]

Delete a user and its mail data.

Parameters:
  • args (Namespace) –

  • channel (Channel) –

classmethod add_subparser(name, subparsers)[source]

Add the command-line argument subparser for the command.

Parameters:
  • name (str) – The name to use for the subparser.

  • subparsers (Any) – The special action object as returned by add_subparsers().

Returns:

The new sub-parser object.

Return type:

ArgumentParser

property method: MethodProtocol[DeleteUserRequest, UserResponse]

The GRPC client method.

build_request()[source]

Build the request.

Return type:

DeleteUserRequest