waterbutler.core package

waterbutler.core.auth module

class waterbutler.core.auth.AuthType[source]

Bases: enum.Enum

An enumeration.

SOURCE = 0
DESTINATION = 1
class waterbutler.core.auth.BaseAuthHandler[source]

Bases: object

fetch(request, bundle)[source]
get(resource, provider, request, action=None, auth_type=<AuthType.SOURCE: 0>, path='', version=None)[source]

waterbutler.core.exceptions module

waterbutler.core.log_payload module

waterbutler.core.logging module

class waterbutler.core.logging.MaskFormatter(fmt=None, datefmt=None, style='%', pattern=None, mask='***')[source]

Bases: logging.Formatter

format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

waterbutler.core.metadata module

waterbutler.core.metrics module

class waterbutler.core.metrics.MetricsBase[source]

Bases: object

Lightweight wrapper around a dict to make keeping track of metrics a little easier.

Current functionality is limited, but may be extended later. To do:

  • update/override method to indicate expectations of existing key

    self.metrics.add_default(‘some.flag’, True) <later> self.metrics.override(‘some.flag’, False) # dies if ‘some.flag’ doesn’t already exist

  • optional type validation?

    self.metrics.add(‘some.flag’, True, bool()) -or- self.metrics.define(‘some.flag’, bool()) <later> self.metrics.add(‘some.flag’, ‘foobar’) # dies, ‘foobar’ isn’t a bool

key()[source]

ID string for this object

add(key, value)[source]

add() stores the given value under the given key. Subkeys can be specified by placing a dot between the parent and child keys. e.g. ‘foo.bar’ will be interpreted as self._metrics['foo']['bar']

Parameters:
  • key (str) – the key to store value under
  • value – the value to store, type unrestricted
incr(key)[source]

incr() increments the value stored in key, or initializes it to 1 if it has not yet been set.

Parameters:key (str) – the key to increment the value of
append(key, new_value)[source]

Assume key points to a list and append new_value to it. Will initialize a list if key is undefined. Type homogeneity of list members is not enforced.

Parameters:
  • key (str) – the key to store value under
  • value – the value to store, type unrestricted
merge(record)[source]

Merges a dict into the current metrics.

Parameters:record (dict) – a dict to merge with the current metrics
serialize()[source]

Return a copy of the metrics

manifesto()[source]

‘This is who I am and this is what I stand for!’

Returns a dict with one entry: our key pointing to our metrics

class waterbutler.core.metrics.MetricsRecord(category)[source]

Bases: waterbutler.core.metrics.MetricsBase

An extension to MetricsBase that carries a category and list of submetrics. When serialized, will include the serialized child metrics

key

ID string for this record: ‘{category}’

serialize()[source]

Returns its metrics with the metrics for each of the subrecords included under their key.

new_subrecord(name)[source]

Create a new MetricsSubRecord object with our category and save it to the subrecords list.

class waterbutler.core.metrics.MetricsSubRecord(category, name)[source]

Bases: waterbutler.core.metrics.MetricsRecord

An extension to MetricsRecord that carries a name in addition to a category. Will identify itself as {category}_{name}. Can create its own subrecord whose category will be this subrecord’s name.

key

ID string for this subrecord: ‘{category}_{name}’

new_subrecord(name)[source]

Creates and saves a new subrecord. The new subrecord will have its category set to the parent subrecord’s name. ex:

parent = MetricsRecord('foo')
child = parent.new_subrecord('bar')
grandchild = child.new_subrecord('baz')

print(parent.key)      # foo
print(child.key)       # foo_bar
print(grandchild.key)  # bar_baz

waterbutler.core.path module

waterbutler.core.provider module

waterbutler.core.remote_logging module

waterbutler.core.signing module

waterbutler.core.signing.order_recursive(data)[source]

Recursively sort keys of input data and all its nested dictionaries. Used to ensure consistent ordering of JSON payloads.

waterbutler.core.signing.serialize_payload(payload)[source]
waterbutler.core.signing.unserialize_payload(message)[source]
class waterbutler.core.signing.Signer(secret, digest)[source]

Bases: object

sign_message(message)[source]
sign_payload(payload)[source]
verify_message(signature, message)[source]
verify_payload(signature, payload)[source]
waterbutler.core.signing.sign_data(signer, data, ttl=100)[source]

waterbutler.core.utils module

Module contents