magpie.cli.batch_update_permissions

Magpie helper to create or delete a set of permissions.

When parsing permissions to create, any underlying user, group, or intermediate resource that are missing, but that can be resolved with reasonable defaults or with an explicit definition in the configuration file, will be dynamically created prior to setting the corresponding permission on it. All referenced services should exist beforehand. Consider using the ‘register_providers’ utility to register services beforehand as needed.

See https://pavics-magpie.readthedocs.io/en/latest/configuration.html#file-permissions-cfg for more details.

Attributes

LOGGER

ERROR_PARAMS

ERROR_EXEC

Functions

make_logging_options(→ None)

Defines argument parser options for logging operations.

setup_logger_from_options(→ None)

Uses argument parser options to setup logging level from specified flags.

magpie_register_permissions_from_config(→ None)

Applies permissions specified in configuration(s) defined as file, directory with files or literal configuration.

get_logger(→ logging.Logger)

Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when

make_parser(→ argparse.ArgumentParser)

main(→ Any)

Module Contents

magpie.cli.batch_update_permissions.make_logging_options(parser: argparse.ArgumentParser) None[source]

Defines argument parser options for logging operations.

magpie.cli.batch_update_permissions.setup_logger_from_options(logger: logging.Logger, args: argparse.Namespace) None[source]

Uses argument parser options to setup logging level from specified flags.

Setup both the specific CLI logger that is provided and the generic magpie logger.

magpie.cli.batch_update_permissions.magpie_register_permissions_from_config(permissions_config: magpie.typedefs.Str | magpie.typedefs.PermissionsConfig, settings: magpie.typedefs.AnySettingsContainer | None = None, db_session: sqlalchemy.orm.session.Session | None = None, raise_errors: bool = False) None[source]

Applies permissions specified in configuration(s) defined as file, directory with files or literal configuration.

Parameters:
  • permissions_config – file/dir path to permissions config or JSON/YAML equivalent pre-loaded.

  • settings – Magpie settings to resolve an instance session when using requests instead of DB session. Will look for magpie.url, magpie.admin_user and magpie.admin_password by default, or any corresponding environment variable resolution if omitted in the settings.

  • db_session – db session to use instead of requests to directly create/remove permissions with config.

  • raise_errors – raises errors related to permissions, instead of just logging the info.

See also

magpie/config/permissions.cfg for specific parameters and operational details.

magpie.cli.batch_update_permissions.get_logger(name: magpie.typedefs.Str, level: int | None = None, force_stdout: bool = None, message_format: magpie.typedefs.Str | None = None, datetime_format: magpie.typedefs.Str | None = None) logging.Logger[source]

Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when level is logging.NOTSET.

magpie.cli.batch_update_permissions.LOGGER[source]
magpie.cli.batch_update_permissions.ERROR_PARAMS = 2[source]
magpie.cli.batch_update_permissions.ERROR_EXEC = 1[source]
magpie.cli.batch_update_permissions.make_parser() argparse.ArgumentParser[source]
magpie.cli.batch_update_permissions.main(args: Sequence[str] | None = None, parser: argparse.ArgumentParser | None = None, namespace: argparse.Namespace | None = None) Any[source]