The watcher.objects.strategy Module

class watcher.objects.strategy.Strategy(context=None, **kwargs)[source]

Bases: watcher.objects.base.WatcherPersistentObject, watcher.objects.base.WatcherObject, watcher.objects.base.WatcherObjectDictCompat

create(*args, **kwargs)[source]

Create a Strategy record in the DB.

Parameters:context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
Returns:A Strategy object.
destroy(context=None)[source]

Delete the Strategy from the DB.

Parameters:context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
classmethod get(context, *args, **kwargs)[source]

Find a strategy based on its id or uuid

Parameters:
  • context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
  • strategy_id – the id or uuid of a strategy.
  • eager – Load object fields if True (Default: False)
Returns:

A Strategy object.

classmethod get_by_id(context, *args, **kwargs)[source]

Find a strategy based on its integer id

Parameters:
  • context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
  • strategy_id – the id of a strategy.
  • eager – Load object fields if True (Default: False)
Returns:

A Strategy object.

classmethod get_by_name(context, *args, **kwargs)[source]

Find a strategy based on name

Parameters:
  • context – Security context
  • name – the name of a strategy.
  • eager – Load object fields if True (Default: False)
Returns:

A Strategy object.

classmethod get_by_uuid(context, *args, **kwargs)[source]

Find a strategy based on uuid

Parameters:
  • context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
  • uuid – the uuid of a strategy.
  • eager – Load object fields if True (Default: False)
Returns:

A Strategy object.

classmethod list(context, *args, **kwargs)[source]

Return a list of Strategy objects.

Parameters:
  • context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
  • limit – maximum number of resources to return in a single result.
  • marker – pagination marker for large data sets.
  • filters – dict mapping the filter key to a value.
  • sort_key – column to sort results by.
  • sort_dir – direction to sort. “asc” or “desc`”.
  • eager – Load object fields if True (Default: False)
Returns:

a list of Strategy object.

refresh(*args, **kwargs)[source]

Loads updates for this Strategy.

Loads a strategy with the same uuid from the database and checks for updated attributes. Updates are applied from the loaded strategy column by column, if there are any updates.

Parameters:
  • context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
  • eager – Load object fields if True (Default: False)
save(*args, **kwargs)[source]

Save updates to this Strategy.

Updates will be made column by column based on the result of self.what_changed().

Parameters:context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)
soft_delete(*args, **kwargs)[source]

Soft Delete the Strategy from the DB.

Parameters:context – Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don’t use it. A context should be set when instantiating the object, e.g.: Strategy(context)