repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseUser.revoke_user_access
def revoke_user_access(self, db_names, strict=True): """ Revokes access to the databases listed in `db_names` for the user. """ return self.manager.revoke_user_access(self, db_names, strict=strict)
python
def revoke_user_access(self, db_names, strict=True): """ Revokes access to the databases listed in `db_names` for the user. """ return self.manager.revoke_user_access(self, db_names, strict=strict)
[ "def", "revoke_user_access", "(", "self", ",", "db_names", ",", "strict", "=", "True", ")", ":", "return", "self", ".", "manager", ".", "revoke_user_access", "(", "self", ",", "db_names", ",", "strict", "=", "strict", ")" ]
Revokes access to the databases listed in `db_names` for the user.
[ "Revokes", "access", "to", "the", "databases", "listed", "in", "db_names", "for", "the", "user", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L649-L653
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient._configure_manager
def _configure_manager(self): """ Creates a manager to handle the instances, and another to handle flavors. """ self._manager = CloudDatabaseManager(self, resource_class=CloudDatabaseInstance, response_key="instance", uri_base="instances") ...
python
def _configure_manager(self): """ Creates a manager to handle the instances, and another to handle flavors. """ self._manager = CloudDatabaseManager(self, resource_class=CloudDatabaseInstance, response_key="instance", uri_base="instances") ...
[ "def", "_configure_manager", "(", "self", ")", ":", "self", ".", "_manager", "=", "CloudDatabaseManager", "(", "self", ",", "resource_class", "=", "CloudDatabaseInstance", ",", "response_key", "=", "\"instance\"", ",", "uri_base", "=", "\"instances\"", ")", "self"...
Creates a manager to handle the instances, and another to handle flavors.
[ "Creates", "a", "manager", "to", "handle", "the", "instances", "and", "another", "to", "handle", "flavors", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L683-L696
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.list_databases
def list_databases(self, instance, limit=None, marker=None): """Returns all databases for the specified instance.""" return instance.list_databases(limit=limit, marker=marker)
python
def list_databases(self, instance, limit=None, marker=None): """Returns all databases for the specified instance.""" return instance.list_databases(limit=limit, marker=marker)
[ "def", "list_databases", "(", "self", ",", "instance", ",", "limit", "=", "None", ",", "marker", "=", "None", ")", ":", "return", "instance", ".", "list_databases", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ")" ]
Returns all databases for the specified instance.
[ "Returns", "all", "databases", "for", "the", "specified", "instance", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L700-L702
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.create_database
def create_database(self, instance, name, character_set=None, collate=None): """Creates a database with the specified name on the given instance.""" return instance.create_database(name, character_set=character_set, collate=collate)
python
def create_database(self, instance, name, character_set=None, collate=None): """Creates a database with the specified name on the given instance.""" return instance.create_database(name, character_set=character_set, collate=collate)
[ "def", "create_database", "(", "self", ",", "instance", ",", "name", ",", "character_set", "=", "None", ",", "collate", "=", "None", ")", ":", "return", "instance", ".", "create_database", "(", "name", ",", "character_set", "=", "character_set", ",", "collat...
Creates a database with the specified name on the given instance.
[ "Creates", "a", "database", "with", "the", "specified", "name", "on", "the", "given", "instance", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L706-L710
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.list_users
def list_users(self, instance, limit=None, marker=None): """Returns all users for the specified instance.""" return instance.list_users(limit=limit, marker=marker)
python
def list_users(self, instance, limit=None, marker=None): """Returns all users for the specified instance.""" return instance.list_users(limit=limit, marker=marker)
[ "def", "list_users", "(", "self", ",", "instance", ",", "limit", "=", "None", ",", "marker", "=", "None", ")", ":", "return", "instance", ".", "list_users", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ")" ]
Returns all users for the specified instance.
[ "Returns", "all", "users", "for", "the", "specified", "instance", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L730-L732
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.create_user
def create_user(self, instance, name, password, database_names, host=None): """ Creates a user with the specified name and password, and gives that user access to the specified database(s). """ return instance.create_user(name=name, password=password, database_nam...
python
def create_user(self, instance, name, password, database_names, host=None): """ Creates a user with the specified name and password, and gives that user access to the specified database(s). """ return instance.create_user(name=name, password=password, database_nam...
[ "def", "create_user", "(", "self", ",", "instance", ",", "name", ",", "password", ",", "database_names", ",", "host", "=", "None", ")", ":", "return", "instance", ".", "create_user", "(", "name", "=", "name", ",", "password", "=", "password", ",", "datab...
Creates a user with the specified name and password, and gives that user access to the specified database(s).
[ "Creates", "a", "user", "with", "the", "specified", "name", "and", "password", "and", "gives", "that", "user", "access", "to", "the", "specified", "database", "(", "s", ")", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L736-L742
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.update_user
def update_user(self, instance, user, name=None, password=None, host=None): """ Allows you to change one or more of the user's username, password, or host. """ return instance.update_user(user, name=name, password=password, host=host)
python
def update_user(self, instance, user, name=None, password=None, host=None): """ Allows you to change one or more of the user's username, password, or host. """ return instance.update_user(user, name=name, password=password, host=host)
[ "def", "update_user", "(", "self", ",", "instance", ",", "user", ",", "name", "=", "None", ",", "password", "=", "None", ",", "host", "=", "None", ")", ":", "return", "instance", ".", "update_user", "(", "user", ",", "name", "=", "name", ",", "passwo...
Allows you to change one or more of the user's username, password, or host.
[ "Allows", "you", "to", "change", "one", "or", "more", "of", "the", "user", "s", "username", "password", "or", "host", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L774-L780
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.grant_user_access
def grant_user_access(self, instance, user, db_names, strict=True): """ Gives access to the databases listed in `db_names` to the user on the specified instance. """ return instance.grant_user_access(user, db_names, strict=strict)
python
def grant_user_access(self, instance, user, db_names, strict=True): """ Gives access to the databases listed in `db_names` to the user on the specified instance. """ return instance.grant_user_access(user, db_names, strict=strict)
[ "def", "grant_user_access", "(", "self", ",", "instance", ",", "user", ",", "db_names", ",", "strict", "=", "True", ")", ":", "return", "instance", ".", "grant_user_access", "(", "user", ",", "db_names", ",", "strict", "=", "strict", ")" ]
Gives access to the databases listed in `db_names` to the user on the specified instance.
[ "Gives", "access", "to", "the", "databases", "listed", "in", "db_names", "to", "the", "user", "on", "the", "specified", "instance", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L793-L798
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.revoke_user_access
def revoke_user_access(self, instance, user, db_names, strict=True): """ Revokes access to the databases listed in `db_names` for the user on the specified instance. """ return instance.revoke_user_access(user, db_names, strict=strict)
python
def revoke_user_access(self, instance, user, db_names, strict=True): """ Revokes access to the databases listed in `db_names` for the user on the specified instance. """ return instance.revoke_user_access(user, db_names, strict=strict)
[ "def", "revoke_user_access", "(", "self", ",", "instance", ",", "user", ",", "db_names", ",", "strict", "=", "True", ")", ":", "return", "instance", ".", "revoke_user_access", "(", "user", ",", "db_names", ",", "strict", "=", "strict", ")" ]
Revokes access to the databases listed in `db_names` for the user on the specified instance.
[ "Revokes", "access", "to", "the", "databases", "listed", "in", "db_names", "for", "the", "user", "on", "the", "specified", "instance", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L802-L807
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.list_flavors
def list_flavors(self, limit=None, marker=None): """Returns a list of all available Flavors.""" return self._flavor_manager.list(limit=limit, marker=marker)
python
def list_flavors(self, limit=None, marker=None): """Returns a list of all available Flavors.""" return self._flavor_manager.list(limit=limit, marker=marker)
[ "def", "list_flavors", "(", "self", ",", "limit", "=", "None", ",", "marker", "=", "None", ")", ":", "return", "self", ".", "_flavor_manager", ".", "list", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ")" ]
Returns a list of all available Flavors.
[ "Returns", "a", "list", "of", "all", "available", "Flavors", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L842-L844
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient._get_flavor_ref
def _get_flavor_ref(self, flavor): """ Flavors are odd in that the API expects an href link, not an ID, as with nearly every other resource. This method takes either a CloudDatabaseFlavor object, a flavor ID, a RAM size, or a flavor name, and uses that to determine the appropriat...
python
def _get_flavor_ref(self, flavor): """ Flavors are odd in that the API expects an href link, not an ID, as with nearly every other resource. This method takes either a CloudDatabaseFlavor object, a flavor ID, a RAM size, or a flavor name, and uses that to determine the appropriat...
[ "def", "_get_flavor_ref", "(", "self", ",", "flavor", ")", ":", "flavor_obj", "=", "None", "if", "isinstance", "(", "flavor", ",", "CloudDatabaseFlavor", ")", ":", "flavor_obj", "=", "flavor", "elif", "isinstance", "(", "flavor", ",", "int", ")", ":", "# T...
Flavors are odd in that the API expects an href link, not an ID, as with nearly every other resource. This method takes either a CloudDatabaseFlavor object, a flavor ID, a RAM size, or a flavor name, and uses that to determine the appropriate href.
[ "Flavors", "are", "odd", "in", "that", "the", "API", "expects", "an", "href", "link", "not", "an", "ID", "as", "with", "nearly", "every", "other", "resource", ".", "This", "method", "takes", "either", "a", "CloudDatabaseFlavor", "object", "a", "flavor", "I...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L852-L887
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.create_backup
def create_backup(self, instance, name, description=None): """ Creates a backup of the specified instance, giving it the specified name along with an optional description. """ return instance.create_backup(name, description=description)
python
def create_backup(self, instance, name, description=None): """ Creates a backup of the specified instance, giving it the specified name along with an optional description. """ return instance.create_backup(name, description=description)
[ "def", "create_backup", "(", "self", ",", "instance", ",", "name", ",", "description", "=", "None", ")", ":", "return", "instance", ".", "create_backup", "(", "name", ",", "description", "=", "description", ")" ]
Creates a backup of the specified instance, giving it the specified name along with an optional description.
[ "Creates", "a", "backup", "of", "the", "specified", "instance", "giving", "it", "the", "specified", "name", "along", "with", "an", "optional", "description", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L914-L919
pycontribs/pyrax
pyrax/clouddatabases.py
CloudDatabaseClient.restore_backup
def restore_backup(self, backup, name, flavor, volume): """ Restores a backup to a new database instance. You must supply a backup (either the ID or a CloudDatabaseBackup object), a name for the new instance, as well as a flavor and size (in GB) for the instance. """ retu...
python
def restore_backup(self, backup, name, flavor, volume): """ Restores a backup to a new database instance. You must supply a backup (either the ID or a CloudDatabaseBackup object), a name for the new instance, as well as a flavor and size (in GB) for the instance. """ retu...
[ "def", "restore_backup", "(", "self", ",", "backup", ",", "name", ",", "flavor", ",", "volume", ")", ":", "return", "self", ".", "_manager", ".", "restore_backup", "(", "backup", ",", "name", ",", "flavor", ",", "volume", ")" ]
Restores a backup to a new database instance. You must supply a backup (either the ID or a CloudDatabaseBackup object), a name for the new instance, as well as a flavor and size (in GB) for the instance.
[ "Restores", "a", "backup", "to", "a", "new", "database", "instance", ".", "You", "must", "supply", "a", "backup", "(", "either", "the", "ID", "or", "a", "CloudDatabaseBackup", "object", ")", "a", "name", "for", "the", "new", "instance", "as", "well", "as...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L922-L928
pycontribs/pyrax
pyrax/utils.py
runproc
def runproc(cmd): """ Convenience method for executing operating system commands. Accepts a single string that would be the command as executed on the command line. Returns a 2-tuple consisting of the output of (STDOUT, STDERR). In your code you should check for an empty STDERR output to deter...
python
def runproc(cmd): """ Convenience method for executing operating system commands. Accepts a single string that would be the command as executed on the command line. Returns a 2-tuple consisting of the output of (STDOUT, STDERR). In your code you should check for an empty STDERR output to deter...
[ "def", "runproc", "(", "cmd", ")", ":", "proc", "=", "Popen", "(", "[", "cmd", "]", ",", "shell", "=", "True", ",", "stdin", "=", "PIPE", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "PIPE", ",", "close_fds", "=", "True", ")", "stdoutdata", ",...
Convenience method for executing operating system commands. Accepts a single string that would be the command as executed on the command line. Returns a 2-tuple consisting of the output of (STDOUT, STDERR). In your code you should check for an empty STDERR output to determine if your command compl...
[ "Convenience", "method", "for", "executing", "operating", "system", "commands", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L39-L53
pycontribs/pyrax
pyrax/utils.py
get_checksum
def get_checksum(content, encoding="utf8", block_size=8192): """ Returns the MD5 checksum in hex for the given content. If 'content' is a file-like object, the content will be obtained from its read() method. If 'content' is a file path, that file is read and its contents used. Otherwise, 'content' ...
python
def get_checksum(content, encoding="utf8", block_size=8192): """ Returns the MD5 checksum in hex for the given content. If 'content' is a file-like object, the content will be obtained from its read() method. If 'content' is a file path, that file is read and its contents used. Otherwise, 'content' ...
[ "def", "get_checksum", "(", "content", ",", "encoding", "=", "\"utf8\"", ",", "block_size", "=", "8192", ")", ":", "md", "=", "hashlib", ".", "md5", "(", ")", "def", "safe_update", "(", "txt", ")", ":", "if", "isinstance", "(", "txt", ",", "six", "."...
Returns the MD5 checksum in hex for the given content. If 'content' is a file-like object, the content will be obtained from its read() method. If 'content' is a file path, that file is read and its contents used. Otherwise, 'content' is assumed to be the string whose checksum is desired. If the content...
[ "Returns", "the", "MD5", "checksum", "in", "hex", "for", "the", "given", "content", ".", "If", "content", "is", "a", "file", "-", "like", "object", "the", "content", "will", "be", "obtained", "from", "its", "read", "()", "method", ".", "If", "content", ...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L223-L265
pycontribs/pyrax
pyrax/utils.py
_join_chars
def _join_chars(chars, length): """ Used by the random character functions. """ mult = int(length / len(chars)) + 1 mult_chars = chars * mult return "".join(random.sample(mult_chars, length))
python
def _join_chars(chars, length): """ Used by the random character functions. """ mult = int(length / len(chars)) + 1 mult_chars = chars * mult return "".join(random.sample(mult_chars, length))
[ "def", "_join_chars", "(", "chars", ",", "length", ")", ":", "mult", "=", "int", "(", "length", "/", "len", "(", "chars", ")", ")", "+", "1", "mult_chars", "=", "chars", "*", "mult", "return", "\"\"", ".", "join", "(", "random", ".", "sample", "(",...
Used by the random character functions.
[ "Used", "by", "the", "random", "character", "functions", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L268-L274
pycontribs/pyrax
pyrax/utils.py
random_unicode
def random_unicode(length=20): """ Generates a random name; useful for testing. Returns an encoded string of the specified length containing unicode values up to code point 1000. """ def get_char(): return six.unichr(random.randint(32, 1000)) chars = u"".join([get_char() for ii in s...
python
def random_unicode(length=20): """ Generates a random name; useful for testing. Returns an encoded string of the specified length containing unicode values up to code point 1000. """ def get_char(): return six.unichr(random.randint(32, 1000)) chars = u"".join([get_char() for ii in s...
[ "def", "random_unicode", "(", "length", "=", "20", ")", ":", "def", "get_char", "(", ")", ":", "return", "six", ".", "unichr", "(", "random", ".", "randint", "(", "32", ",", "1000", ")", ")", "chars", "=", "u\"\"", ".", "join", "(", "[", "get_char"...
Generates a random name; useful for testing. Returns an encoded string of the specified length containing unicode values up to code point 1000.
[ "Generates", "a", "random", "name", ";", "useful", "for", "testing", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L277-L287
pycontribs/pyrax
pyrax/utils.py
coerce_to_list
def coerce_to_list(val): """ For parameters that can take either a single string or a list of strings, this function will ensure that the result is a list containing the passed values. """ if val: if not isinstance(val, (list, tuple)): val = [val] else: val = [] ...
python
def coerce_to_list(val): """ For parameters that can take either a single string or a list of strings, this function will ensure that the result is a list containing the passed values. """ if val: if not isinstance(val, (list, tuple)): val = [val] else: val = [] ...
[ "def", "coerce_to_list", "(", "val", ")", ":", "if", "val", ":", "if", "not", "isinstance", "(", "val", ",", "(", "list", ",", "tuple", ")", ")", ":", "val", "=", "[", "val", "]", "else", ":", "val", "=", "[", "]", "return", "val" ]
For parameters that can take either a single string or a list of strings, this function will ensure that the result is a list containing the passed values.
[ "For", "parameters", "that", "can", "take", "either", "a", "single", "string", "or", "a", "list", "of", "strings", "this", "function", "will", "ensure", "that", "the", "result", "is", "a", "list", "containing", "the", "passed", "values", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L299-L310
pycontribs/pyrax
pyrax/utils.py
folder_size
def folder_size(pth, ignore=None): """ Returns the total bytes for the specified path, optionally ignoring any files which match the 'ignore' parameter. 'ignore' can either be a single string pattern, or a list of such patterns. """ if not os.path.isdir(pth): raise exc.FolderNotFound ...
python
def folder_size(pth, ignore=None): """ Returns the total bytes for the specified path, optionally ignoring any files which match the 'ignore' parameter. 'ignore' can either be a single string pattern, or a list of such patterns. """ if not os.path.isdir(pth): raise exc.FolderNotFound ...
[ "def", "folder_size", "(", "pth", ",", "ignore", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "pth", ")", ":", "raise", "exc", ".", "FolderNotFound", "ignore", "=", "coerce_to_list", "(", "ignore", ")", "total", "=", "0",...
Returns the total bytes for the specified path, optionally ignoring any files which match the 'ignore' parameter. 'ignore' can either be a single string pattern, or a list of such patterns.
[ "Returns", "the", "total", "bytes", "for", "the", "specified", "path", "optionally", "ignoring", "any", "files", "which", "match", "the", "ignore", "parameter", ".", "ignore", "can", "either", "be", "a", "single", "string", "pattern", "or", "a", "list", "of"...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L313-L334
pycontribs/pyrax
pyrax/utils.py
add_method
def add_method(obj, func, name=None): """Adds an instance method to an object.""" if name is None: name = func.__name__ if sys.version_info < (3,): method = types.MethodType(func, obj, obj.__class__) else: method = types.MethodType(func, obj) setattr(obj, name, method)
python
def add_method(obj, func, name=None): """Adds an instance method to an object.""" if name is None: name = func.__name__ if sys.version_info < (3,): method = types.MethodType(func, obj, obj.__class__) else: method = types.MethodType(func, obj) setattr(obj, name, method)
[ "def", "add_method", "(", "obj", ",", "func", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "func", ".", "__name__", "if", "sys", ".", "version_info", "<", "(", "3", ",", ")", ":", "method", "=", "types", ".", ...
Adds an instance method to an object.
[ "Adds", "an", "instance", "method", "to", "an", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L337-L345
pycontribs/pyrax
pyrax/utils.py
wait_until
def wait_until(obj, att, desired, callback=None, interval=5, attempts=0, verbose=False, verbose_atts=None): """ When changing the state of an object, it will commonly be in a transitional state until the change is complete. This will reload the object every `interval` seconds, and check its `att...
python
def wait_until(obj, att, desired, callback=None, interval=5, attempts=0, verbose=False, verbose_atts=None): """ When changing the state of an object, it will commonly be in a transitional state until the change is complete. This will reload the object every `interval` seconds, and check its `att...
[ "def", "wait_until", "(", "obj", ",", "att", ",", "desired", ",", "callback", "=", "None", ",", "interval", "=", "5", ",", "attempts", "=", "0", ",", "verbose", "=", "False", ",", "verbose_atts", "=", "None", ")", ":", "if", "callback", ":", "waiter"...
When changing the state of an object, it will commonly be in a transitional state until the change is complete. This will reload the object every `interval` seconds, and check its `att` attribute until the `desired` value is reached, or until the maximum number of attempts is reached. The updated object...
[ "When", "changing", "the", "state", "of", "an", "object", "it", "will", "commonly", "be", "in", "a", "transitional", "state", "until", "the", "change", "is", "complete", ".", "This", "will", "reload", "the", "object", "every", "interval", "seconds", "and", ...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L373-L423
pycontribs/pyrax
pyrax/utils.py
_wait_until
def _wait_until(obj, att, desired, callback, interval, attempts, verbose, verbose_atts): """ Loops until either the desired value of the attribute is reached, or the number of attempts is exceeded. """ if not isinstance(desired, (list, tuple)): desired = [desired] if verbose_atts...
python
def _wait_until(obj, att, desired, callback, interval, attempts, verbose, verbose_atts): """ Loops until either the desired value of the attribute is reached, or the number of attempts is exceeded. """ if not isinstance(desired, (list, tuple)): desired = [desired] if verbose_atts...
[ "def", "_wait_until", "(", "obj", ",", "att", ",", "desired", ",", "callback", ",", "interval", ",", "attempts", ",", "verbose", ",", "verbose_atts", ")", ":", "if", "not", "isinstance", "(", "desired", ",", "(", "list", ",", "tuple", ")", ")", ":", ...
Loops until either the desired value of the attribute is reached, or the number of attempts is exceeded.
[ "Loops", "until", "either", "the", "desired", "value", "of", "the", "attribute", "is", "reached", "or", "the", "number", "of", "attempts", "is", "exceeded", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L426-L466
pycontribs/pyrax
pyrax/utils.py
wait_for_build
def wait_for_build(obj, att=None, desired=None, callback=None, interval=None, attempts=None, verbose=None, verbose_atts=None): """ Designed to handle the most common use case for wait_until: an object whose 'status' attribute will end up in either 'ACTIVE' or 'ERROR' state. Since builds don't ha...
python
def wait_for_build(obj, att=None, desired=None, callback=None, interval=None, attempts=None, verbose=None, verbose_atts=None): """ Designed to handle the most common use case for wait_until: an object whose 'status' attribute will end up in either 'ACTIVE' or 'ERROR' state. Since builds don't ha...
[ "def", "wait_for_build", "(", "obj", ",", "att", "=", "None", ",", "desired", "=", "None", ",", "callback", "=", "None", ",", "interval", "=", "None", ",", "attempts", "=", "None", ",", "verbose", "=", "None", ",", "verbose_atts", "=", "None", ")", "...
Designed to handle the most common use case for wait_until: an object whose 'status' attribute will end up in either 'ACTIVE' or 'ERROR' state. Since builds don't happen very quickly, the interval will default to 20 seconds to avoid excess polling.
[ "Designed", "to", "handle", "the", "most", "common", "use", "case", "for", "wait_until", ":", "an", "object", "whose", "status", "attribute", "will", "end", "up", "in", "either", "ACTIVE", "or", "ERROR", "state", ".", "Since", "builds", "don", "t", "happen...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L470-L484
pycontribs/pyrax
pyrax/utils.py
_parse_datetime_string
def _parse_datetime_string(val): """ Attempts to parse a string representation of a date or datetime value, and returns a datetime if successful. If not, a InvalidDateTimeString exception will be raised. """ dt = None lenval = len(val) fmt = {19: "%Y-%m-%d %H:%M:%S", 10: "%Y-%m-%d"}.get(...
python
def _parse_datetime_string(val): """ Attempts to parse a string representation of a date or datetime value, and returns a datetime if successful. If not, a InvalidDateTimeString exception will be raised. """ dt = None lenval = len(val) fmt = {19: "%Y-%m-%d %H:%M:%S", 10: "%Y-%m-%d"}.get(...
[ "def", "_parse_datetime_string", "(", "val", ")", ":", "dt", "=", "None", "lenval", "=", "len", "(", "val", ")", "fmt", "=", "{", "19", ":", "\"%Y-%m-%d %H:%M:%S\"", ",", "10", ":", "\"%Y-%m-%d\"", "}", ".", "get", "(", "lenval", ")", "if", "fmt", "i...
Attempts to parse a string representation of a date or datetime value, and returns a datetime if successful. If not, a InvalidDateTimeString exception will be raised.
[ "Attempts", "to", "parse", "a", "string", "representation", "of", "a", "date", "or", "datetime", "value", "and", "returns", "a", "datetime", "if", "successful", ".", "If", "not", "a", "InvalidDateTimeString", "exception", "will", "be", "raised", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L487-L501
pycontribs/pyrax
pyrax/utils.py
iso_time_string
def iso_time_string(val, show_tzinfo=False): """ Takes either a date, datetime or a string, and returns the standard ISO formatted string for that date/time, with any fractional second portion removed. """ if not val: return "" if isinstance(val, six.string_types): dt = _pars...
python
def iso_time_string(val, show_tzinfo=False): """ Takes either a date, datetime or a string, and returns the standard ISO formatted string for that date/time, with any fractional second portion removed. """ if not val: return "" if isinstance(val, six.string_types): dt = _pars...
[ "def", "iso_time_string", "(", "val", ",", "show_tzinfo", "=", "False", ")", ":", "if", "not", "val", ":", "return", "\"\"", "if", "isinstance", "(", "val", ",", "six", ".", "string_types", ")", ":", "dt", "=", "_parse_datetime_string", "(", "val", ")", ...
Takes either a date, datetime or a string, and returns the standard ISO formatted string for that date/time, with any fractional second portion removed.
[ "Takes", "either", "a", "date", "datetime", "or", "a", "string", "and", "returns", "the", "standard", "ISO", "formatted", "string", "for", "that", "date", "/", "time", "with", "any", "fractional", "second", "portion", "removed", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L504-L528
pycontribs/pyrax
pyrax/utils.py
rfc2822_format
def rfc2822_format(val): """ Takes either a date, a datetime, or a string, and returns a string that represents the value in RFC 2822 format. If a string is passed it is returned unchanged. """ if isinstance(val, six.string_types): return val elif isinstance(val, (datetime.datetime, ...
python
def rfc2822_format(val): """ Takes either a date, a datetime, or a string, and returns a string that represents the value in RFC 2822 format. If a string is passed it is returned unchanged. """ if isinstance(val, six.string_types): return val elif isinstance(val, (datetime.datetime, ...
[ "def", "rfc2822_format", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "six", ".", "string_types", ")", ":", "return", "val", "elif", "isinstance", "(", "val", ",", "(", "datetime", ".", "datetime", ",", "datetime", ".", "date", ")", ")", ...
Takes either a date, a datetime, or a string, and returns a string that represents the value in RFC 2822 format. If a string is passed it is returned unchanged.
[ "Takes", "either", "a", "date", "a", "datetime", "or", "a", "string", "and", "returns", "a", "string", "that", "represents", "the", "value", "in", "RFC", "2822", "format", ".", "If", "a", "string", "is", "passed", "it", "is", "returned", "unchanged", "."...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L531-L546
pycontribs/pyrax
pyrax/utils.py
to_timestamp
def to_timestamp(val): """ Takes a value that is either a Python date, datetime, or a string representation of a date/datetime value. Returns a standard Unix timestamp corresponding to that value. """ # If we're given a number, give it right back - it's already a timestamp. if isinstance(val...
python
def to_timestamp(val): """ Takes a value that is either a Python date, datetime, or a string representation of a date/datetime value. Returns a standard Unix timestamp corresponding to that value. """ # If we're given a number, give it right back - it's already a timestamp. if isinstance(val...
[ "def", "to_timestamp", "(", "val", ")", ":", "# If we're given a number, give it right back - it's already a timestamp.", "if", "isinstance", "(", "val", ",", "numbers", ".", "Number", ")", ":", "return", "val", "elif", "isinstance", "(", "val", ",", "six", ".", "...
Takes a value that is either a Python date, datetime, or a string representation of a date/datetime value. Returns a standard Unix timestamp corresponding to that value.
[ "Takes", "a", "value", "that", "is", "either", "a", "Python", "date", "datetime", "or", "a", "string", "representation", "of", "a", "date", "/", "datetime", "value", ".", "Returns", "a", "standard", "Unix", "timestamp", "corresponding", "to", "that", "value"...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L549-L562
pycontribs/pyrax
pyrax/utils.py
get_id
def get_id(id_or_obj): """ Returns the 'id' attribute of 'id_or_obj' if present; if not, returns 'id_or_obj'. """ if isinstance(id_or_obj, six.string_types + (int,)): # It's an ID return id_or_obj try: return id_or_obj.id except AttributeError: return id_or_ob...
python
def get_id(id_or_obj): """ Returns the 'id' attribute of 'id_or_obj' if present; if not, returns 'id_or_obj'. """ if isinstance(id_or_obj, six.string_types + (int,)): # It's an ID return id_or_obj try: return id_or_obj.id except AttributeError: return id_or_ob...
[ "def", "get_id", "(", "id_or_obj", ")", ":", "if", "isinstance", "(", "id_or_obj", ",", "six", ".", "string_types", "+", "(", "int", ",", ")", ")", ":", "# It's an ID", "return", "id_or_obj", "try", ":", "return", "id_or_obj", ".", "id", "except", "Attri...
Returns the 'id' attribute of 'id_or_obj' if present; if not, returns 'id_or_obj'.
[ "Returns", "the", "id", "attribute", "of", "id_or_obj", "if", "present", ";", "if", "not", "returns", "id_or_obj", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L565-L576
pycontribs/pyrax
pyrax/utils.py
get_name
def get_name(name_or_obj): """ Returns the 'name' attribute of 'name_or_obj' if present; if not, returns 'name_or_obj'. """ if isinstance(name_or_obj, six.string_types): # It's a name return name_or_obj try: return name_or_obj.name except AttributeError: raise...
python
def get_name(name_or_obj): """ Returns the 'name' attribute of 'name_or_obj' if present; if not, returns 'name_or_obj'. """ if isinstance(name_or_obj, six.string_types): # It's a name return name_or_obj try: return name_or_obj.name except AttributeError: raise...
[ "def", "get_name", "(", "name_or_obj", ")", ":", "if", "isinstance", "(", "name_or_obj", ",", "six", ".", "string_types", ")", ":", "# It's a name", "return", "name_or_obj", "try", ":", "return", "name_or_obj", ".", "name", "except", "AttributeError", ":", "ra...
Returns the 'name' attribute of 'name_or_obj' if present; if not, returns 'name_or_obj'.
[ "Returns", "the", "name", "attribute", "of", "name_or_obj", "if", "present", ";", "if", "not", "returns", "name_or_obj", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L579-L590
pycontribs/pyrax
pyrax/utils.py
params_to_dict
def params_to_dict(params, dct): """ Updates the 'dct' dictionary with the 'params' dictionary, filtering out all those whose param value is None. """ for param, val in params.items(): if val is None: continue dct[param] = val return dct
python
def params_to_dict(params, dct): """ Updates the 'dct' dictionary with the 'params' dictionary, filtering out all those whose param value is None. """ for param, val in params.items(): if val is None: continue dct[param] = val return dct
[ "def", "params_to_dict", "(", "params", ",", "dct", ")", ":", "for", "param", ",", "val", "in", "params", ".", "items", "(", ")", ":", "if", "val", "is", "None", ":", "continue", "dct", "[", "param", "]", "=", "val", "return", "dct" ]
Updates the 'dct' dictionary with the 'params' dictionary, filtering out all those whose param value is None.
[ "Updates", "the", "dct", "dictionary", "with", "the", "params", "dictionary", "filtering", "out", "all", "those", "whose", "param", "value", "is", "None", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L593-L602
pycontribs/pyrax
pyrax/utils.py
dict_to_qs
def dict_to_qs(dct): """ Takes a dictionary and uses it to create a query string. """ itms = ["%s=%s" % (key, val) for key, val in list(dct.items()) if val is not None] return "&".join(itms)
python
def dict_to_qs(dct): """ Takes a dictionary and uses it to create a query string. """ itms = ["%s=%s" % (key, val) for key, val in list(dct.items()) if val is not None] return "&".join(itms)
[ "def", "dict_to_qs", "(", "dct", ")", ":", "itms", "=", "[", "\"%s=%s\"", "%", "(", "key", ",", "val", ")", "for", "key", ",", "val", "in", "list", "(", "dct", ".", "items", "(", ")", ")", "if", "val", "is", "not", "None", "]", "return", "\"&\"...
Takes a dictionary and uses it to create a query string.
[ "Takes", "a", "dictionary", "and", "uses", "it", "to", "create", "a", "query", "string", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L605-L611
pycontribs/pyrax
pyrax/utils.py
match_pattern
def match_pattern(nm, patterns): """ Compares `nm` with the supplied patterns, and returns True if it matches at least one. Patterns are standard file-name wildcard strings, as defined in the `fnmatch` module. For example, the pattern "*.py" will match the names of all Python scripts. """ ...
python
def match_pattern(nm, patterns): """ Compares `nm` with the supplied patterns, and returns True if it matches at least one. Patterns are standard file-name wildcard strings, as defined in the `fnmatch` module. For example, the pattern "*.py" will match the names of all Python scripts. """ ...
[ "def", "match_pattern", "(", "nm", ",", "patterns", ")", ":", "patterns", "=", "coerce_to_list", "(", "patterns", ")", "for", "pat", "in", "patterns", ":", "if", "fnmatch", ".", "fnmatch", "(", "nm", ",", "pat", ")", ":", "return", "True", "return", "F...
Compares `nm` with the supplied patterns, and returns True if it matches at least one. Patterns are standard file-name wildcard strings, as defined in the `fnmatch` module. For example, the pattern "*.py" will match the names of all Python scripts.
[ "Compares", "nm", "with", "the", "supplied", "patterns", "and", "returns", "True", "if", "it", "matches", "at", "least", "one", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L614-L627
pycontribs/pyrax
pyrax/utils.py
update_exc
def update_exc(exc, msg, before=True, separator="\n"): """ Adds additional text to an exception's error message. The new text will be added before the existing text by default; to append it after the original text, pass False to the `before` parameter. By default the old and new text will be separ...
python
def update_exc(exc, msg, before=True, separator="\n"): """ Adds additional text to an exception's error message. The new text will be added before the existing text by default; to append it after the original text, pass False to the `before` parameter. By default the old and new text will be separ...
[ "def", "update_exc", "(", "exc", ",", "msg", ",", "before", "=", "True", ",", "separator", "=", "\"\\n\"", ")", ":", "emsg", "=", "exc", ".", "message", "if", "before", ":", "parts", "=", "(", "msg", ",", "separator", ",", "emsg", ")", "else", ":",...
Adds additional text to an exception's error message. The new text will be added before the existing text by default; to append it after the original text, pass False to the `before` parameter. By default the old and new text will be separated by a newline. If you wish to use a different separator, pa...
[ "Adds", "additional", "text", "to", "an", "exception", "s", "error", "message", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L630-L649
pycontribs/pyrax
pyrax/utils.py
case_insensitive_update
def case_insensitive_update(dct1, dct2): """ Given two dicts, updates the first one with the second, but considers keys that are identical except for case to be the same. No return value; this function modified dct1 similar to the update() method. """ lowkeys = dict([(key.lower(), key) for key ...
python
def case_insensitive_update(dct1, dct2): """ Given two dicts, updates the first one with the second, but considers keys that are identical except for case to be the same. No return value; this function modified dct1 similar to the update() method. """ lowkeys = dict([(key.lower(), key) for key ...
[ "def", "case_insensitive_update", "(", "dct1", ",", "dct2", ")", ":", "lowkeys", "=", "dict", "(", "[", "(", "key", ".", "lower", "(", ")", ",", "key", ")", "for", "key", "in", "dct1", "]", ")", "for", "key", ",", "val", "in", "dct2", ".", "items...
Given two dicts, updates the first one with the second, but considers keys that are identical except for case to be the same. No return value; this function modified dct1 similar to the update() method.
[ "Given", "two", "dicts", "updates", "the", "first", "one", "with", "the", "second", "but", "considers", "keys", "that", "are", "identical", "except", "for", "case", "to", "be", "the", "same", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L652-L662
pycontribs/pyrax
pyrax/utils.py
env
def env(*args, **kwargs): """ Returns the first environment variable set if none are non-empty, defaults to "" or keyword arg default """ for arg in args: value = os.environ.get(arg, None) if value: return value return kwargs.get("default", "")
python
def env(*args, **kwargs): """ Returns the first environment variable set if none are non-empty, defaults to "" or keyword arg default """ for arg in args: value = os.environ.get(arg, None) if value: return value return kwargs.get("default", "")
[ "def", "env", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "value", "=", "os", ".", "environ", ".", "get", "(", "arg", ",", "None", ")", "if", "value", ":", "return", "value", "return", "kwargs", ".", "g...
Returns the first environment variable set if none are non-empty, defaults to "" or keyword arg default
[ "Returns", "the", "first", "environment", "variable", "set", "if", "none", "are", "non", "-", "empty", "defaults", "to", "or", "keyword", "arg", "default" ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L665-L674
pycontribs/pyrax
pyrax/utils.py
import_class
def import_class(import_str): """Returns a class from a string including module and class.""" mod_str, _sep, class_str = import_str.rpartition(".") __import__(mod_str) return getattr(sys.modules[mod_str], class_str)
python
def import_class(import_str): """Returns a class from a string including module and class.""" mod_str, _sep, class_str = import_str.rpartition(".") __import__(mod_str) return getattr(sys.modules[mod_str], class_str)
[ "def", "import_class", "(", "import_str", ")", ":", "mod_str", ",", "_sep", ",", "class_str", "=", "import_str", ".", "rpartition", "(", "\".\"", ")", "__import__", "(", "mod_str", ")", "return", "getattr", "(", "sys", ".", "modules", "[", "mod_str", "]", ...
Returns a class from a string including module and class.
[ "Returns", "a", "class", "from", "a", "string", "including", "module", "and", "class", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L708-L712
pycontribs/pyrax
pyrax/utils.py
safe_decode
def safe_decode(text, incoming=None, errors='strict'): """Decodes incoming text/bytes string using `incoming` if they're not already unicode. This function was copied from novaclient.openstack.strutils :param incoming: Text's current encoding :param errors: Errors handling policy. See here for ...
python
def safe_decode(text, incoming=None, errors='strict'): """Decodes incoming text/bytes string using `incoming` if they're not already unicode. This function was copied from novaclient.openstack.strutils :param incoming: Text's current encoding :param errors: Errors handling policy. See here for ...
[ "def", "safe_decode", "(", "text", ",", "incoming", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "not", "isinstance", "(", "text", ",", "(", "six", ".", "string_types", ",", "six", ".", "binary_type", ")", ")", ":", "raise", "TypeError"...
Decodes incoming text/bytes string using `incoming` if they're not already unicode. This function was copied from novaclient.openstack.strutils :param incoming: Text's current encoding :param errors: Errors handling policy. See here for valid values http://docs.python.org/2/library/codecs.h...
[ "Decodes", "incoming", "text", "/", "bytes", "string", "using", "incoming", "if", "they", "re", "not", "already", "unicode", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L715-L753
pycontribs/pyrax
pyrax/utils.py
to_slug
def to_slug(value, incoming=None, errors="strict"): """Normalize string. Convert to lowercase, remove non-word characters, and convert spaces to hyphens. This function was copied from novaclient.openstack.strutils Inspired by Django's `slugify` filter. :param value: Text to slugify :para...
python
def to_slug(value, incoming=None, errors="strict"): """Normalize string. Convert to lowercase, remove non-word characters, and convert spaces to hyphens. This function was copied from novaclient.openstack.strutils Inspired by Django's `slugify` filter. :param value: Text to slugify :para...
[ "def", "to_slug", "(", "value", ",", "incoming", "=", "None", ",", "errors", "=", "\"strict\"", ")", ":", "value", "=", "safe_decode", "(", "value", ",", "incoming", ",", "errors", ")", "# NOTE(aababilov): no need to use safe_(encode|decode) here:", "# encodings are...
Normalize string. Convert to lowercase, remove non-word characters, and convert spaces to hyphens. This function was copied from novaclient.openstack.strutils Inspired by Django's `slugify` filter. :param value: Text to slugify :param incoming: Text's current encoding :param errors: Erro...
[ "Normalize", "string", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L756-L780
pycontribs/pyrax
pyrax/utils.py
ResultsIterator.next
def next(self): """ Return the next available item. If there are no more items in the local 'results' list, check if there is a 'next_uri' value. If so, use that to get the next page of results from the API, and return the first item from that query. """ try: ...
python
def next(self): """ Return the next available item. If there are no more items in the local 'results' list, check if there is a 'next_uri' value. If so, use that to get the next page of results from the API, and return the first item from that query. """ try: ...
[ "def", "next", "(", "self", ")", ":", "try", ":", "return", "self", ".", "results", ".", "pop", "(", "0", ")", "except", "IndexError", ":", "if", "self", ".", "next_uri", "is", "None", ":", "raise", "StopIteration", "(", ")", "else", ":", "if", "no...
Return the next available item. If there are no more items in the local 'results' list, check if there is a 'next_uri' value. If so, use that to get the next page of results from the API, and return the first item from that query.
[ "Return", "the", "next", "available", "item", ".", "If", "there", "are", "no", "more", "items", "in", "the", "local", "results", "list", "check", "if", "there", "is", "a", "next_uri", "value", ".", "If", "so", "use", "that", "to", "get", "the", "next",...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L194-L220
pycontribs/pyrax
pyrax/utils.py
_WaitThread.run
def run(self): """Starts the thread.""" resp = _wait_until(obj=self.obj, att=self.att, desired=self.desired, callback=None, interval=self.interval, attempts=self.attempts, verbose=False, verbose_atts=None) self.callback(resp)
python
def run(self): """Starts the thread.""" resp = _wait_until(obj=self.obj, att=self.att, desired=self.desired, callback=None, interval=self.interval, attempts=self.attempts, verbose=False, verbose_atts=None) self.callback(resp)
[ "def", "run", "(", "self", ")", ":", "resp", "=", "_wait_until", "(", "obj", "=", "self", ".", "obj", ",", "att", "=", "self", ".", "att", ",", "desired", "=", "self", ".", "desired", ",", "callback", "=", "None", ",", "interval", "=", "self", "....
Starts the thread.
[ "Starts", "the", "thread", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/utils.py#L364-L370
pycontribs/pyrax
pyrax/cloudblockstorage.py
assure_volume
def assure_volume(fnc): """ Converts a volumeID passed as the volume to a CloudBlockStorageVolume object. """ @wraps(fnc) def _wrapped(self, volume, *args, **kwargs): if not isinstance(volume, CloudBlockStorageVolume): # Must be the ID volume = self._manager.get(volum...
python
def assure_volume(fnc): """ Converts a volumeID passed as the volume to a CloudBlockStorageVolume object. """ @wraps(fnc) def _wrapped(self, volume, *args, **kwargs): if not isinstance(volume, CloudBlockStorageVolume): # Must be the ID volume = self._manager.get(volum...
[ "def", "assure_volume", "(", "fnc", ")", ":", "@", "wraps", "(", "fnc", ")", "def", "_wrapped", "(", "self", ",", "volume", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "volume", ",", "CloudBlockStorageVolume", ...
Converts a volumeID passed as the volume to a CloudBlockStorageVolume object.
[ "Converts", "a", "volumeID", "passed", "as", "the", "volume", "to", "a", "CloudBlockStorageVolume", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L46-L56
pycontribs/pyrax
pyrax/cloudblockstorage.py
assure_snapshot
def assure_snapshot(fnc): """ Converts a snapshot ID passed as the snapshot to a CloudBlockStorageSnapshot object. """ @wraps(fnc) def _wrapped(self, snapshot, *args, **kwargs): if not isinstance(snapshot, CloudBlockStorageSnapshot): # Must be the ID snapshot = se...
python
def assure_snapshot(fnc): """ Converts a snapshot ID passed as the snapshot to a CloudBlockStorageSnapshot object. """ @wraps(fnc) def _wrapped(self, snapshot, *args, **kwargs): if not isinstance(snapshot, CloudBlockStorageSnapshot): # Must be the ID snapshot = se...
[ "def", "assure_snapshot", "(", "fnc", ")", ":", "@", "wraps", "(", "fnc", ")", "def", "_wrapped", "(", "self", ",", "snapshot", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "snapshot", ",", "CloudBlockStorageSnap...
Converts a snapshot ID passed as the snapshot to a CloudBlockStorageSnapshot object.
[ "Converts", "a", "snapshot", "ID", "passed", "as", "the", "snapshot", "to", "a", "CloudBlockStorageSnapshot", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L59-L70
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageSnapshot.delete
def delete(self): """ Adds a check to make sure that the snapshot is able to be deleted. """ if self.status not in ("available", "error"): raise exc.SnapshotNotAvailable("Snapshot must be in 'available' " "or 'error' status before deleting. Current status:...
python
def delete(self): """ Adds a check to make sure that the snapshot is able to be deleted. """ if self.status not in ("available", "error"): raise exc.SnapshotNotAvailable("Snapshot must be in 'available' " "or 'error' status before deleting. Current status:...
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "status", "not", "in", "(", "\"available\"", ",", "\"error\"", ")", ":", "raise", "exc", ".", "SnapshotNotAvailable", "(", "\"Snapshot must be in 'available' \"", "\"or 'error' status before deleting. Current ...
Adds a check to make sure that the snapshot is able to be deleted.
[ "Adds", "a", "check", "to", "make", "sure", "that", "the", "snapshot", "is", "able", "to", "be", "deleted", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L78-L95
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageSnapshot.update
def update(self, display_name=None, display_description=None): """ Update the specified values on this snapshot. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ return self.manager...
python
def update(self, display_name=None, display_description=None): """ Update the specified values on this snapshot. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ return self.manager...
[ "def", "update", "(", "self", ",", "display_name", "=", "None", ",", "display_description", "=", "None", ")", ":", "return", "self", ".", "manager", ".", "update", "(", "self", ",", "display_name", "=", "display_name", ",", "display_description", "=", "displ...
Update the specified values on this snapshot. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised.
[ "Update", "the", "specified", "values", "on", "this", "snapshot", ".", "You", "may", "specify", "one", "or", "more", "values", "to", "update", ".", "If", "no", "values", "are", "specified", "as", "non", "-", "None", "the", "call", "is", "a", "no", "-",...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L98-L105
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageVolume.attach_to_instance
def attach_to_instance(self, instance, mountpoint): """ Attaches this volume to the cloud server instance at the specified mountpoint. This requires a call to the cloud servers API; it cannot be done directly. """ instance_id = _resolve_id(instance) try: ...
python
def attach_to_instance(self, instance, mountpoint): """ Attaches this volume to the cloud server instance at the specified mountpoint. This requires a call to the cloud servers API; it cannot be done directly. """ instance_id = _resolve_id(instance) try: ...
[ "def", "attach_to_instance", "(", "self", ",", "instance", ",", "mountpoint", ")", ":", "instance_id", "=", "_resolve_id", "(", "instance", ")", "try", ":", "resp", "=", "self", ".", "_nova_volumes", ".", "create_server_volume", "(", "instance_id", ",", "self"...
Attaches this volume to the cloud server instance at the specified mountpoint. This requires a call to the cloud servers API; it cannot be done directly.
[ "Attaches", "this", "volume", "to", "the", "cloud", "server", "instance", "at", "the", "specified", "mountpoint", ".", "This", "requires", "a", "call", "to", "the", "cloud", "servers", "API", ";", "it", "cannot", "be", "done", "directly", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L153-L164
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageVolume.detach
def detach(self): """ Detaches this volume from any device it may be attached to. If it is not attached, nothing happens. """ attachments = self.attachments if not attachments: # Not attached; no error needed, just return return # A volume ...
python
def detach(self): """ Detaches this volume from any device it may be attached to. If it is not attached, nothing happens. """ attachments = self.attachments if not attachments: # Not attached; no error needed, just return return # A volume ...
[ "def", "detach", "(", "self", ")", ":", "attachments", "=", "self", ".", "attachments", "if", "not", "attachments", ":", "# Not attached; no error needed, just return", "return", "# A volume can only be attached to one device at a time, but for some", "# reason this is a list ins...
Detaches this volume from any device it may be attached to. If it is not attached, nothing happens.
[ "Detaches", "this", "volume", "from", "any", "device", "it", "may", "be", "attached", "to", ".", "If", "it", "is", "not", "attached", "nothing", "happens", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L167-L184
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageVolume.delete
def delete(self, force=False): """ Volumes cannot be deleted if either a) they are attached to a device, or b) they have any snapshots. This method overrides the base delete() method to both better handle these failures, and also to offer a 'force' option. When 'force' is True, t...
python
def delete(self, force=False): """ Volumes cannot be deleted if either a) they are attached to a device, or b) they have any snapshots. This method overrides the base delete() method to both better handle these failures, and also to offer a 'force' option. When 'force' is True, t...
[ "def", "delete", "(", "self", ",", "force", "=", "False", ")", ":", "if", "force", ":", "self", ".", "detach", "(", ")", "self", ".", "delete_all_snapshots", "(", ")", "try", ":", "super", "(", "CloudBlockStorageVolume", ",", "self", ")", ".", "delete"...
Volumes cannot be deleted if either a) they are attached to a device, or b) they have any snapshots. This method overrides the base delete() method to both better handle these failures, and also to offer a 'force' option. When 'force' is True, the volume is detached, and any dependent sn...
[ "Volumes", "cannot", "be", "deleted", "if", "either", "a", ")", "they", "are", "attached", "to", "a", "device", "or", "b", ")", "they", "have", "any", "snapshots", ".", "This", "method", "overrides", "the", "base", "delete", "()", "method", "to", "both",...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L187-L203
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageVolume.create_snapshot
def create_snapshot(self, name=None, description=None, force=False): """ Creates a snapshot of this volume, with an optional name and description. Normally snapshots will not happen if the volume is attached. To override this default behavior, pass force=True. """ ...
python
def create_snapshot(self, name=None, description=None, force=False): """ Creates a snapshot of this volume, with an optional name and description. Normally snapshots will not happen if the volume is attached. To override this default behavior, pass force=True. """ ...
[ "def", "create_snapshot", "(", "self", ",", "name", "=", "None", ",", "description", "=", "None", ",", "force", "=", "False", ")", ":", "name", "=", "name", "or", "\"\"", "description", "=", "description", "or", "\"\"", "# Note that passing in non-None values ...
Creates a snapshot of this volume, with an optional name and description. Normally snapshots will not happen if the volume is attached. To override this default behavior, pass force=True.
[ "Creates", "a", "snapshot", "of", "this", "volume", "with", "an", "optional", "name", "and", "description", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L223-L237
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageVolume.list_snapshots
def list_snapshots(self): """ Returns a list of all snapshots of this volume. """ return [snap for snap in self.manager.list_snapshots() if snap.volume_id == self.id]
python
def list_snapshots(self): """ Returns a list of all snapshots of this volume. """ return [snap for snap in self.manager.list_snapshots() if snap.volume_id == self.id]
[ "def", "list_snapshots", "(", "self", ")", ":", "return", "[", "snap", "for", "snap", "in", "self", ".", "manager", ".", "list_snapshots", "(", ")", "if", "snap", ".", "volume_id", "==", "self", ".", "id", "]" ]
Returns a list of all snapshots of this volume.
[ "Returns", "a", "list", "of", "all", "snapshots", "of", "this", "volume", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L240-L245
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageManager._create_body
def _create_body(self, name, size=None, volume_type=None, description=None, metadata=None, snapshot_id=None, clone_id=None, availability_zone=None, image=None): """ Used to create the dict required to create a new volume """ if not isinstance(size, six.integer_t...
python
def _create_body(self, name, size=None, volume_type=None, description=None, metadata=None, snapshot_id=None, clone_id=None, availability_zone=None, image=None): """ Used to create the dict required to create a new volume """ if not isinstance(size, six.integer_t...
[ "def", "_create_body", "(", "self", ",", "name", ",", "size", "=", "None", ",", "volume_type", "=", "None", ",", "description", "=", "None", ",", "metadata", "=", "None", ",", "snapshot_id", "=", "None", ",", "clone_id", "=", "None", ",", "availability_z...
Used to create the dict required to create a new volume
[ "Used", "to", "create", "the", "dict", "required", "to", "create", "a", "new", "volume" ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L279-L307
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageManager.create
def create(self, *args, **kwargs): """ Catches errors that may be returned, and raises more informational exceptions. """ try: return super(CloudBlockStorageManager, self).create(*args, **kwargs) except exc.BadRequest as e: msg ...
python
def create(self, *args, **kwargs): """ Catches errors that may be returned, and raises more informational exceptions. """ try: return super(CloudBlockStorageManager, self).create(*args, **kwargs) except exc.BadRequest as e: msg ...
[ "def", "create", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "super", "(", "CloudBlockStorageManager", ",", "self", ")", ".", "create", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "exc", "."...
Catches errors that may be returned, and raises more informational exceptions.
[ "Catches", "errors", "that", "may", "be", "returned", "and", "raises", "more", "informational", "exceptions", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L310-L323
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageManager.update
def update(self, volume, display_name=None, display_description=None): """ Update the specified values on the specified volume. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ uri ...
python
def update(self, volume, display_name=None, display_description=None): """ Update the specified values on the specified volume. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ uri ...
[ "def", "update", "(", "self", ",", "volume", ",", "display_name", "=", "None", ",", "display_description", "=", "None", ")", ":", "uri", "=", "\"/%s/%s\"", "%", "(", "self", ".", "uri_base", ",", "utils", ".", "get_id", "(", "volume", ")", ")", "param_...
Update the specified values on the specified volume. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised.
[ "Update", "the", "specified", "values", "on", "the", "specified", "volume", ".", "You", "may", "specify", "one", "or", "more", "values", "to", "update", ".", "If", "no", "values", "are", "specified", "as", "non", "-", "None", "the", "call", "is", "a", ...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L326-L342
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageManager.create_snapshot
def create_snapshot(self, volume, name, description=None, force=False): """ Pass-through method to allow the create_snapshot() call to be made directly on a volume. """ return self.api.create_snapshot(volume, name, description=description, force=force)
python
def create_snapshot(self, volume, name, description=None, force=False): """ Pass-through method to allow the create_snapshot() call to be made directly on a volume. """ return self.api.create_snapshot(volume, name, description=description, force=force)
[ "def", "create_snapshot", "(", "self", ",", "volume", ",", "name", ",", "description", "=", "None", ",", "force", "=", "False", ")", ":", "return", "self", ".", "api", ".", "create_snapshot", "(", "volume", ",", "name", ",", "description", "=", "descript...
Pass-through method to allow the create_snapshot() call to be made directly on a volume.
[ "Pass", "-", "through", "method", "to", "allow", "the", "create_snapshot", "()", "call", "to", "be", "made", "directly", "on", "a", "volume", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L353-L359
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageSnapshotManager._create_body
def _create_body(self, name, description=None, volume=None, force=False): """ Used to create the dict required to create a new snapshot """ body = {"snapshot": { "display_name": name, "display_description": description, "volume_id": volume....
python
def _create_body(self, name, description=None, volume=None, force=False): """ Used to create the dict required to create a new snapshot """ body = {"snapshot": { "display_name": name, "display_description": description, "volume_id": volume....
[ "def", "_create_body", "(", "self", ",", "name", ",", "description", "=", "None", ",", "volume", "=", "None", ",", "force", "=", "False", ")", ":", "body", "=", "{", "\"snapshot\"", ":", "{", "\"display_name\"", ":", "name", ",", "\"display_description\"",...
Used to create the dict required to create a new snapshot
[ "Used", "to", "create", "the", "dict", "required", "to", "create", "a", "new", "snapshot" ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L367-L377
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageSnapshotManager.create
def create(self, name, volume, description=None, force=False): """ Adds exception handling to the default create() call. """ try: snap = super(CloudBlockStorageSnapshotManager, self).create( name=name, volume=volume, description=description, ...
python
def create(self, name, volume, description=None, force=False): """ Adds exception handling to the default create() call. """ try: snap = super(CloudBlockStorageSnapshotManager, self).create( name=name, volume=volume, description=description, ...
[ "def", "create", "(", "self", ",", "name", ",", "volume", ",", "description", "=", "None", ",", "force", "=", "False", ")", ":", "try", ":", "snap", "=", "super", "(", "CloudBlockStorageSnapshotManager", ",", "self", ")", ".", "create", "(", "name", "=...
Adds exception handling to the default create() call.
[ "Adds", "exception", "handling", "to", "the", "default", "create", "()", "call", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L380-L410
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageClient._configure_manager
def _configure_manager(self): """ Create the manager to handle the instances, and also another to handle flavors. """ self._manager = CloudBlockStorageManager(self, resource_class=CloudBlockStorageVolume, response_key="volume", uri_base="volumes") ...
python
def _configure_manager(self): """ Create the manager to handle the instances, and also another to handle flavors. """ self._manager = CloudBlockStorageManager(self, resource_class=CloudBlockStorageVolume, response_key="volume", uri_base="volumes") ...
[ "def", "_configure_manager", "(", "self", ")", ":", "self", ".", "_manager", "=", "CloudBlockStorageManager", "(", "self", ",", "resource_class", "=", "CloudBlockStorageVolume", ",", "response_key", "=", "\"volume\"", ",", "uri_base", "=", "\"volumes\"", ")", "sel...
Create the manager to handle the instances, and also another to handle flavors.
[ "Create", "the", "manager", "to", "handle", "the", "instances", "and", "also", "another", "to", "handle", "flavors", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L438-L451
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageClient.update
def update(self, volume, display_name=None, display_description=None): """ Update the specified values on the specified volume. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ retu...
python
def update(self, volume, display_name=None, display_description=None): """ Update the specified values on the specified volume. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised. """ retu...
[ "def", "update", "(", "self", ",", "volume", ",", "display_name", "=", "None", ",", "display_description", "=", "None", ")", ":", "return", "volume", ".", "update", "(", "display_name", "=", "display_name", ",", "display_description", "=", "display_description",...
Update the specified values on the specified volume. You may specify one or more values to update. If no values are specified as non-None, the call is a no-op; no exception will be raised.
[ "Update", "the", "specified", "values", "on", "the", "specified", "volume", ".", "You", "may", "specify", "one", "or", "more", "values", "to", "update", ".", "If", "no", "values", "are", "specified", "as", "non", "-", "None", "the", "call", "is", "a", ...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L483-L490
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageClient.create_snapshot
def create_snapshot(self, volume, name=None, description=None, force=False): """ Creates a snapshot of the volume, with an optional name and description. Normally snapshots will not happen if the volume is attached. To override this default behavior, pass force=True. """ ...
python
def create_snapshot(self, volume, name=None, description=None, force=False): """ Creates a snapshot of the volume, with an optional name and description. Normally snapshots will not happen if the volume is attached. To override this default behavior, pass force=True. """ ...
[ "def", "create_snapshot", "(", "self", ",", "volume", ",", "name", "=", "None", ",", "description", "=", "None", ",", "force", "=", "False", ")", ":", "return", "self", ".", "_snapshot_manager", ".", "create", "(", "volume", "=", "volume", ",", "name", ...
Creates a snapshot of the volume, with an optional name and description. Normally snapshots will not happen if the volume is attached. To override this default behavior, pass force=True.
[ "Creates", "a", "snapshot", "of", "the", "volume", "with", "an", "optional", "name", "and", "description", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L501-L509
pycontribs/pyrax
pyrax/cloudblockstorage.py
CloudBlockStorageClient.update_snapshot
def update_snapshot(self, snapshot, display_name=None, display_description=None): """ Update the specified values on the specified snapshot. You may specify one or more values to update. """ return snapshot.update(display_name=display_name, display_des...
python
def update_snapshot(self, snapshot, display_name=None, display_description=None): """ Update the specified values on the specified snapshot. You may specify one or more values to update. """ return snapshot.update(display_name=display_name, display_des...
[ "def", "update_snapshot", "(", "self", ",", "snapshot", ",", "display_name", "=", "None", ",", "display_description", "=", "None", ")", ":", "return", "snapshot", ".", "update", "(", "display_name", "=", "display_name", ",", "display_description", "=", "display_...
Update the specified values on the specified snapshot. You may specify one or more values to update.
[ "Update", "the", "specified", "values", "on", "the", "specified", "snapshot", ".", "You", "may", "specify", "one", "or", "more", "values", "to", "update", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudblockstorage.py#L526-L533
pycontribs/pyrax
pyrax/cloudmonitoring.py
assure_check
def assure_check(fnc): """ Converts an checkID passed as the check to a CloudMonitorCheck object. """ @wraps(fnc) def _wrapped(self, check, *args, **kwargs): if not isinstance(check, CloudMonitorCheck): # Must be the ID check = self._check_manager.get(check) r...
python
def assure_check(fnc): """ Converts an checkID passed as the check to a CloudMonitorCheck object. """ @wraps(fnc) def _wrapped(self, check, *args, **kwargs): if not isinstance(check, CloudMonitorCheck): # Must be the ID check = self._check_manager.get(check) r...
[ "def", "assure_check", "(", "fnc", ")", ":", "@", "wraps", "(", "fnc", ")", "def", "_wrapped", "(", "self", ",", "check", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "check", ",", "CloudMonitorCheck", ")", "...
Converts an checkID passed as the check to a CloudMonitorCheck object.
[ "Converts", "an", "checkID", "passed", "as", "the", "check", "to", "a", "CloudMonitorCheck", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L42-L52
pycontribs/pyrax
pyrax/cloudmonitoring.py
assure_entity
def assure_entity(fnc): """ Converts an entityID passed as the entity to a CloudMonitorEntity object. """ @wraps(fnc) def _wrapped(self, entity, *args, **kwargs): if not isinstance(entity, CloudMonitorEntity): # Must be the ID entity = self._entity_manager.get(entity)...
python
def assure_entity(fnc): """ Converts an entityID passed as the entity to a CloudMonitorEntity object. """ @wraps(fnc) def _wrapped(self, entity, *args, **kwargs): if not isinstance(entity, CloudMonitorEntity): # Must be the ID entity = self._entity_manager.get(entity)...
[ "def", "assure_entity", "(", "fnc", ")", ":", "@", "wraps", "(", "fnc", ")", "def", "_wrapped", "(", "self", ",", "entity", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "entity", ",", "CloudMonitorEntity", ")",...
Converts an entityID passed as the entity to a CloudMonitorEntity object.
[ "Converts", "an", "entityID", "passed", "as", "the", "entity", "to", "a", "CloudMonitorEntity", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L55-L65
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.update
def update(self, agent=None, metadata=None): """ Only the agent_id and metadata are able to be updated via the API. """ self.manager.update_entity(self, agent=agent, metadata=metadata)
python
def update(self, agent=None, metadata=None): """ Only the agent_id and metadata are able to be updated via the API. """ self.manager.update_entity(self, agent=agent, metadata=metadata)
[ "def", "update", "(", "self", ",", "agent", "=", "None", ",", "metadata", "=", "None", ")", ":", "self", ".", "manager", ".", "update_entity", "(", "self", ",", "agent", "=", "agent", ",", "metadata", "=", "metadata", ")" ]
Only the agent_id and metadata are able to be updated via the API.
[ "Only", "the", "agent_id", "and", "metadata", "are", "able", "to", "be", "updated", "via", "the", "API", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L82-L86
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.get_check
def get_check(self, check): """ Returns an instance of the specified check. """ chk = self._check_manager.get(check) chk.set_entity(self) return chk
python
def get_check(self, check): """ Returns an instance of the specified check. """ chk = self._check_manager.get(check) chk.set_entity(self) return chk
[ "def", "get_check", "(", "self", ",", "check", ")", ":", "chk", "=", "self", ".", "_check_manager", ".", "get", "(", "check", ")", "chk", ".", "set_entity", "(", "self", ")", "return", "chk" ]
Returns an instance of the specified check.
[ "Returns", "an", "instance", "of", "the", "specified", "check", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L89-L95
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.list_checks
def list_checks(self, limit=None, marker=None, return_next=False): """ Returns a list of the checks defined for this account. By default the number returned is limited to 100; you can define the number to return by optionally passing a value for the 'limit' parameter. The value for ...
python
def list_checks(self, limit=None, marker=None, return_next=False): """ Returns a list of the checks defined for this account. By default the number returned is limited to 100; you can define the number to return by optionally passing a value for the 'limit' parameter. The value for ...
[ "def", "list_checks", "(", "self", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "return_next", "=", "False", ")", ":", "checks", "=", "self", ".", "_check_manager", ".", "list", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ...
Returns a list of the checks defined for this account. By default the number returned is limited to 100; you can define the number to return by optionally passing a value for the 'limit' parameter. The value for limit must be at least 1, and can be up to 1000. For pagination, you must a...
[ "Returns", "a", "list", "of", "the", "checks", "defined", "for", "this", "account", ".", "By", "default", "the", "number", "returned", "is", "limited", "to", "100", ";", "you", "can", "define", "the", "number", "to", "return", "by", "optionally", "passing"...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L98-L115
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.find_all_checks
def find_all_checks(self, **kwargs): """ Finds all checks for this entity with attributes matching ``**kwargs``. This isn't very efficient: it loads the entire list then filters on the Python side. """ checks = self._check_manager.find_all_checks(**kwargs) for ch...
python
def find_all_checks(self, **kwargs): """ Finds all checks for this entity with attributes matching ``**kwargs``. This isn't very efficient: it loads the entire list then filters on the Python side. """ checks = self._check_manager.find_all_checks(**kwargs) for ch...
[ "def", "find_all_checks", "(", "self", ",", "*", "*", "kwargs", ")", ":", "checks", "=", "self", ".", "_check_manager", ".", "find_all_checks", "(", "*", "*", "kwargs", ")", "for", "check", "in", "checks", ":", "check", ".", "set_entity", "(", "self", ...
Finds all checks for this entity with attributes matching ``**kwargs``. This isn't very efficient: it loads the entire list then filters on the Python side.
[ "Finds", "all", "checks", "for", "this", "entity", "with", "attributes", "matching", "**", "kwargs", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L118-L128
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.create_check
def create_check(self, label=None, name=None, check_type=None, disabled=False, metadata=None, details=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None, test_only=False, include_debug=False): ...
python
def create_check(self, label=None, name=None, check_type=None, disabled=False, metadata=None, details=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None, test_only=False, include_debug=False): ...
[ "def", "create_check", "(", "self", ",", "label", "=", "None", ",", "name", "=", "None", ",", "check_type", "=", "None", ",", "disabled", "=", "False", ",", "metadata", "=", "None", ",", "details", "=", "None", ",", "monitoring_zones_poll", "=", "None", ...
Creates a check on this entity with the specified attributes. The 'details' parameter should be a dict with the keys as the option name, and the value as the desired setting.
[ "Creates", "a", "check", "on", "this", "entity", "with", "the", "specified", "attributes", ".", "The", "details", "parameter", "should", "be", "a", "dict", "with", "the", "keys", "as", "the", "option", "name", "and", "the", "value", "as", "the", "desired",...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L131-L147
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.create_alarm
def create_alarm(self, check, notification_plan, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Creates an alarm that binds the check on this entity with a notification plan. """ return self._alarm_manager.create(check, notification_plan, ...
python
def create_alarm(self, check, notification_plan, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Creates an alarm that binds the check on this entity with a notification plan. """ return self._alarm_manager.create(check, notification_plan, ...
[ "def", "create_alarm", "(", "self", ",", "check", ",", "notification_plan", ",", "criteria", "=", "None", ",", "disabled", "=", "False", ",", "label", "=", "None", ",", "name", "=", "None", ",", "metadata", "=", "None", ")", ":", "return", "self", ".",...
Creates an alarm that binds the check on this entity with a notification plan.
[ "Creates", "an", "alarm", "that", "binds", "the", "check", "on", "this", "entity", "with", "a", "notification", "plan", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L213-L221
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.update_alarm
def update_alarm(self, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Updates an existing alarm on this entity. """ return self._alarm_manager.update(alarm, criteria=criteria, disabled=disabled, label=label, name=name, metadat...
python
def update_alarm(self, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Updates an existing alarm on this entity. """ return self._alarm_manager.update(alarm, criteria=criteria, disabled=disabled, label=label, name=name, metadat...
[ "def", "update_alarm", "(", "self", ",", "alarm", ",", "criteria", "=", "None", ",", "disabled", "=", "False", ",", "label", "=", "None", ",", "name", "=", "None", ",", "metadata", "=", "None", ")", ":", "return", "self", ".", "_alarm_manager", ".", ...
Updates an existing alarm on this entity.
[ "Updates", "an", "existing", "alarm", "on", "this", "entity", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L224-L230
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntity.list_alarms
def list_alarms(self, limit=None, marker=None, return_next=False): """ Returns a list of all the alarms created on this entity. """ return self._alarm_manager.list(limit=limit, marker=marker, return_next=return_next)
python
def list_alarms(self, limit=None, marker=None, return_next=False): """ Returns a list of all the alarms created on this entity. """ return self._alarm_manager.list(limit=limit, marker=marker, return_next=return_next)
[ "def", "list_alarms", "(", "self", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "return_next", "=", "False", ")", ":", "return", "self", ".", "_alarm_manager", ".", "list", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ",", ...
Returns a list of all the alarms created on this entity.
[ "Returns", "a", "list", "of", "all", "the", "alarms", "created", "on", "this", "entity", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L233-L238
pycontribs/pyrax
pyrax/cloudmonitoring.py
_PaginationManager.list
def list(self, limit=None, marker=None, return_next=False): """ This is necessary to handle pagination correctly, as the Monitoring service defines 'marker' differently than most other services. For monitoring, 'marker' represents the first item in the next page, whereas other se...
python
def list(self, limit=None, marker=None, return_next=False): """ This is necessary to handle pagination correctly, as the Monitoring service defines 'marker' differently than most other services. For monitoring, 'marker' represents the first item in the next page, whereas other se...
[ "def", "list", "(", "self", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "return_next", "=", "False", ")", ":", "kwargs", "=", "{", "}", "if", "return_next", ":", "kwargs", "[", "\"other_keys\"", "]", "=", "\"metadata\"", "ret", "=", "...
This is necessary to handle pagination correctly, as the Monitoring service defines 'marker' differently than most other services. For monitoring, 'marker' represents the first item in the next page, whereas other services define it as the ID of the last item in the current page.
[ "This", "is", "necessary", "to", "handle", "pagination", "correctly", "as", "the", "Monitoring", "service", "defines", "marker", "differently", "than", "most", "other", "services", ".", "For", "monitoring", "marker", "represents", "the", "first", "item", "in", "...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L264-L281
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorNotificationManager.create
def create(self, notification_type, label=None, name=None, details=None): """ Defines a notification for handling an alarm. """ uri = "/%s" % self.uri_base body = {"label": label or name, "type": utils.get_id(notification_type), "details": details,...
python
def create(self, notification_type, label=None, name=None, details=None): """ Defines a notification for handling an alarm. """ uri = "/%s" % self.uri_base body = {"label": label or name, "type": utils.get_id(notification_type), "details": details,...
[ "def", "create", "(", "self", ",", "notification_type", ",", "label", "=", "None", ",", "name", "=", "None", ",", "details", "=", "None", ")", ":", "uri", "=", "\"/%s\"", "%", "self", ".", "uri_base", "body", "=", "{", "\"label\"", ":", "label", "or"...
Defines a notification for handling an alarm.
[ "Defines", "a", "notification", "for", "handling", "an", "alarm", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L289-L299
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorNotificationManager.update_notification
def update_notification(self, notification, details): """ Updates the specified notification with the supplied details. """ if isinstance(notification, CloudMonitorNotification): nid = notification.id ntyp = notification.type else: # Supplied a...
python
def update_notification(self, notification, details): """ Updates the specified notification with the supplied details. """ if isinstance(notification, CloudMonitorNotification): nid = notification.id ntyp = notification.type else: # Supplied a...
[ "def", "update_notification", "(", "self", ",", "notification", ",", "details", ")", ":", "if", "isinstance", "(", "notification", ",", "CloudMonitorNotification", ")", ":", "nid", "=", "notification", ".", "id", "ntyp", "=", "notification", ".", "type", "else...
Updates the specified notification with the supplied details.
[ "Updates", "the", "specified", "notification", "with", "the", "supplied", "details", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L327-L342
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorNotificationManager.list_types
def list_types(self): """ Returns a list of all available notification types. """ uri = "/notification_types" resp, resp_body = self.api.method_get(uri) return [CloudMonitorNotificationType(self, info) for info in resp_body["values"]]
python
def list_types(self): """ Returns a list of all available notification types. """ uri = "/notification_types" resp, resp_body = self.api.method_get(uri) return [CloudMonitorNotificationType(self, info) for info in resp_body["values"]]
[ "def", "list_types", "(", "self", ")", ":", "uri", "=", "\"/notification_types\"", "resp", ",", "resp_body", "=", "self", ".", "api", ".", "method_get", "(", "uri", ")", "return", "[", "CloudMonitorNotificationType", "(", "self", ",", "info", ")", "for", "...
Returns a list of all available notification types.
[ "Returns", "a", "list", "of", "all", "available", "notification", "types", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L345-L352
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorNotificationManager.get_type
def get_type(self, notification_type_id): """ Returns a CloudMonitorNotificationType object for the given ID. """ uri = "/notification_types/%s" % utils.get_id(notification_type_id) resp, resp_body = self.api.method_get(uri) return CloudMonitorNotificationType(self, resp_...
python
def get_type(self, notification_type_id): """ Returns a CloudMonitorNotificationType object for the given ID. """ uri = "/notification_types/%s" % utils.get_id(notification_type_id) resp, resp_body = self.api.method_get(uri) return CloudMonitorNotificationType(self, resp_...
[ "def", "get_type", "(", "self", ",", "notification_type_id", ")", ":", "uri", "=", "\"/notification_types/%s\"", "%", "utils", ".", "get_id", "(", "notification_type_id", ")", "resp", ",", "resp_body", "=", "self", ".", "api", ".", "method_get", "(", "uri", ...
Returns a CloudMonitorNotificationType object for the given ID.
[ "Returns", "a", "CloudMonitorNotificationType", "object", "for", "the", "given", "ID", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L355-L361
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorNotificationPlanManager.create
def create(self, label=None, name=None, critical_state=None, ok_state=None, warning_state=None): """ Creates a notification plan to be executed when a monitoring check triggers an alarm. You can optionally label (or name) the plan. A plan consists of one or more notification...
python
def create(self, label=None, name=None, critical_state=None, ok_state=None, warning_state=None): """ Creates a notification plan to be executed when a monitoring check triggers an alarm. You can optionally label (or name) the plan. A plan consists of one or more notification...
[ "def", "create", "(", "self", ",", "label", "=", "None", ",", "name", "=", "None", ",", "critical_state", "=", "None", ",", "ok_state", "=", "None", ",", "warning_state", "=", "None", ")", ":", "uri", "=", "\"/%s\"", "%", "self", ".", "uri_base", "bo...
Creates a notification plan to be executed when a monitoring check triggers an alarm. You can optionally label (or name) the plan. A plan consists of one or more notifications to be executed when an associated alarm is triggered. You can have different lists of actions for CRITICAL, WAR...
[ "Creates", "a", "notification", "plan", "to", "be", "executed", "when", "a", "monitoring", "check", "triggers", "an", "alarm", ".", "You", "can", "optionally", "label", "(", "or", "name", ")", "the", "plan", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L369-L396
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorMetricsManager.get_metric_data_points
def get_metric_data_points(self, metric, start, end, points=None, resolution=None, stats=None): """ Returns the data points for a given metric for the given period. The 'start' and 'end' times must be specified; they can be be either Python date/datetime values, or a Unix tim...
python
def get_metric_data_points(self, metric, start, end, points=None, resolution=None, stats=None): """ Returns the data points for a given metric for the given period. The 'start' and 'end' times must be specified; they can be be either Python date/datetime values, or a Unix tim...
[ "def", "get_metric_data_points", "(", "self", ",", "metric", ",", "start", ",", "end", ",", "points", "=", "None", ",", "resolution", "=", "None", ",", "stats", "=", "None", ")", ":", "allowed_resolutions", "=", "(", "\"FULL\"", ",", "\"MIN5\"", ",", "\"...
Returns the data points for a given metric for the given period. The 'start' and 'end' times must be specified; they can be be either Python date/datetime values, or a Unix timestamp. The 'points' parameter represents the number of points to return. The 'resolution' parameter represents...
[ "Returns", "the", "data", "points", "for", "a", "given", "metric", "for", "the", "given", "period", ".", "The", "start", "and", "end", "times", "must", "be", "specified", ";", "they", "can", "be", "be", "either", "Python", "date", "/", "datetime", "value...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L401-L472
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorAlarmManager.create
def create(self, check, notification_plan, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Creates an alarm that binds the check on the given entity with a notification plan. Note that the 'criteria' parameter, if supplied, should be a string ...
python
def create(self, check, notification_plan, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Creates an alarm that binds the check on the given entity with a notification plan. Note that the 'criteria' parameter, if supplied, should be a string ...
[ "def", "create", "(", "self", ",", "check", ",", "notification_plan", ",", "criteria", "=", "None", ",", "disabled", "=", "False", ",", "label", "=", "None", ",", "name", "=", "None", ",", "metadata", "=", "None", ")", ":", "uri", "=", "\"/%s\"", "%"...
Creates an alarm that binds the check on the given entity with a notification plan. Note that the 'criteria' parameter, if supplied, should be a string representing the DSL for describing alerting conditions and their output states. Pyrax does not do any validation of these criteria ...
[ "Creates", "an", "alarm", "that", "binds", "the", "check", "on", "the", "given", "entity", "with", "a", "notification", "plan", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L489-L518
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorAlarmManager.update
def update(self, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Updates an existing alarm. See the comments on the 'create()' method regarding the criteria parameter. """ uri = "/%s/%s" % (self.uri_base, utils.get_id(alarm)) b...
python
def update(self, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Updates an existing alarm. See the comments on the 'create()' method regarding the criteria parameter. """ uri = "/%s/%s" % (self.uri_base, utils.get_id(alarm)) b...
[ "def", "update", "(", "self", ",", "alarm", ",", "criteria", "=", "None", ",", "disabled", "=", "False", ",", "label", "=", "None", ",", "name", "=", "None", ",", "metadata", "=", "None", ")", ":", "uri", "=", "\"/%s/%s\"", "%", "(", "self", ".", ...
Updates an existing alarm. See the comments on the 'create()' method regarding the criteria parameter.
[ "Updates", "an", "existing", "alarm", ".", "See", "the", "comments", "on", "the", "create", "()", "method", "regarding", "the", "criteria", "parameter", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L521-L538
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheckManager.create_check
def create_check(self, label=None, name=None, check_type=None, details=None, disabled=False, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None, test_only=False, include_debug=False): ...
python
def create_check(self, label=None, name=None, check_type=None, details=None, disabled=False, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None, test_only=False, include_debug=False): ...
[ "def", "create_check", "(", "self", ",", "label", "=", "None", ",", "name", "=", "None", ",", "check_type", "=", "None", ",", "details", "=", "None", ",", "disabled", "=", "False", ",", "metadata", "=", "None", ",", "monitoring_zones_poll", "=", "None", ...
Creates a check on the entity with the specified attributes. The 'details' parameter should be a dict with the keys as the option name, and the value as the desired setting. If the 'test_only' parameter is True, then the check is not created; instead, the check is run and the results of...
[ "Creates", "a", "check", "on", "the", "entity", "with", "the", "specified", "attributes", ".", "The", "details", "parameter", "should", "be", "a", "dict", "with", "the", "keys", "as", "the", "option", "name", "and", "the", "value", "as", "the", "desired", ...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L546-L626
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheckManager.find_all_checks
def find_all_checks(self, **kwargs): """ Finds all checks for a given entity with attributes matching ``**kwargs``. This isn't very efficient: it loads the entire list then filters on the Python side. """ found = [] searches = kwargs.items() for o...
python
def find_all_checks(self, **kwargs): """ Finds all checks for a given entity with attributes matching ``**kwargs``. This isn't very efficient: it loads the entire list then filters on the Python side. """ found = [] searches = kwargs.items() for o...
[ "def", "find_all_checks", "(", "self", ",", "*", "*", "kwargs", ")", ":", "found", "=", "[", "]", "searches", "=", "kwargs", ".", "items", "(", ")", "for", "obj", "in", "self", ".", "list", "(", ")", ":", "try", ":", "if", "all", "(", "getattr", ...
Finds all checks for a given entity with attributes matching ``**kwargs``. This isn't very efficient: it loads the entire list then filters on the Python side.
[ "Finds", "all", "checks", "for", "a", "given", "entity", "with", "attributes", "matching", "**", "kwargs", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L660-L677
pycontribs/pyrax
pyrax/cloudmonitoring.py
_EntityFilteringManger.list
def list(self, entity=None): """ Returns a dictionary of data, optionally filtered for a given entity. """ uri = "/%s" % self.uri_base if entity: uri = "%s?entityId=%s" % (uri, utils.get_id(entity)) resp, resp_body = self._list(uri, return_raw=True) re...
python
def list(self, entity=None): """ Returns a dictionary of data, optionally filtered for a given entity. """ uri = "/%s" % self.uri_base if entity: uri = "%s?entityId=%s" % (uri, utils.get_id(entity)) resp, resp_body = self._list(uri, return_raw=True) re...
[ "def", "list", "(", "self", ",", "entity", "=", "None", ")", ":", "uri", "=", "\"/%s\"", "%", "self", ".", "uri_base", "if", "entity", ":", "uri", "=", "\"%s?entityId=%s\"", "%", "(", "uri", ",", "utils", ".", "get_id", "(", "entity", ")", ")", "re...
Returns a dictionary of data, optionally filtered for a given entity.
[ "Returns", "a", "dictionary", "of", "data", "optionally", "filtered", "for", "a", "given", "entity", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L685-L693
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntityManager._create_body
def _create_body(self, name, label=None, agent=None, ip_addresses=None, metadata=None): """ Used to create the dict required to create various resources. Accepts either 'label' or 'name' as the keyword parameter for the label attribute for entities. """ label ...
python
def _create_body(self, name, label=None, agent=None, ip_addresses=None, metadata=None): """ Used to create the dict required to create various resources. Accepts either 'label' or 'name' as the keyword parameter for the label attribute for entities. """ label ...
[ "def", "_create_body", "(", "self", ",", "name", ",", "label", "=", "None", ",", "agent", "=", "None", ",", "ip_addresses", "=", "None", ",", "metadata", "=", "None", ")", ":", "label", "=", "label", "or", "name", "if", "ip_addresses", "is", "not", "...
Used to create the dict required to create various resources. Accepts either 'label' or 'name' as the keyword parameter for the label attribute for entities.
[ "Used", "to", "create", "the", "dict", "required", "to", "create", "various", "resources", ".", "Accepts", "either", "label", "or", "name", "as", "the", "keyword", "parameter", "for", "the", "label", "attribute", "for", "entities", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L701-L717
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorEntityManager.update_entity
def update_entity(self, entity, agent=None, metadata=None): """ Updates the specified entity's values with the supplied parameters. """ body = {} if agent: body["agent_id"] = utils.get_id(agent) if metadata: body["metadata"] = metadata if b...
python
def update_entity(self, entity, agent=None, metadata=None): """ Updates the specified entity's values with the supplied parameters. """ body = {} if agent: body["agent_id"] = utils.get_id(agent) if metadata: body["metadata"] = metadata if b...
[ "def", "update_entity", "(", "self", ",", "entity", ",", "agent", "=", "None", ",", "metadata", "=", "None", ")", ":", "body", "=", "{", "}", "if", "agent", ":", "body", "[", "\"agent_id\"", "]", "=", "utils", ".", "get_id", "(", "agent", ")", "if"...
Updates the specified entity's values with the supplied parameters.
[ "Updates", "the", "specified", "entity", "s", "values", "with", "the", "supplied", "parameters", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L720-L731
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheck.get
def get(self): """Reloads the check with its current values.""" new = self.manager.get(self) if new: self._add_details(new._info)
python
def get(self): """Reloads the check with its current values.""" new = self.manager.get(self) if new: self._add_details(new._info)
[ "def", "get", "(", "self", ")", ":", "new", "=", "self", ".", "manager", ".", "get", "(", "self", ")", "if", "new", ":", "self", ".", "_add_details", "(", "new", ".", "_info", ")" ]
Reloads the check with its current values.
[ "Reloads", "the", "check", "with", "its", "current", "values", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L789-L793
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheck.update
def update(self, label=None, name=None, disabled=None, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None): """ Updates an existing check with any of the parameters. """ self.manager....
python
def update(self, label=None, name=None, disabled=None, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None): """ Updates an existing check with any of the parameters. """ self.manager....
[ "def", "update", "(", "self", ",", "label", "=", "None", ",", "name", "=", "None", ",", "disabled", "=", "None", ",", "metadata", "=", "None", ",", "monitoring_zones_poll", "=", "None", ",", "timeout", "=", "None", ",", "period", "=", "None", ",", "t...
Updates an existing check with any of the parameters.
[ "Updates", "an", "existing", "check", "with", "any", "of", "the", "parameters", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L798-L809
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheck.list_metrics
def list_metrics(self, limit=None, marker=None, return_next=False): """ Returns a list of all the metrics associated with this check. """ return self._metrics_manager.list(limit=limit, marker=marker, return_next=return_next)
python
def list_metrics(self, limit=None, marker=None, return_next=False): """ Returns a list of all the metrics associated with this check. """ return self._metrics_manager.list(limit=limit, marker=marker, return_next=return_next)
[ "def", "list_metrics", "(", "self", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "return_next", "=", "False", ")", ":", "return", "self", ".", "_metrics_manager", ".", "list", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ","...
Returns a list of all the metrics associated with this check.
[ "Returns", "a", "list", "of", "all", "the", "metrics", "associated", "with", "this", "check", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L817-L822
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheck.get_metric_data_points
def get_metric_data_points(self, metric, start, end, points=None, resolution=None, stats=None): """ Returns the data points for a given metric for the given period. The 'start' and 'end' times must be specified; they can be be either Python date/datetime values, or a Unix tim...
python
def get_metric_data_points(self, metric, start, end, points=None, resolution=None, stats=None): """ Returns the data points for a given metric for the given period. The 'start' and 'end' times must be specified; they can be be either Python date/datetime values, or a Unix tim...
[ "def", "get_metric_data_points", "(", "self", ",", "metric", ",", "start", ",", "end", ",", "points", "=", "None", ",", "resolution", "=", "None", ",", "stats", "=", "None", ")", ":", "return", "self", ".", "_metrics_manager", ".", "get_metric_data_points", ...
Returns the data points for a given metric for the given period. The 'start' and 'end' times must be specified; they can be be either Python date/datetime values, or a Unix timestamp. The 'points' parameter represents the number of points to return. The 'resolution' parameter represents...
[ "Returns", "the", "data", "points", "for", "a", "given", "metric", "for", "the", "given", "period", ".", "The", "start", "and", "end", "times", "must", "be", "specified", ";", "they", "can", "be", "be", "either", "Python", "date", "/", "datetime", "value...
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L825-L853
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorCheck.create_alarm
def create_alarm(self, notification_plan, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Creates an alarm that binds this check with a notification plan. """ return self.manager.create_alarm(self.entity, self, notification_plan, crit...
python
def create_alarm(self, notification_plan, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Creates an alarm that binds this check with a notification plan. """ return self.manager.create_alarm(self.entity, self, notification_plan, crit...
[ "def", "create_alarm", "(", "self", ",", "notification_plan", ",", "criteria", "=", "None", ",", "disabled", "=", "False", ",", "label", "=", "None", ",", "name", "=", "None", ",", "metadata", "=", "None", ")", ":", "return", "self", ".", "manager", "....
Creates an alarm that binds this check with a notification plan.
[ "Creates", "an", "alarm", "that", "binds", "this", "check", "with", "a", "notification", "plan", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L856-L863
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorAlarm.get
def get(self): """ Fetches the current state of the alarm from the API and updates the object. """ new_alarm = self.entity.get_alarm(self) if new_alarm: self._add_details(new_alarm._info)
python
def get(self): """ Fetches the current state of the alarm from the API and updates the object. """ new_alarm = self.entity.get_alarm(self) if new_alarm: self._add_details(new_alarm._info)
[ "def", "get", "(", "self", ")", ":", "new_alarm", "=", "self", ".", "entity", ".", "get_alarm", "(", "self", ")", "if", "new_alarm", ":", "self", ".", "_add_details", "(", "new_alarm", ".", "_info", ")" ]
Fetches the current state of the alarm from the API and updates the object.
[ "Fetches", "the", "current", "state", "of", "the", "alarm", "from", "the", "API", "and", "updates", "the", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L978-L985
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient._configure_manager
def _configure_manager(self): """ Creates the Manager instances to handle monitoring. """ self._entity_manager = CloudMonitorEntityManager(self, uri_base="entities", resource_class=CloudMonitorEntity, response_key=None, plural_response_key=None) se...
python
def _configure_manager(self): """ Creates the Manager instances to handle monitoring. """ self._entity_manager = CloudMonitorEntityManager(self, uri_base="entities", resource_class=CloudMonitorEntity, response_key=None, plural_response_key=None) se...
[ "def", "_configure_manager", "(", "self", ")", ":", "self", ".", "_entity_manager", "=", "CloudMonitorEntityManager", "(", "self", ",", "uri_base", "=", "\"entities\"", ",", "resource_class", "=", "CloudMonitorEntity", ",", "response_key", "=", "None", ",", "plura...
Creates the Manager instances to handle monitoring.
[ "Creates", "the", "Manager", "instances", "to", "handle", "monitoring", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1017-L1044
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.update_entity
def update_entity(self, entity, agent=None, metadata=None): """ Only the agent_id and metadata are able to be updated via the API. """ self._entity_manager.update_entity(entity, agent=agent, metadata=metadata)
python
def update_entity(self, entity, agent=None, metadata=None): """ Only the agent_id and metadata are able to be updated via the API. """ self._entity_manager.update_entity(entity, agent=agent, metadata=metadata)
[ "def", "update_entity", "(", "self", ",", "entity", ",", "agent", "=", "None", ",", "metadata", "=", "None", ")", ":", "self", ".", "_entity_manager", ".", "update_entity", "(", "entity", ",", "agent", "=", "agent", ",", "metadata", "=", "metadata", ")" ...
Only the agent_id and metadata are able to be updated via the API.
[ "Only", "the", "agent_id", "and", "metadata", "are", "able", "to", "be", "updated", "via", "the", "API", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1093-L1098
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.update_check
def update_check(self, entity, check, label=None, name=None, disabled=None, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None): """ Updates an existing check with any of the parameters. ...
python
def update_check(self, entity, check, label=None, name=None, disabled=None, metadata=None, monitoring_zones_poll=None, timeout=None, period=None, target_alias=None, target_hostname=None, target_receiver=None): """ Updates an existing check with any of the parameters. ...
[ "def", "update_check", "(", "self", ",", "entity", ",", "check", ",", "label", "=", "None", ",", "name", "=", "None", ",", "disabled", "=", "None", ",", "metadata", "=", "None", ",", "monitoring_zones_poll", "=", "None", ",", "timeout", "=", "None", ",...
Updates an existing check with any of the parameters.
[ "Updates", "an", "existing", "check", "with", "any", "of", "the", "parameters", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1160-L1171
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.list_metrics
def list_metrics(self, entity, check, limit=None, marker=None, return_next=False): """ Returns a list of all the metrics associated with the specified check. """ return entity.list_metrics(check, limit=limit, marker=marker, return_next=return_next)
python
def list_metrics(self, entity, check, limit=None, marker=None, return_next=False): """ Returns a list of all the metrics associated with the specified check. """ return entity.list_metrics(check, limit=limit, marker=marker, return_next=return_next)
[ "def", "list_metrics", "(", "self", ",", "entity", ",", "check", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "return_next", "=", "False", ")", ":", "return", "entity", ".", "list_metrics", "(", "check", ",", "limit", "=", "limit", ",", ...
Returns a list of all the metrics associated with the specified check.
[ "Returns", "a", "list", "of", "all", "the", "metrics", "associated", "with", "the", "specified", "check", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1183-L1189
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.create_notification
def create_notification(self, notification_type, label=None, name=None, details=None): """ Defines a notification for handling an alarm. """ return self._notification_manager.create(notification_type, label=label, name=name, details=details)
python
def create_notification(self, notification_type, label=None, name=None, details=None): """ Defines a notification for handling an alarm. """ return self._notification_manager.create(notification_type, label=label, name=name, details=details)
[ "def", "create_notification", "(", "self", ",", "notification_type", ",", "label", "=", "None", ",", "name", "=", "None", ",", "details", "=", "None", ")", ":", "return", "self", ".", "_notification_manager", ".", "create", "(", "notification_type", ",", "la...
Defines a notification for handling an alarm.
[ "Defines", "a", "notification", "for", "handling", "an", "alarm", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1255-L1261
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.create_notification_plan
def create_notification_plan(self, label=None, name=None, critical_state=None, ok_state=None, warning_state=None): """ Creates a notification plan to be executed when a monitoring check triggers an alarm. """ return self._notification_plan_manager.create(label=label, ...
python
def create_notification_plan(self, label=None, name=None, critical_state=None, ok_state=None, warning_state=None): """ Creates a notification plan to be executed when a monitoring check triggers an alarm. """ return self._notification_plan_manager.create(label=label, ...
[ "def", "create_notification_plan", "(", "self", ",", "label", "=", "None", ",", "name", "=", "None", ",", "critical_state", "=", "None", ",", "ok_state", "=", "None", ",", "warning_state", "=", "None", ")", ":", "return", "self", ".", "_notification_plan_man...
Creates a notification plan to be executed when a monitoring check triggers an alarm.
[ "Creates", "a", "notification", "plan", "to", "be", "executed", "when", "a", "monitoring", "check", "triggers", "an", "alarm", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1279-L1287
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.update_alarm
def update_alarm(self, entity, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Updates an existing alarm on the given entity. """ return entity.update_alarm(alarm, criteria=criteria, disabled=disabled, label=label, name=name, metad...
python
def update_alarm(self, entity, alarm, criteria=None, disabled=False, label=None, name=None, metadata=None): """ Updates an existing alarm on the given entity. """ return entity.update_alarm(alarm, criteria=criteria, disabled=disabled, label=label, name=name, metad...
[ "def", "update_alarm", "(", "self", ",", "entity", ",", "alarm", ",", "criteria", "=", "None", ",", "disabled", "=", "False", ",", "label", "=", "None", ",", "name", "=", "None", ",", "metadata", "=", "None", ")", ":", "return", "entity", ".", "updat...
Updates an existing alarm on the given entity.
[ "Updates", "an", "existing", "alarm", "on", "the", "given", "entity", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1321-L1327
pycontribs/pyrax
pyrax/cloudmonitoring.py
CloudMonitorClient.list_alarms
def list_alarms(self, entity, limit=None, marker=None, return_next=False): """ Returns a list of all the alarms created on the specified entity. """ return entity.list_alarms(limit=limit, marker=marker, return_next=return_next)
python
def list_alarms(self, entity, limit=None, marker=None, return_next=False): """ Returns a list of all the alarms created on the specified entity. """ return entity.list_alarms(limit=limit, marker=marker, return_next=return_next)
[ "def", "list_alarms", "(", "self", ",", "entity", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "return_next", "=", "False", ")", ":", "return", "entity", ".", "list_alarms", "(", "limit", "=", "limit", ",", "marker", "=", "marker", ",", ...
Returns a list of all the alarms created on the specified entity.
[ "Returns", "a", "list", "of", "all", "the", "alarms", "created", "on", "the", "specified", "entity", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/cloudmonitoring.py#L1331-L1336
pycontribs/pyrax
pyrax/http.py
request
def request(method, uri, *args, **kwargs): """ Handles all the common functionality required for API calls. Returns the resulting response object. Formats the request into a dict representing the headers and body that will be used to make the API call. """ req_method = req_methods[method.up...
python
def request(method, uri, *args, **kwargs): """ Handles all the common functionality required for API calls. Returns the resulting response object. Formats the request into a dict representing the headers and body that will be used to make the API call. """ req_method = req_methods[method.up...
[ "def", "request", "(", "method", ",", "uri", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "req_method", "=", "req_methods", "[", "method", ".", "upper", "(", ")", "]", "raise_exception", "=", "kwargs", ".", "pop", "(", "\"raise_exception\"", ",...
Handles all the common functionality required for API calls. Returns the resulting response object. Formats the request into a dict representing the headers and body that will be used to make the API call.
[ "Handles", "all", "the", "common", "functionality", "required", "for", "API", "calls", ".", "Returns", "the", "resulting", "response", "object", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/http.py#L42-L78
pycontribs/pyrax
pyrax/http.py
http_log_req
def http_log_req(method, uri, args, kwargs): """ When pyrax.get_http_debug() is True, outputs the equivalent `curl` command for the API request being made. """ if not pyrax.get_http_debug(): return string_parts = ["curl -i -X %s" % method] for element in args: string_parts.ap...
python
def http_log_req(method, uri, args, kwargs): """ When pyrax.get_http_debug() is True, outputs the equivalent `curl` command for the API request being made. """ if not pyrax.get_http_debug(): return string_parts = ["curl -i -X %s" % method] for element in args: string_parts.ap...
[ "def", "http_log_req", "(", "method", ",", "uri", ",", "args", ",", "kwargs", ")", ":", "if", "not", "pyrax", ".", "get_http_debug", "(", ")", ":", "return", "string_parts", "=", "[", "\"curl -i -X %s\"", "%", "method", "]", "for", "element", "in", "args...
When pyrax.get_http_debug() is True, outputs the equivalent `curl` command for the API request being made.
[ "When", "pyrax", ".", "get_http_debug", "()", "is", "True", "outputs", "the", "equivalent", "curl", "command", "for", "the", "API", "request", "being", "made", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/http.py#L81-L100
pycontribs/pyrax
pyrax/http.py
http_log_resp
def http_log_resp(resp, body): """ When pyrax.get_http_debug() is True, outputs the response received from the API request. """ if not pyrax.get_http_debug(): return log = logging.getLogger("pyrax") log.debug("RESP: %s\n%s", resp, resp.headers) if body: log.debug("RESP BO...
python
def http_log_resp(resp, body): """ When pyrax.get_http_debug() is True, outputs the response received from the API request. """ if not pyrax.get_http_debug(): return log = logging.getLogger("pyrax") log.debug("RESP: %s\n%s", resp, resp.headers) if body: log.debug("RESP BO...
[ "def", "http_log_resp", "(", "resp", ",", "body", ")", ":", "if", "not", "pyrax", ".", "get_http_debug", "(", ")", ":", "return", "log", "=", "logging", ".", "getLogger", "(", "\"pyrax\"", ")", "log", ".", "debug", "(", "\"RESP: %s\\n%s\"", ",", "resp", ...
When pyrax.get_http_debug() is True, outputs the response received from the API request.
[ "When", "pyrax", ".", "get_http_debug", "()", "is", "True", "outputs", "the", "response", "received", "from", "the", "API", "request", "." ]
train
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/http.py#L103-L113