troveclient.utils module

class troveclient.utils.HookableMixin

Bases: object

Mixin so classes can register and run hooks.

classmethod add_hook(hook_type, hook_func)
classmethod run_hooks(hook_type, *args, **kwargs)
troveclient.utils.add_arg(f, *args, **kwargs)

Bind CLI arguments to a shell.py do_foo function.

troveclient.utils.arg(*args, **kwargs)

Decorator for CLI args.

troveclient.utils.decode_data(data)

Encode the data using the base64 codec.

troveclient.utils.do_action_on_many(action, resources, success_msg, error_msg)

Helper to run an action on many resources.

troveclient.utils.do_action_with_msg(action, success_msg)

Helper to run an action with return message.

troveclient.utils.encode_data(data)

Encode the data using the base64 codec.

troveclient.utils.env(*vars, **kwargs)

Returns environment variables.

Returns the first environment variable set if none are non-empty, defaults to ‘’ or keyword arg default

troveclient.utils.find_resource(manager, name_or_id)

Helper for the _find_* methods.

This method should be replaced with osc_utils.find_resource()

troveclient.utils.get_project_id(manager, id_or_name)
troveclient.utils.get_resource_id(manager, id_or_name)
troveclient.utils.get_resource_id_by_name(manager, name)
troveclient.utils.get_service_type(f)

Retrieves service type from function.

troveclient.utils.is_admin(cs)
troveclient.utils.is_uuid_like(val)

Returns validation of a value as a UUID.

For our purposes, a UUID is a canonical form string: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa

troveclient.utils.isunauthenticated(f)

Decorator to mark authentication-non-required.

Checks to see if the function is marked as not requiring authentication with the @unauthenticated decorator. Returns True if decorator is set to True, False otherwise.

troveclient.utils.print_dict(d, key='Property')
troveclient.utils.print_list(objs, fields, formatters={}, order_by=None, obj_is_dict=False, labels={})
troveclient.utils.safe_issubclass(*args)

Like issubclass, but will just return False if not a class.

troveclient.utils.service_type(stype)

Adds ‘service_type’ attribute to decorated function.

Usage:

@service_type('database')
def mymethod(f):
    ...
troveclient.utils.translate_keys(collection, convert)
troveclient.utils.unauthenticated(f)

Adds ‘unauthenticated’ attribute to decorated function.

Usage:

@unauthenticated
def mymethod(f):
    ...