api.utils

Helper functions used by the Deis server.

api.utils.dict_diff(dict1, dict2)[source]

Returns the added, changed, and deleted items in dict1 compared with dict2.

Parameters:
  • dict1 – a python dict
  • dict2 – an earlier version of the same python dict
Returns:

a new dict, with ‘added’, ‘changed’, and ‘removed’ items if any were found.

>>> d1 = {1: 'a'}
>>> dict_diff(d1, d1)
{}
>>> d2 = {1: 'a', 2: 'b'}
>>> dict_diff(d2, d1)
{'added': {2: 'b'}}
>>> d3 = {2: 'B', 3: 'c'}
>>> expected = {'added': {3: 'c'}, 'changed': {2: 'B'}, 'deleted': {1: 'a'}}
>>> dict_diff(d3, d2) == expected
True
api.utils.encode(obj)[source]

Return UTF-8 encoding for string objects.

api.utils.fingerprint(key)[source]

Return the fingerprint for an SSH Public Key

api.utils.generate_app_name()[source]

Return a randomly-generated memorable name.