networkapi.util package¶
Submodules¶
networkapi.util.decorators module¶
-
class
networkapi.util.decorators.
cached_property
(func)[source]¶ Bases:
object
Decorator that converts a method with a single self argument into a property cached on the instance. # https://github.com/django/django/blob/2456ffa42c33d63b54579eae0f5b9cf2a8cd3714/django/utils/functional.py#L38-50
networkapi.util.json_validate module¶
networkapi.util.signals_helper module¶
-
networkapi.util.signals_helper.
get_m2m_fields_for
(instance=None)[source]¶ gets m2mfields for instance
-
networkapi.util.signals_helper.
m2m_clean_unchanged_fields
(dict_diff)[source]¶ returns a list of dicts with only the changes
-
networkapi.util.signals_helper.
m2m_proccess_diff_states
(old, new)[source]¶ old and new are dictionaries in the following format
old: {u’toppings.1’: {u’id’: [1, None], ‘name’: [u’ceboloa’, None]},
u’toppings.11’: {u’id’: [11, None], ‘name’: [u’abacate’, None]}, u’toppings.5’: {u’id’: [5, None], ‘name’: [u’cogumelo’, None]}, u’toppings.6’: {u’id’: [6, None], ‘name’: [u’abobrinha’, None]}, u’toppings.8’: {u’id’: [8, None], ‘name’: [u’codorna’, None]}, u’toppings.9’: {u’id’: [9, None], ‘name’: [u’banana’, None]}}new: {u’toppings.1’: {u’id’: [None, 1], ‘name’: [None, u’ceboloa’]},
u’toppings.10’: {u’id’: [None, 10], ‘name’: [None, u’abacaxi’]}, u’toppings.5’: {u’id’: [None, 5], ‘name’: [None, u’cogumelo’]}, u’toppings.6’: {u’id’: [None, 6], ‘name’: [None, u’abobrinha’]}, u’toppings.8’: {u’id’: [None, 8], ‘name’: [None, u’codorna’]}, u’toppings.9’: {u’id’: [None, 9], ‘name’: [None, u’banana’]}}
Module contents¶
-
class
networkapi.util.
IP_VERSION
[source]¶ -
IPv4
= (u'v4', u'IPv4')¶
-
IPv6
= (u'v6', u'IPv6')¶
-
List
= ((u'v4', u'IPv4'), (u'v6', u'IPv6'))¶
-
-
networkapi.util.
cache_function
(length, equipment=False)[source]¶ Cache the result of function
@param length: time in seconds to stay in cache
-
networkapi.util.
clone
(obj)[source]¶ Clone the object
@param obj: object to be cloned
@return object cloned.
-
networkapi.util.
convert_boolean_to_int
(param)[source]¶ Convert the parameter of boolean to int.
@param param: parameter to be converted.
@return Parameter converted.
-
networkapi.util.
convert_string_or_int_to_boolean
(param, force=None)[source]¶ Convert the parameter of string or int to boolean. @param param: parameter to be converted. @return Parameter converted.
-
networkapi.util.
is_valid_boolean_param
(param, required=True)[source]¶ Checks if the parameter is a valid boolean.
@param param: Value to be validated.
@return True if the parameter has a valid boolean value, or False otherwise.
-
networkapi.util.
is_valid_email
(param)[source]¶ Checks if the parameter is a valid e-mail.
@param param: Value to be validated.
@return True if the parameter has a valid e-mail value, or False otherwise.
-
networkapi.util.
is_valid_healthcheck_destination
(param)[source]¶ Checks if the parameter is a valid healthcheck_destination.
@param param: Value to be validated.
@return True if the parameter has a valid healthcheck_destination value, or False otherwise.
-
networkapi.util.
is_valid_int_greater_equal_zero_param
(param)[source]¶ Checks if the parameter is a valid integer value and greater and equal than zero.
@param param: Value to be validated.
@return True if the parameter has a valid integer value, or False otherwise.
-
networkapi.util.
is_valid_int_greater_zero_param
(param, required=True)[source]¶ Checks if the parameter is a valid integer value and greater than zero.
@param param: Value to be validated.
@return True if the parameter has a valid integer value, or False otherwise.
-
networkapi.util.
is_valid_int_param
(param, required=True)[source]¶ Checks if the parameter is a valid integer value.
@param param: Value to be validated.
@return True if the parameter has a valid integer value, or False otherwise.
-
networkapi.util.
is_valid_ip_ipaddr
(param)[source]¶ Checks if the parameter is a valid ip is ipv4 or ipv6.
@param param: Value to be validated.
@return True if the parameter has a valid ipv6 or ipv4 value, or False otherwise.
-
networkapi.util.
is_valid_ipv4
(param)[source]¶ Checks if the parameter is a valid ipv4.
@param param: Value to be validated.
@return True if the parameter has a valid ipv4 value, or False otherwise.
-
networkapi.util.
is_valid_ipv6
(param)[source]¶ Checks if the parameter is a valid ipv6.
@param param: Value to be validated.
@return True if the parameter has a valid ipv6 value, or False otherwise.
-
networkapi.util.
is_valid_list_int_greater_zero_param
(list_param, required=True)[source]¶ Checks if the parameter list is a valid integer value and greater than zero.
@param param: Value to be validated.
@raise ValidationError: If there is validation error in the field
-
networkapi.util.
is_valid_option
(param)[source]¶ Checks if the parameter is a valid field text and 0-9 and should follow the format of [A-Za-z] and special characters hyphen, underline and point.
@param param: Value to be validated.
@return True if the parameter has a valid text value, or False otherwise.
-
networkapi.util.
is_valid_pool_identifier_text
(param, required=True)[source]¶ Checks if the parameter is a valid field text and should follow the format of [A-Za-z] and special characters hyphen and underline.
@param param: Value to be validated. @param required: Check if the value can be None
@return True if the parameter has a valid text value, or False otherwise.
-
networkapi.util.
is_valid_regex
(string, regex)[source]¶ Checks if the parameter is a valid value by regex.
Parameters: param – Value to be validated. Returns: True if the parameter has a valid vakue, or False otherwise.
-
networkapi.util.
is_valid_string_maxsize
(param, maxsize=None, required=True)[source]¶ Checks if the parameter is a valid string and his size is less than maxsize. If the parameter maxsize is None than the size is ignored If the parameter required is True than the string can not be None
@param param: Value to be validated. @param maxsize: Max size of the value to be validated. @param required: Check if the value can be None
@return True if the parameter is valid or False otherwise.
-
networkapi.util.
is_valid_string_minsize
(param, minsize=None, required=True)[source]¶ Checks if the parameter is a valid string and his size is more than minsize. If the parameter minsize is None than the size is ignored If the parameter required is True than the string can not be None
@param param: Value to be validated. @param minsize: Min size of the value to be validated. @param required: Check if the value can be None
@return True if the parameter is valid or False otherwise.
-
networkapi.util.
is_valid_text
(param, required=True)[source]¶ Checks if the parameter is a valid field text and should follow the format of [A-Za-z] and special characters hyphen and underline.
@param param: Value to be validated. @param required: Check if the value can be None
@return True if the parameter has a valid text value, or False otherwise.
-
networkapi.util.
is_valid_uri
(param)[source]¶ Checks if the parameter is a valid uri.
@param param: Value to be validated.
@return True if the parameter has a valid uri value, or False otherwise.
-
networkapi.util.
is_valid_version_ip
(param, IP_VERSION)[source]¶ Checks if the parameter is a valid ip version value.
@param param: Value to be validated.
@return True if the parameter has a valid ip version value, or False otherwise.
-
networkapi.util.
is_valid_yes_no_choice
(param)[source]¶ Checks if the parameter is valid ‘S’ or ‘N’ char.
@param param: valid to be validated.
@return True if the parameter is a valid choice, or False otherwise.
-
networkapi.util.
is_valid_zero_one_param
(param, required=True)[source]¶ Checks if the parameter is a valid zero or one string.
@param param: Value to be validated.
@return True if the parameter has a valid zero or one value, or False otherwise.