code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def get_api_key_with_prefix(self, identifier, alias=None): """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. :param alias: The alternative identifier of apiKey. :return: The token for api key authentication. """ if self.refresh_api_key_hook is not None: self.refresh_api_key_hook(self) key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) if key: prefix = self.api_key_prefix.get(identifier) if prefix: return "%s %s" % (prefix, key) else: return key
Gets API key (with prefix if set). :param identifier: The identifier of apiKey. :param alias: The alternative identifier of apiKey. :return: The token for api key authentication.
get_api_key_with_prefix
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def get_basic_auth_token(self): """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. """ username = "" if self.username is not None: username = self.username password = "" if self.password is not None: password = self.password return urllib3.util.make_headers( basic_auth=username + ':' + password ).get('authorization')
Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication.
get_basic_auth_token
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def to_debug_report(self): """Gets the essential information for debugging. :return: The report for debugging. """ return "Python SDK Debug Report:\n"\ "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 1.2.0\n"\ "SDK Package Version: 1.0.0".\ format(env=sys.platform, pyversion=sys.version)
Gets the essential information for debugging. :return: The report for debugging.
to_debug_report
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def get_host_settings(self): """Gets an array of host settings :return: An array of host settings """ return [ { 'url': "{scheme}://{host}/{basePath}", 'description': "No description provided", 'variables': { 'basePath': { 'description': "No description provided", 'default_value': "v1", }, 'host': { 'description': "No description provided", 'default_value': "localhost", }, 'scheme': { 'description': "No description provided", 'default_value': "http", 'enum_values': [ "http", "https" ] } } } ]
Gets an array of host settings :return: An array of host settings
get_host_settings
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def get_host_from_settings(self, index, variables=None, servers=None): """Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value :param servers: an array of host settings or None :return: URL based on host settings """ if index is None: return self._base_path variables = {} if variables is None else variables servers = self.get_host_settings() if servers is None else servers try: server = servers[index] except IndexError: raise ValueError( "Invalid index {0} when selecting the host settings. " "Must be less than {1}".format(index, len(servers))) url = server['url'] # go through variables and replace placeholders for variable_name, variable in server.get('variables', {}).items(): used_value = variables.get( variable_name, variable['default_value']) if 'enum_values' in variable \ and used_value not in variable['enum_values']: raise ValueError( "The variable `{0}` in the host URL has invalid value " "{1}. Must be {2}.".format( variable_name, variables[variable_name], variable['enum_values'])) url = url.replace("{" + variable_name + "}", used_value) return url
Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value :param servers: an array of host settings or None :return: URL based on host settings
get_host_from_settings
python
Yelp/paasta
paasta_tools/paastaapi/configuration.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/configuration.py
Apache-2.0
def __init__(self, msg, path_to_item=None): """ Args: msg (str): the exception message Keyword Args: path_to_item (list) the path to the exception in the received_data dict. None if unset """ self.path_to_item = path_to_item full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiValueError, self).__init__(full_msg)
Args: msg (str): the exception message Keyword Args: path_to_item (list) the path to the exception in the received_data dict. None if unset
__init__
python
Yelp/paasta
paasta_tools/paastaapi/exceptions.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/exceptions.py
Apache-2.0
def __init__(self, msg, path_to_item=None): """ Raised when an attribute reference or assignment fails. Args: msg (str): the exception message Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict """ self.path_to_item = path_to_item full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiAttributeError, self).__init__(full_msg)
Raised when an attribute reference or assignment fails. Args: msg (str): the exception message Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict
__init__
python
Yelp/paasta
paasta_tools/paastaapi/exceptions.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/exceptions.py
Apache-2.0
def __init__(self, msg, path_to_item=None): """ Args: msg (str): the exception message Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict """ self.path_to_item = path_to_item full_msg = msg if path_to_item: full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) super(ApiKeyError, self).__init__(full_msg)
Args: msg (str): the exception message Keyword Args: path_to_item (None/list) the path to the exception in the received_data dict
__init__
python
Yelp/paasta
paasta_tools/paastaapi/exceptions.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/exceptions.py
Apache-2.0
def allows_single_value_input(cls): """ This function returns True if the input composed schema model or any descendant model allows a value only input This is true for cases where oneOf contains items like: oneOf: - float - NumberWithValidation - StringEnum - ArrayModel - null TODO: lru_cache this """ if ( issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES ): return True elif issubclass(cls, ModelComposed): if not cls._composed_schemas['oneOf']: return False return any(allows_single_value_input(c) for c in cls._composed_schemas['oneOf']) return False
This function returns True if the input composed schema model or any descendant model allows a value only input This is true for cases where oneOf contains items like: oneOf: - float - NumberWithValidation - StringEnum - ArrayModel - null TODO: lru_cache this
allows_single_value_input
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def composed_model_input_classes(cls): """ This function returns a list of the possible models that can be accepted as inputs. TODO: lru_cache this """ if issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES: return [cls] elif issubclass(cls, ModelNormal): if cls.discriminator is None: return [cls] else: return get_discriminated_classes(cls) elif issubclass(cls, ModelComposed): if not cls._composed_schemas['oneOf']: return [] if cls.discriminator is None: input_classes = [] for c in cls._composed_schemas['oneOf']: input_classes.extend(composed_model_input_classes(c)) return input_classes else: return get_discriminated_classes(cls) return []
This function returns a list of the possible models that can be accepted as inputs. TODO: lru_cache this
composed_model_input_classes
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def __setitem__(self, name, value): """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" if name in self.required_properties: self.__dict__[name] = value return self.set_attribute(name, value)
set the value of an attribute using square-bracket notation: `instance[attr] = val`
__setitem__
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get(self, name, default=None): """returns the value of an attribute or some default value if the attribute was not set""" if name in self.required_properties: return self.__dict__[name] return self.__dict__['_data_store'].get(name, default)
returns the value of an attribute or some default value if the attribute was not set
get
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def __getitem__(self, name): """get the value of an attribute using square-bracket notation: `instance[attr]`""" if name in self: return self.get(name) raise ApiAttributeError( "{0} has no attribute '{1}'".format( type(self).__name__, name), [e for e in [self._path_to_item, name] if e] )
get the value of an attribute using square-bracket notation: `instance[attr]`
__getitem__
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def __contains__(self, name): """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" if name in self.required_properties: return name in self.__dict__ return name in self.__dict__['_data_store']
used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`
__contains__
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def __eq__(self, other): """Returns true if both objects are equal""" if not isinstance(other, self.__class__): return False this_val = self._data_store['value'] that_val = other._data_store['value'] types = set() types.add(this_val.__class__) types.add(that_val.__class__) vals_equal = this_val == that_val return vals_equal
Returns true if both objects are equal
__eq__
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_simple_class(input_value): """Returns an input_value's simple class that we will use for type checking Python2: float and int will return int, where int is the python3 int backport str and unicode will return str, where str is the python3 str backport Note: float and int ARE both instances of int backport Note: str_py2 and unicode_py2 are NOT both instances of str backport Args: input_value (class/class_instance): the item for which we will return the simple class """ if isinstance(input_value, type): # input_value is a class return input_value elif isinstance(input_value, tuple): return tuple elif isinstance(input_value, list): return list elif isinstance(input_value, dict): return dict elif isinstance(input_value, none_type): return none_type elif isinstance(input_value, file_type): return file_type elif isinstance(input_value, bool): # this must be higher than the int check because # isinstance(True, int) == True return bool elif isinstance(input_value, int): return int elif isinstance(input_value, datetime): # this must be higher than the date check because # isinstance(datetime_instance, date) == True return datetime elif isinstance(input_value, date): return date elif isinstance(input_value, str): return str return type(input_value)
Returns an input_value's simple class that we will use for type checking Python2: float and int will return int, where int is the python3 int backport str and unicode will return str, where str is the python3 str backport Note: float and int ARE both instances of int backport Note: str_py2 and unicode_py2 are NOT both instances of str backport Args: input_value (class/class_instance): the item for which we will return the simple class
get_simple_class
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def check_allowed_values(allowed_values, input_variable_path, input_values): """Raises an exception if the input_values are not allowed Args: allowed_values (dict): the allowed_values dict input_variable_path (tuple): the path to the input variable input_values (list/str/int/float/date/datetime): the values that we are checking to see if they are in allowed_values """ these_allowed_values = list(allowed_values[input_variable_path].values()) if (isinstance(input_values, list) and not set(input_values).issubset( set(these_allowed_values))): invalid_values = ", ".join( map(str, set(input_values) - set(these_allowed_values))), raise ApiValueError( "Invalid values for `%s` [%s], must be a subset of [%s]" % ( input_variable_path[0], invalid_values, ", ".join(map(str, these_allowed_values)) ) ) elif (isinstance(input_values, dict) and not set( input_values.keys()).issubset(set(these_allowed_values))): invalid_values = ", ".join( map(str, set(input_values.keys()) - set(these_allowed_values))) raise ApiValueError( "Invalid keys in `%s` [%s], must be a subset of [%s]" % ( input_variable_path[0], invalid_values, ", ".join(map(str, these_allowed_values)) ) ) elif (not isinstance(input_values, (list, dict)) and input_values not in these_allowed_values): raise ApiValueError( "Invalid value for `%s` (%s), must be one of %s" % ( input_variable_path[0], input_values, these_allowed_values ) )
Raises an exception if the input_values are not allowed Args: allowed_values (dict): the allowed_values dict input_variable_path (tuple): the path to the input variable input_values (list/str/int/float/date/datetime): the values that we are checking to see if they are in allowed_values
check_allowed_values
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def is_json_validation_enabled(schema_keyword, configuration=None): """Returns true if JSON schema validation is enabled for the specified validation keyword. This can be used to skip JSON schema structural validation as requested in the configuration. Args: schema_keyword (string): the name of a JSON schema validation keyword. configuration (Configuration): the configuration class. """ return (configuration is None or not hasattr(configuration, '_disabled_client_side_validations') or schema_keyword not in configuration._disabled_client_side_validations)
Returns true if JSON schema validation is enabled for the specified validation keyword. This can be used to skip JSON schema structural validation as requested in the configuration. Args: schema_keyword (string): the name of a JSON schema validation keyword. configuration (Configuration): the configuration class.
is_json_validation_enabled
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def check_validations( validations, input_variable_path, input_values, configuration=None): """Raises an exception if the input_values are invalid Args: validations (dict): the validation dictionary. input_variable_path (tuple): the path to the input variable. input_values (list/str/int/float/date/datetime): the values that we are checking. configuration (Configuration): the configuration class. """ current_validations = validations[input_variable_path] if (is_json_validation_enabled('multipleOf', configuration) and 'multiple_of' in current_validations and isinstance(input_values, (int, float)) and not (float(input_values) / current_validations['multiple_of']).is_integer()): # Note 'multipleOf' will be as good as the floating point arithmetic. raise ApiValueError( "Invalid value for `%s`, value must be a multiple of " "`%s`" % ( input_variable_path[0], current_validations['multiple_of'] ) ) if (is_json_validation_enabled('maxLength', configuration) and 'max_length' in current_validations and len(input_values) > current_validations['max_length']): raise ApiValueError( "Invalid value for `%s`, length must be less than or equal to " "`%s`" % ( input_variable_path[0], current_validations['max_length'] ) ) if (is_json_validation_enabled('minLength', configuration) and 'min_length' in current_validations and len(input_values) < current_validations['min_length']): raise ApiValueError( "Invalid value for `%s`, length must be greater than or equal to " "`%s`" % ( input_variable_path[0], current_validations['min_length'] ) ) if (is_json_validation_enabled('maxItems', configuration) and 'max_items' in current_validations and len(input_values) > current_validations['max_items']): raise ApiValueError( "Invalid value for `%s`, number of items must be less than or " "equal to `%s`" % ( input_variable_path[0], current_validations['max_items'] ) ) if (is_json_validation_enabled('minItems', configuration) and 'min_items' in current_validations and len(input_values) < current_validations['min_items']): raise ValueError( "Invalid value for `%s`, number of items must be greater than or " "equal to `%s`" % ( input_variable_path[0], current_validations['min_items'] ) ) items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', 'inclusive_minimum') if (any(item in current_validations for item in items)): if isinstance(input_values, list): max_val = max(input_values) min_val = min(input_values) elif isinstance(input_values, dict): max_val = max(input_values.values()) min_val = min(input_values.values()) else: max_val = input_values min_val = input_values if (is_json_validation_enabled('exclusiveMaximum', configuration) and 'exclusive_maximum' in current_validations and max_val >= current_validations['exclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than `%s`" % ( input_variable_path[0], current_validations['exclusive_maximum'] ) ) if (is_json_validation_enabled('maximum', configuration) and 'inclusive_maximum' in current_validations and max_val > current_validations['inclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than or equal to " "`%s`" % ( input_variable_path[0], current_validations['inclusive_maximum'] ) ) if (is_json_validation_enabled('exclusiveMinimum', configuration) and 'exclusive_minimum' in current_validations and min_val <= current_validations['exclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than `%s`" % ( input_variable_path[0], current_validations['exclusive_maximum'] ) ) if (is_json_validation_enabled('minimum', configuration) and 'inclusive_minimum' in current_validations and min_val < current_validations['inclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than or equal " "to `%s`" % ( input_variable_path[0], current_validations['inclusive_minimum'] ) ) flags = current_validations.get('regex', {}).get('flags', 0) if (is_json_validation_enabled('pattern', configuration) and 'regex' in current_validations and not re.search(current_validations['regex']['pattern'], input_values, flags=flags)): err_msg = r"Invalid value for `%s`, must match regular expression `%s`" % ( input_variable_path[0], current_validations['regex']['pattern'] ) if flags != 0: # Don't print the regex flags if the flags are not # specified in the OAS document. err_msg = r"%s with flags=`%s`" % (err_msg, flags) raise ApiValueError(err_msg)
Raises an exception if the input_values are invalid Args: validations (dict): the validation dictionary. input_variable_path (tuple): the path to the input variable. input_values (list/str/int/float/date/datetime): the values that we are checking. configuration (Configuration): the configuration class.
check_validations
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def order_response_types(required_types): """Returns the required types sorted in coercion order Args: required_types (list/tuple): collection of classes or instance of list or dict with class information inside it. Returns: (list): coercion order sorted collection of classes or instance of list or dict with class information inside it. """ def index_getter(class_or_instance): if isinstance(class_or_instance, list): return COERCION_INDEX_BY_TYPE[list] elif isinstance(class_or_instance, dict): return COERCION_INDEX_BY_TYPE[dict] elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelComposed)): return COERCION_INDEX_BY_TYPE[ModelComposed] elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelNormal)): return COERCION_INDEX_BY_TYPE[ModelNormal] elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelSimple)): return COERCION_INDEX_BY_TYPE[ModelSimple] elif class_or_instance in COERCION_INDEX_BY_TYPE: return COERCION_INDEX_BY_TYPE[class_or_instance] raise ApiValueError("Unsupported type: %s" % class_or_instance) sorted_types = sorted( required_types, key=lambda class_or_instance: index_getter(class_or_instance) ) return sorted_types
Returns the required types sorted in coercion order Args: required_types (list/tuple): collection of classes or instance of list or dict with class information inside it. Returns: (list): coercion order sorted collection of classes or instance of list or dict with class information inside it.
order_response_types
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_discriminated_classes(cls): """ Returns all the classes that a discriminator converts to TODO: lru_cache this """ possible_classes = [] key = list(cls.discriminator.keys())[0] if is_type_nullable(cls): possible_classes.append(cls) for discr_cls in cls.discriminator[key].values(): if hasattr(discr_cls, 'discriminator') and discr_cls.discriminator is not None: possible_classes.extend(get_discriminated_classes(discr_cls)) else: possible_classes.append(discr_cls) return possible_classes
Returns all the classes that a discriminator converts to TODO: lru_cache this
get_discriminated_classes
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_required_type_classes(required_types_mixed, spec_property_naming): """Converts the tuple required_types into a tuple and a dict described below Args: required_types_mixed (tuple/list): will contain either classes or instance of list or dict spec_property_naming (bool): if True these values came from the server, and we use the data types in our endpoints. If False, we are client side and we need to include oneOf and discriminator classes inside the data types in our endpoints Returns: (valid_classes, dict_valid_class_to_child_types_mixed): valid_classes (tuple): the valid classes that the current item should be dict_valid_class_to_child_types_mixed (dict): valid_class (class): this is the key child_types_mixed (list/dict/tuple): describes the valid child types """ valid_classes = [] child_req_types_by_current_type = {} for required_type in required_types_mixed: if isinstance(required_type, list): valid_classes.append(list) child_req_types_by_current_type[list] = required_type elif isinstance(required_type, tuple): valid_classes.append(tuple) child_req_types_by_current_type[tuple] = required_type elif isinstance(required_type, dict): valid_classes.append(dict) child_req_types_by_current_type[dict] = required_type[str] else: valid_classes.extend(get_possible_classes(required_type, spec_property_naming)) return tuple(valid_classes), child_req_types_by_current_type
Converts the tuple required_types into a tuple and a dict described below Args: required_types_mixed (tuple/list): will contain either classes or instance of list or dict spec_property_naming (bool): if True these values came from the server, and we use the data types in our endpoints. If False, we are client side and we need to include oneOf and discriminator classes inside the data types in our endpoints Returns: (valid_classes, dict_valid_class_to_child_types_mixed): valid_classes (tuple): the valid classes that the current item should be dict_valid_class_to_child_types_mixed (dict): valid_class (class): this is the key child_types_mixed (list/dict/tuple): describes the valid child types
get_required_type_classes
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def change_keys_js_to_python(input_dict, model_class): """ Converts from javascript_key keys in the input_dict to python_keys in the output dict using the mapping in model_class. If the input_dict contains a key which does not declared in the model_class, the key is added to the output dict as is. The assumption is the model_class may have undeclared properties (additionalProperties attribute in the OAS document). """ if getattr(model_class, 'attribute_map', None) is None: return input_dict output_dict = {} reversed_attr_map = {value: key for key, value in model_class.attribute_map.items()} for javascript_key, value in input_dict.items(): python_key = reversed_attr_map.get(javascript_key) if python_key is None: # if the key is unknown, it is in error or it is an # additionalProperties variable python_key = javascript_key output_dict[python_key] = value return output_dict
Converts from javascript_key keys in the input_dict to python_keys in the output dict using the mapping in model_class. If the input_dict contains a key which does not declared in the model_class, the key is added to the output dict as is. The assumption is the model_class may have undeclared properties (additionalProperties attribute in the OAS document).
change_keys_js_to_python
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_discriminator_class(model_class, discr_name, discr_value, cls_visited): """Returns the child class specified by the discriminator. Args: model_class (OpenApiModel): the model class. discr_name (string): the name of the discriminator property. discr_value (any): the discriminator value. cls_visited (list): list of model classes that have been visited. Used to determine the discriminator class without visiting circular references indefinitely. Returns: used_model_class (class/None): the chosen child class that will be used to deserialize the data, for example dog.Dog. If a class is not found, None is returned. """ if model_class in cls_visited: # The class has already been visited and no suitable class was found. return None cls_visited.append(model_class) used_model_class = None if discr_name in model_class.discriminator: class_name_to_discr_class = model_class.discriminator[discr_name] used_model_class = class_name_to_discr_class.get(discr_value) if used_model_class is None: # We didn't find a discriminated class in class_name_to_discr_class. # So look in the ancestor or descendant discriminators # The discriminator mapping may exist in a descendant (anyOf, oneOf) # or ancestor (allOf). # Ancestor example: in the GrandparentAnimal -> ParentPet -> ChildCat # hierarchy, the discriminator mappings may be defined at any level # in the hierarchy. # Descendant example: mammal -> whale/zebra/Pig -> BasquePig/DanishPig # if we try to make BasquePig from mammal, we need to travel through # the oneOf descendant discriminators to find BasquePig descendant_classes = model_class._composed_schemas.get('oneOf', ()) + \ model_class._composed_schemas.get('anyOf', ()) ancestor_classes = model_class._composed_schemas.get('allOf', ()) possible_classes = descendant_classes + ancestor_classes for cls in possible_classes: # Check if the schema has inherited discriminators. if hasattr(cls, 'discriminator') and cls.discriminator is not None: used_model_class = get_discriminator_class( cls, discr_name, discr_value, cls_visited) if used_model_class is not None: return used_model_class return used_model_class
Returns the child class specified by the discriminator. Args: model_class (OpenApiModel): the model class. discr_name (string): the name of the discriminator property. discr_value (any): the discriminator value. cls_visited (list): list of model classes that have been visited. Used to determine the discriminator class without visiting circular references indefinitely. Returns: used_model_class (class/None): the chosen child class that will be used to deserialize the data, for example dog.Dog. If a class is not found, None is returned.
get_discriminator_class
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, spec_property_naming): """Deserializes model_data to model instance. Args: model_data (int/str/float/bool/none_type/list/dict): data to instantiate the model model_class (OpenApiModel): the model class path_to_item (list): path to the model in the received data check_type (bool): whether to check the data tupe for the values in the model configuration (Configuration): the instance to use to convert files spec_property_naming (bool): True if the variable names in the input data are serialized names as specified in the OpenAPI document. False if the variables names in the input data are python variable names in PEP-8 snake case. Returns: model instance Raise: ApiTypeError ApiValueError ApiKeyError """ kw_args = dict(_check_type=check_type, _path_to_item=path_to_item, _configuration=configuration, _spec_property_naming=spec_property_naming) if issubclass(model_class, ModelSimple): return model_class(model_data, **kw_args) elif isinstance(model_data, list): return model_class(*model_data, **kw_args) if isinstance(model_data, dict): kw_args.update(model_data) return model_class(**kw_args) elif isinstance(model_data, PRIMITIVE_TYPES): return model_class(model_data, **kw_args)
Deserializes model_data to model instance. Args: model_data (int/str/float/bool/none_type/list/dict): data to instantiate the model model_class (OpenApiModel): the model class path_to_item (list): path to the model in the received data check_type (bool): whether to check the data tupe for the values in the model configuration (Configuration): the instance to use to convert files spec_property_naming (bool): True if the variable names in the input data are serialized names as specified in the OpenAPI document. False if the variables names in the input data are python variable names in PEP-8 snake case. Returns: model instance Raise: ApiTypeError ApiValueError ApiKeyError
deserialize_model
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def deserialize_file(response_data, configuration, content_disposition=None): """Deserializes body to file Saves response body into a file in a temporary folder, using the filename from the `Content-Disposition` header if provided. Args: param response_data (str): the file data to write configuration (Configuration): the instance to use to convert files Keyword Args: content_disposition (str): the value of the Content-Disposition header Returns: (file_type): the deserialized file which is open The user is responsible for closing and reading the file """ fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) os.close(fd) os.remove(path) if content_disposition: filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: if isinstance(response_data, str): # change str to bytes so we can write it response_data = response_data.encode('utf-8') f.write(response_data) f = open(path, "rb") return f
Deserializes body to file Saves response body into a file in a temporary folder, using the filename from the `Content-Disposition` header if provided. Args: param response_data (str): the file data to write configuration (Configuration): the instance to use to convert files Keyword Args: content_disposition (str): the value of the Content-Disposition header Returns: (file_type): the deserialized file which is open The user is responsible for closing and reading the file
deserialize_file
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def attempt_convert_item(input_value, valid_classes, path_to_item, configuration, spec_property_naming, key_type=False, must_convert=False, check_type=True): """ Args: input_value (any): the data to convert valid_classes (any): the classes that are valid path_to_item (list): the path to the item to convert configuration (Configuration): the instance to use to convert files spec_property_naming (bool): True if the variable names in the input data are serialized names as specified in the OpenAPI document. False if the variables names in the input data are python variable names in PEP-8 snake case. key_type (bool): if True we need to convert a key type (not supported) must_convert (bool): if True we must convert check_type (bool): if True we check the type or the returned data in ModelComposed/ModelNormal/ModelSimple instances Returns: instance (any) the fixed item Raises: ApiTypeError ApiValueError ApiKeyError """ valid_classes_ordered = order_response_types(valid_classes) valid_classes_coercible = remove_uncoercible( valid_classes_ordered, input_value, spec_property_naming) if not valid_classes_coercible or key_type: # we do not handle keytype errors, json will take care # of this for us if configuration is None or not configuration.discard_unknown_keys: raise get_type_error(input_value, path_to_item, valid_classes, key_type=key_type) for valid_class in valid_classes_coercible: try: if issubclass(valid_class, OpenApiModel): return deserialize_model(input_value, valid_class, path_to_item, check_type, configuration, spec_property_naming) elif valid_class == file_type: return deserialize_file(input_value, configuration) return deserialize_primitive(input_value, valid_class, path_to_item) except (ApiTypeError, ApiValueError, ApiKeyError) as conversion_exc: if must_convert: raise conversion_exc # if we have conversion errors when must_convert == False # we ignore the exception and move on to the next class continue # we were unable to convert, must_convert == False return input_value
Args: input_value (any): the data to convert valid_classes (any): the classes that are valid path_to_item (list): the path to the item to convert configuration (Configuration): the instance to use to convert files spec_property_naming (bool): True if the variable names in the input data are serialized names as specified in the OpenAPI document. False if the variables names in the input data are python variable names in PEP-8 snake case. key_type (bool): if True we need to convert a key type (not supported) must_convert (bool): if True we must convert check_type (bool): if True we check the type or the returned data in ModelComposed/ModelNormal/ModelSimple instances Returns: instance (any) the fixed item Raises: ApiTypeError ApiValueError ApiKeyError
attempt_convert_item
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def is_type_nullable(input_type): """ Returns true if None is an allowed value for the specified input_type. A type is nullable if at least one of the following conditions is true: 1. The OAS 'nullable' attribute has been specified, 1. The type is the 'null' type, 1. The type is a anyOf/oneOf composed schema, and a child schema is the 'null' type. Args: input_type (type): the class of the input_value that we are checking Returns: bool """ if input_type is none_type: return True if issubclass(input_type, OpenApiModel) and input_type._nullable: return True if issubclass(input_type, ModelComposed): # If oneOf/anyOf, check if the 'null' type is one of the allowed types. for t in input_type._composed_schemas.get('oneOf', ()): if is_type_nullable(t): return True for t in input_type._composed_schemas.get('anyOf', ()): if is_type_nullable(t): return True return False
Returns true if None is an allowed value for the specified input_type. A type is nullable if at least one of the following conditions is true: 1. The OAS 'nullable' attribute has been specified, 1. The type is the 'null' type, 1. The type is a anyOf/oneOf composed schema, and a child schema is the 'null' type. Args: input_type (type): the class of the input_value that we are checking Returns: bool
is_type_nullable
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def is_valid_type(input_class_simple, valid_classes): """ Args: input_class_simple (class): the class of the input_value that we are checking valid_classes (tuple): the valid classes that the current item should be Returns: bool """ valid_type = input_class_simple in valid_classes if not valid_type and ( issubclass(input_class_simple, OpenApiModel) or input_class_simple is none_type): for valid_class in valid_classes: if input_class_simple is none_type and is_type_nullable(valid_class): # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. return True if not (issubclass(valid_class, OpenApiModel) and valid_class.discriminator): continue discr_propertyname_py = list(valid_class.discriminator.keys())[0] discriminator_classes = ( valid_class.discriminator[discr_propertyname_py].values() ) valid_type = is_valid_type(input_class_simple, discriminator_classes) if valid_type: return True return valid_type
Args: input_class_simple (class): the class of the input_value that we are checking valid_classes (tuple): the valid classes that the current item should be Returns: bool
is_valid_type
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def validate_and_convert_types(input_value, required_types_mixed, path_to_item, spec_property_naming, _check_type, configuration=None): """Raises a TypeError is there is a problem, otherwise returns value Args: input_value (any): the data to validate/convert required_types_mixed (list/dict/tuple): A list of valid classes, or a list tuples of valid classes, or a dict where the value is a tuple of value classes path_to_item: (list) the path to the data being validated this stores a list of keys or indices to get to the data being validated spec_property_naming (bool): True if the variable names in the input data are serialized names as specified in the OpenAPI document. False if the variables names in the input data are python variable names in PEP-8 snake case. _check_type: (boolean) if true, type will be checked and conversion will be attempted. configuration: (Configuration): the configuration class to use when converting file_type items. If passed, conversion will be attempted when possible If not passed, no conversions will be attempted and exceptions will be raised Returns: the correctly typed value Raises: ApiTypeError """ results = get_required_type_classes(required_types_mixed, spec_property_naming) valid_classes, child_req_types_by_current_type = results input_class_simple = get_simple_class(input_value) valid_type = is_valid_type(input_class_simple, valid_classes) if not valid_type: if configuration: # if input_value is not valid_type try to convert it converted_instance = attempt_convert_item( input_value, valid_classes, path_to_item, configuration, spec_property_naming, key_type=False, must_convert=True ) return converted_instance else: raise get_type_error(input_value, path_to_item, valid_classes, key_type=False) # input_value's type is in valid_classes if len(valid_classes) > 1 and configuration: # there are valid classes which are not the current class valid_classes_coercible = remove_uncoercible( valid_classes, input_value, spec_property_naming, must_convert=False) if valid_classes_coercible: converted_instance = attempt_convert_item( input_value, valid_classes_coercible, path_to_item, configuration, spec_property_naming, key_type=False, must_convert=False ) return converted_instance if child_req_types_by_current_type == {}: # all types are of the required types and there are no more inner # variables left to look at return input_value inner_required_types = child_req_types_by_current_type.get( type(input_value) ) if inner_required_types is None: # for this type, there are not more inner variables left to look at return input_value if isinstance(input_value, list): if input_value == []: # allow an empty list return input_value for index, inner_value in enumerate(input_value): inner_path = list(path_to_item) inner_path.append(index) input_value[index] = validate_and_convert_types( inner_value, inner_required_types, inner_path, spec_property_naming, _check_type, configuration=configuration ) elif isinstance(input_value, dict): if input_value == {}: # allow an empty dict return input_value for inner_key, inner_val in input_value.items(): inner_path = list(path_to_item) inner_path.append(inner_key) if get_simple_class(inner_key) != str: raise get_type_error(inner_key, inner_path, valid_classes, key_type=True) input_value[inner_key] = validate_and_convert_types( inner_val, inner_required_types, inner_path, spec_property_naming, _check_type, configuration=configuration ) return input_value
Raises a TypeError is there is a problem, otherwise returns value Args: input_value (any): the data to validate/convert required_types_mixed (list/dict/tuple): A list of valid classes, or a list tuples of valid classes, or a dict where the value is a tuple of value classes path_to_item: (list) the path to the data being validated this stores a list of keys or indices to get to the data being validated spec_property_naming (bool): True if the variable names in the input data are serialized names as specified in the OpenAPI document. False if the variables names in the input data are python variable names in PEP-8 snake case. _check_type: (boolean) if true, type will be checked and conversion will be attempted. configuration: (Configuration): the configuration class to use when converting file_type items. If passed, conversion will be attempted when possible If not passed, no conversions will be attempted and exceptions will be raised Returns: the correctly typed value Raises: ApiTypeError
validate_and_convert_types
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def model_to_dict(model_instance, serialize=True): """Returns the model properties as a dict Args: model_instance (one of your model instances): the model instance that will be converted to a dict. Keyword Args: serialize (bool): if True, the keys in the dict will be values from attribute_map """ result = {} model_instances = [model_instance] if model_instance._composed_schemas: model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in model_instance._data_store.items(): if serialize: # we use get here because additional property key names do not # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): result[attr] = list(map( lambda x: model_to_dict(x, serialize=serialize) if hasattr(x, '_data_store') else x, value )) elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], model_to_dict(item[1], serialize=serialize)) if hasattr(item[1], '_data_store') else item, value.items() )) elif isinstance(value, ModelSimple): result[attr] = value.value elif hasattr(value, '_data_store'): result[attr] = model_to_dict(value, serialize=serialize) else: result[attr] = value return result
Returns the model properties as a dict Args: model_instance (one of your model instances): the model instance that will be converted to a dict. Keyword Args: serialize (bool): if True, the keys in the dict will be values from attribute_map
model_to_dict
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def type_error_message(var_value=None, var_name=None, valid_classes=None, key_type=None): """ Keyword Args: var_value (any): the variable which has the type_error var_name (str): the name of the variable which has the typ error valid_classes (tuple): the accepted classes for current_item's value key_type (bool): False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list """ key_or_value = 'value' if key_type: key_or_value = 'key' valid_classes_phrase = get_valid_classes_phrase(valid_classes) msg = ( "Invalid type for variable '{0}'. Required {1} type {2} and " "passed type was {3}".format( var_name, key_or_value, valid_classes_phrase, type(var_value).__name__, ) ) return msg
Keyword Args: var_value (any): the variable which has the type_error var_name (str): the name of the variable which has the typ error valid_classes (tuple): the accepted classes for current_item's value key_type (bool): False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list
type_error_message
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_valid_classes_phrase(input_classes): """Returns a string phrase describing what types are allowed """ all_classes = list(input_classes) all_classes = sorted(all_classes, key=lambda cls: cls.__name__) all_class_names = [cls.__name__ for cls in all_classes] if len(all_class_names) == 1: return 'is {0}'.format(all_class_names[0]) return "is one of [{0}]".format(", ".join(all_class_names))
Returns a string phrase describing what types are allowed
get_valid_classes_phrase
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_allof_instances(self, model_args, constant_args): """ Args: self: the class we are handling model_args (dict): var_name to var_value used to make instances constant_args (dict): var_name to var_value used to make instances Returns composed_instances (list) """ composed_instances = [] for allof_class in self._composed_schemas['allOf']: # no need to handle changing js keys to python because # for composed schemas, allof parameters are included in the # composed schema and were changed to python keys in __new__ # extract a dict of only required keys from fixed_model_args kwargs = {} var_names = set(allof_class.openapi_types.keys()) for var_name in var_names: if var_name in model_args: kwargs[var_name] = model_args[var_name] # and use it to make the instance kwargs.update(constant_args) try: allof_instance = allof_class(**kwargs) composed_instances.append(allof_instance) except Exception as ex: raise ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " "schema '%s'. Error=%s" % ( allof_class.__name__, allof_class.__name__, self.__class__.__name__, str(ex) ) ) from ex return composed_instances
Args: self: the class we are handling model_args (dict): var_name to var_value used to make instances constant_args (dict): var_name to var_value used to make instances Returns composed_instances (list)
get_allof_instances
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def get_anyof_instances(self, model_args, constant_args): """ Args: self: the class we are handling model_args (dict): var_name to var_value The input data, e.g. the payload that must match at least one anyOf child schema in the OpenAPI document. constant_args (dict): var_name to var_value args that every model requires, including configuration, server and path to item. Returns anyof_instances (list) """ anyof_instances = [] if len(self._composed_schemas['anyOf']) == 0: return anyof_instances for anyof_class in self._composed_schemas['anyOf']: # The composed oneOf schema allows the 'null' type and the input data # is the null value. This is a OAS >= 3.1 feature. if anyof_class is none_type: # skip none_types because we are deserializing dict data. # none_type deserialization is handled in the __new__ method continue # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python(model_args, anyof_class) # extract a dict of only required keys from these_model_vars kwargs = {} var_names = set(anyof_class.openapi_types.keys()) for var_name in var_names: if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] # do not try to make a model with no input args if len(kwargs) == 0: continue # and use it to make the instance kwargs.update(constant_args) try: anyof_instance = anyof_class(**kwargs) anyof_instances.append(anyof_instance) except Exception: pass if len(anyof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. None of the " "anyOf schemas matched the inputs." % self.__class__.__name__ ) return anyof_instances
Args: self: the class we are handling model_args (dict): var_name to var_value The input data, e.g. the payload that must match at least one anyOf child schema in the OpenAPI document. constant_args (dict): var_name to var_value args that every model requires, including configuration, server and path to item. Returns anyof_instances (list)
get_anyof_instances
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def validate_get_composed_info(constant_args, model_args, self): """ For composed schemas, generate schema instances for all schemas in the oneOf/anyOf/allOf definition. If additional properties are allowed, also assign those properties on all matched schemas that contain additionalProperties. Openapi schemas are python classes. Exceptions are raised if: - 0 or > 1 oneOf schema matches the model_args input data - no anyOf schema matches the model_args input data - any of the allOf schemas do not match the model_args input data Args: constant_args (dict): these are the args that every model requires model_args (dict): these are the required and optional spec args that were passed in to make this model self (class): the class that we are instantiating This class contains self._composed_schemas Returns: composed_info (list): length three composed_instances (list): the composed instances which are not self var_name_to_model_instances (dict): a dict going from var_name to the model_instance which holds that var_name the model_instance may be self or an instance of one of the classes in self.composed_instances() additional_properties_model_instances (list): a list of the model instances which have the property additional_properties_type. This list can include self """ # create composed_instances composed_instances = [] allof_instances = get_allof_instances(self, model_args, constant_args) composed_instances.extend(allof_instances) oneof_instance = get_oneof_instance(self.__class__, model_args, constant_args) if oneof_instance is not None: composed_instances.append(oneof_instance) anyof_instances = get_anyof_instances(self, model_args, constant_args) composed_instances.extend(anyof_instances) # map variable names to composed_instances var_name_to_model_instances = get_var_name_to_model_instances( self, composed_instances) # set additional_properties_model_instances additional_properties_model_instances = ( get_additional_properties_model_instances(composed_instances, self) ) # set any remaining values unused_args = get_unused_args(self, composed_instances, model_args) if len(unused_args) > 0 and \ len(additional_properties_model_instances) == 0 and \ (self._configuration is None or not self._configuration.discard_unknown_keys): raise ApiValueError( "Invalid input arguments input when making an instance of " "class %s. Not all inputs were used. The unused input data " "is %s" % (self.__class__.__name__, unused_args) ) # no need to add additional_properties to var_name_to_model_instances here # because additional_properties_model_instances will direct us to that # instance when we use getattr or setattr # and we update var_name_to_model_instances in setattr return [ composed_instances, var_name_to_model_instances, additional_properties_model_instances, unused_args ]
For composed schemas, generate schema instances for all schemas in the oneOf/anyOf/allOf definition. If additional properties are allowed, also assign those properties on all matched schemas that contain additionalProperties. Openapi schemas are python classes. Exceptions are raised if: - 0 or > 1 oneOf schema matches the model_args input data - no anyOf schema matches the model_args input data - any of the allOf schemas do not match the model_args input data Args: constant_args (dict): these are the args that every model requires model_args (dict): these are the required and optional spec args that were passed in to make this model self (class): the class that we are instantiating This class contains self._composed_schemas Returns: composed_info (list): length three composed_instances (list): the composed instances which are not self var_name_to_model_instances (dict): a dict going from var_name to the model_instance which holds that var_name the model_instance may be self or an instance of one of the classes in self.composed_instances() additional_properties_model_instances (list): a list of the model instances which have the property additional_properties_type. This list can include self
validate_get_composed_info
python
Yelp/paasta
paasta_tools/paastaapi/model_utils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model_utils.py
Apache-2.0
def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): """Perform requests. :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. """ method = method.upper() assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS'] if post_params and body: raise ApiValueError( "body parameter cannot be used with post_params parameter." ) post_params = post_params or {} headers = headers or {} timeout = None if _request_timeout: if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif (isinstance(_request_timeout, tuple) and len(_request_timeout) == 2): timeout = urllib3.Timeout( connect=_request_timeout[0], read=_request_timeout[1]) if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, headers=headers) elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. del headers['Content-Type'] r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, headers=headers) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided arguments. Please check that your arguments match declared content type.""" raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: r = self.pool_manager.request(method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) if _preload_content: r = RESTResponse(r) # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) return r
Perform requests. :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.
request
python
Yelp/paasta
paasta_tools/paastaapi/rest.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/rest.py
Apache-2.0
def __get_autoscaler_count( self, service, instance, **kwargs ): """Get status of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_autoscaler_count(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: AutoscalerCountMsg If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get status of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_autoscaler_count(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: AutoscalerCountMsg If the method is called asynchronously, returns the request thread.
__get_autoscaler_count
python
Yelp/paasta
paasta_tools/paastaapi/api/autoscaler_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/autoscaler_api.py
Apache-2.0
def __set_autoscaling_override( self, service, instance, autoscaling_override, **kwargs ): """Set a temporary autoscaling override for a service instance # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.set_autoscaling_override(service, instance, autoscaling_override, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name autoscaling_override (AutoscalingOverride): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InlineResponse202 If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['autoscaling_override'] = \ autoscaling_override return self.call_with_http_info(**kwargs)
Set a temporary autoscaling override for a service instance # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.set_autoscaling_override(service, instance, autoscaling_override, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name autoscaling_override (AutoscalingOverride): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InlineResponse202 If the method is called asynchronously, returns the request thread.
__set_autoscaling_override
python
Yelp/paasta
paasta_tools/paastaapi/api/autoscaler_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/autoscaler_api.py
Apache-2.0
def __update_autoscaler_count( self, service, instance, autoscaler_count_msg, **kwargs ): """Set desired instance count for a service instance # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_autoscaler_count(service, instance, autoscaler_count_msg, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name autoscaler_count_msg (AutoscalerCountMsg): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: AutoscalerCountMsg If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['autoscaler_count_msg'] = \ autoscaler_count_msg return self.call_with_http_info(**kwargs)
Set desired instance count for a service instance # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_autoscaler_count(service, instance, autoscaler_count_msg, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name autoscaler_count_msg (AutoscalerCountMsg): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: AutoscalerCountMsg If the method is called asynchronously, returns the request thread.
__update_autoscaler_count
python
Yelp/paasta
paasta_tools/paastaapi/api/autoscaler_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/autoscaler_api.py
Apache-2.0
def __delete_service_autoscaler_pause( self, **kwargs ): """Unpause the autoscaler # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_service_autoscaler_pause(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: None If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs)
Unpause the autoscaler # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_service_autoscaler_pause(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: None If the method is called asynchronously, returns the request thread.
__delete_service_autoscaler_pause
python
Yelp/paasta
paasta_tools/paastaapi/api/default_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/default_api.py
Apache-2.0
def __deploy_queue( self, **kwargs ): """Get deploy queue contents # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.deploy_queue(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: DeployQueue If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs)
Get deploy queue contents # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.deploy_queue(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: DeployQueue If the method is called asynchronously, returns the request thread.
__deploy_queue
python
Yelp/paasta
paasta_tools/paastaapi/api/default_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/default_api.py
Apache-2.0
def __get_service_autoscaler_pause( self, **kwargs ): """Get autoscaling pause time # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_service_autoscaler_pause(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: str If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs)
Get autoscaling pause time # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_service_autoscaler_pause(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: str If the method is called asynchronously, returns the request thread.
__get_service_autoscaler_pause
python
Yelp/paasta
paasta_tools/paastaapi/api/default_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/default_api.py
Apache-2.0
def __show_version( self, **kwargs ): """Version of paasta_tools package # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.show_version(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: str If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs)
Version of paasta_tools package # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.show_version(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: str If the method is called asynchronously, returns the request thread.
__show_version
python
Yelp/paasta
paasta_tools/paastaapi/api/default_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/default_api.py
Apache-2.0
def __update_service_autoscaler_pause( self, inline_object, **kwargs ): """update_service_autoscaler_pause # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_service_autoscaler_pause(inline_object, async_req=True) >>> result = thread.get() Args: inline_object (InlineObject): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: None If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['inline_object'] = \ inline_object return self.call_with_http_info(**kwargs)
update_service_autoscaler_pause # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_service_autoscaler_pause(inline_object, async_req=True) >>> result = thread.get() Args: inline_object (InlineObject): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: None If the method is called asynchronously, returns the request thread.
__update_service_autoscaler_pause
python
Yelp/paasta
paasta_tools/paastaapi/api/default_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/default_api.py
Apache-2.0
def __remote_run_poll( self, service, instance, job_name, user, **kwargs ): """Check if remote run pod is ready # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_poll(service, instance, job_name, user, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name job_name (str): Job name user (str): User requesting job Keyword Args: toolbox (bool): Whether this is a toolbox job. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunOutcome If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['job_name'] = \ job_name kwargs['user'] = \ user return self.call_with_http_info(**kwargs)
Check if remote run pod is ready # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_poll(service, instance, job_name, user, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name job_name (str): Job name user (str): User requesting job Keyword Args: toolbox (bool): Whether this is a toolbox job. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunOutcome If the method is called asynchronously, returns the request thread.
__remote_run_poll
python
Yelp/paasta
paasta_tools/paastaapi/api/remote_run_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/remote_run_api.py
Apache-2.0
def __remote_run_start( self, service, instance, remote_run_start, **kwargs ): """Launch a remote-run pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_start(service, instance, remote_run_start, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name remote_run_start (RemoteRunStart): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunOutcome If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['remote_run_start'] = \ remote_run_start return self.call_with_http_info(**kwargs)
Launch a remote-run pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_start(service, instance, remote_run_start, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name remote_run_start (RemoteRunStart): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunOutcome If the method is called asynchronously, returns the request thread.
__remote_run_start
python
Yelp/paasta
paasta_tools/paastaapi/api/remote_run_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/remote_run_api.py
Apache-2.0
def __remote_run_stop( self, service, instance, remote_run_stop, **kwargs ): """Stop a remote-run pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_stop(service, instance, remote_run_stop, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name remote_run_stop (RemoteRunStop): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunOutcome If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['remote_run_stop'] = \ remote_run_stop return self.call_with_http_info(**kwargs)
Stop a remote-run pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_stop(service, instance, remote_run_stop, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name remote_run_stop (RemoteRunStop): Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunOutcome If the method is called asynchronously, returns the request thread.
__remote_run_stop
python
Yelp/paasta
paasta_tools/paastaapi/api/remote_run_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/remote_run_api.py
Apache-2.0
def __remote_run_token( self, service, instance, user, **kwargs ): """Get a short lived token for exec into remote-run pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_token(service, instance, user, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name user (str): User name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunToken If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['user'] = \ user return self.call_with_http_info(**kwargs)
Get a short lived token for exec into remote-run pod # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.remote_run_token(service, instance, user, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name user (str): User name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: RemoteRunToken If the method is called asynchronously, returns the request thread.
__remote_run_token
python
Yelp/paasta
paasta_tools/paastaapi/api/remote_run_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/remote_run_api.py
Apache-2.0
def __resources( self, **kwargs ): """Get resources in the cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.resources(async_req=True) >>> result = thread.get() Keyword Args: groupings ([str]): comma separated list of keys to group by. [optional] filter ([str]): List of slave filters in format &#39;filter&#x3D;attr_name:value1,value2&amp;filter&#x3D;attr2:value3,value4&#39;. Matches attr_name&#x3D;(value1 OR value2) AND attr2&#x3D;(value3 OR value4). [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: Resource If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs)
Get resources in the cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.resources(async_req=True) >>> result = thread.get() Keyword Args: groupings ([str]): comma separated list of keys to group by. [optional] filter ([str]): List of slave filters in format &#39;filter&#x3D;attr_name:value1,value2&amp;filter&#x3D;attr2:value3,value4&#39;. Matches attr_name&#x3D;(value1 OR value2) AND attr2&#x3D;(value3 OR value4). [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: Resource If the method is called asynchronously, returns the request thread.
__resources
python
Yelp/paasta
paasta_tools/paastaapi/api/resources_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/resources_api.py
Apache-2.0
def __bounce_status_instance( self, service, instance, **kwargs ): """Get bounce status of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.bounce_status_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InstanceBounceStatus If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get bounce status of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.bounce_status_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InstanceBounceStatus If the method is called asynchronously, returns the request thread.
__bounce_status_instance
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __delay_instance( self, service, instance, **kwargs ): """Get the possible reasons for a deployment delay for a marathon service.instance # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delay_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: {str: (bool, date, datetime, dict, float, int, list, str, none_type)} If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get the possible reasons for a deployment delay for a marathon service.instance # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delay_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: {str: (bool, date, datetime, dict, float, int, list, str, none_type)} If the method is called asynchronously, returns the request thread.
__delay_instance
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __get_flink_cluster_config( self, service, instance, **kwargs ): """Get config of a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_flink_cluster_config(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkConfig If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get config of a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_flink_cluster_config(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkConfig If the method is called asynchronously, returns the request thread.
__get_flink_cluster_config
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __get_flink_cluster_job_details( self, service, instance, job_id, **kwargs ): """Get details of a flink job in a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_flink_cluster_job_details(service, instance, job_id, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name job_id (str): Job id Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkJobDetails If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['job_id'] = \ job_id return self.call_with_http_info(**kwargs)
Get details of a flink job in a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_flink_cluster_job_details(service, instance, job_id, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name job_id (str): Job id Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkJobDetails If the method is called asynchronously, returns the request thread.
__get_flink_cluster_job_details
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __get_flink_cluster_overview( self, service, instance, **kwargs ): """Get overview of a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_flink_cluster_overview(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkClusterOverview If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get overview of a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_flink_cluster_overview(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkClusterOverview If the method is called asynchronously, returns the request thread.
__get_flink_cluster_overview
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __instance_set_state( self, service, instance, desired_state, **kwargs ): """Change state of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.instance_set_state(service, instance, desired_state, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name desired_state (str): Desired state Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: None If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['desired_state'] = \ desired_state return self.call_with_http_info(**kwargs)
Change state of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.instance_set_state(service, instance, desired_state, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name desired_state (str): Desired state Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: None If the method is called asynchronously, returns the request thread.
__instance_set_state
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __list_flink_cluster_jobs( self, service, instance, **kwargs ): """Get list of flink jobs in a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_flink_cluster_jobs(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkJobs If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get list of flink jobs in a flink cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_flink_cluster_jobs(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: FlinkJobs If the method is called asynchronously, returns the request thread.
__list_flink_cluster_jobs
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __list_instances( self, service, **kwargs ): """List instances of service_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_instances(service, async_req=True) >>> result = thread.get() Args: service (str): Service name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InlineResponse2001 If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service return self.call_with_http_info(**kwargs)
List instances of service_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_instances(service, async_req=True) >>> result = thread.get() Args: service (str): Service name Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InlineResponse2001 If the method is called asynchronously, returns the request thread.
__list_instances
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __list_services_for_cluster( self, **kwargs ): """List service names and service instance names on the current cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_services_for_cluster(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InlineResponse200 If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs)
List service names and service instance names on the current cluster # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_services_for_cluster(async_req=True) >>> result = thread.get() Keyword Args: _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InlineResponse200 If the method is called asynchronously, returns the request thread.
__list_services_for_cluster
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __status_instance( self, service, instance, **kwargs ): """Get status of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.status_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: verbose (int): Include verbose status information. [optional] include_envoy (bool): Include Envoy information. [optional] include_mesos (bool): Include Mesos information. [optional] new (bool): Use new version of paasta status for services. [optional] all_namespaces (bool): Search all namespaces for running copies. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InstanceStatus If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get status of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.status_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: verbose (int): Include verbose status information. [optional] include_envoy (bool): Include Envoy information. [optional] include_mesos (bool): Include Mesos information. [optional] new (bool): Use new version of paasta status for services. [optional] all_namespaces (bool): Search all namespaces for running copies. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InstanceStatus If the method is called asynchronously, returns the request thread.
__status_instance
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __task_instance( self, service, instance, task_id, **kwargs ): """Get mesos task of service_name.instance_name by task_id # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.task_instance(service, instance, task_id, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name task_id (str): mesos task id Keyword Args: verbose (bool): Return slave and executor for task. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: {str: (bool, date, datetime, dict, float, int, list, str, none_type)} If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance kwargs['task_id'] = \ task_id return self.call_with_http_info(**kwargs)
Get mesos task of service_name.instance_name by task_id # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.task_instance(service, instance, task_id, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name task_id (str): mesos task id Keyword Args: verbose (bool): Return slave and executor for task. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: {str: (bool, date, datetime, dict, float, int, list, str, none_type)} If the method is called asynchronously, returns the request thread.
__task_instance
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def __tasks_instance( self, service, instance, **kwargs ): """Get mesos tasks of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.tasks_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: slave_hostname (str): slave hostname to filter tasks by. [optional] verbose (bool): Return slave and executor for task. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InstanceTasks If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') kwargs['service'] = \ service kwargs['instance'] = \ instance return self.call_with_http_info(**kwargs)
Get mesos tasks of service_name.instance_name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.tasks_instance(service, instance, async_req=True) >>> result = thread.get() Args: service (str): Service name instance (str): Instance name Keyword Args: slave_hostname (str): slave hostname to filter tasks by. [optional] verbose (bool): Return slave and executor for task. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. async_req (bool): execute request asynchronously Returns: InstanceTasks If the method is called asynchronously, returns the request thread.
__tasks_instance
python
Yelp/paasta
paasta_tools/paastaapi/api/service_api.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/api/service_api.py
Apache-2.0
def openapi_types(): """ This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type. """ return { 'framework_id': (str,), # noqa: E501 'launch_time': (str,), # noqa: E501 'run_id': (str,), # noqa: E501 }
This must be a method because a model may have properties that are of type self, this must run after the class is loaded Returns openapi_types (dict): The key is attribute name and the value is attribute type.
openapi_types
python
Yelp/paasta
paasta_tools/paastaapi/model/adhoc_launch_history.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/paastaapi/model/adhoc_launch_history.py
Apache-2.0
def get_key_versions( self, key_name: str, ) -> List[CryptoKey]: """ Retrieve all versions of Vault key based on its metadata """ client = self.clients[self.ecosystems[0]] crypto_keys: List[CryptoKey] = [] try: meta_response = client.secrets.kv.read_secret_metadata( path=key_name, mount_point="keystore" ) for key_version in meta_response["data"]["versions"].keys(): key_response = client.secrets.kv.read_secret_version( path=key_name, version=key_version, mount_point="keystore" ) crypto_keys.append( { "key_name": key_name, "key_version": key_response["data"]["metadata"]["version"], "key": key_response["data"]["data"]["key"], } ) except hvac.exceptions.VaultError: log.warning( f"Could not fetch key versions for {key_name} on {self.ecosystems[0]}" ) pass return crypto_keys
Retrieve all versions of Vault key based on its metadata
get_key_versions
python
Yelp/paasta
paasta_tools/secret_providers/vault.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/secret_providers/vault.py
Apache-2.0
def update_namespace(self, namespace, new_config, skip_if_unchanged=True): """Updates the configuration for a namespace. :param namespace: str :param new_config: str, should be valid YAML. :param skip_if_unchanged: boolean. If False, will send the update even if the current config matches the new config. """ current_config = self._get("/api/config", {"name": namespace, "no_header": 1}) if skip_if_unchanged: if yaml.safe_load(new_config) == yaml.safe_load(current_config["config"]): log.debug("No change in config, skipping update.") return return self._post( "/api/config", data={ "name": namespace, "config": new_config, "hash": current_config["hash"], "check": 0, }, )
Updates the configuration for a namespace. :param namespace: str :param new_config: str, should be valid YAML. :param skip_if_unchanged: boolean. If False, will send the update even if the current config matches the new config.
update_namespace
python
Yelp/paasta
paasta_tools/tron/client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/client.py
Apache-2.0
def list_namespaces(self): """Gets the namespaces that are currently configured.""" response = self._get("/api") return response.get("namespaces", [])
Gets the namespaces that are currently configured.
list_namespaces
python
Yelp/paasta
paasta_tools/tron/client.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/client.py
Apache-2.0
def build_filled_context(*context_objects): """Create a CommandContext chain from context_objects, using a Filler object to pass to each CommandContext. Can be used to validate a format string. """ if not context_objects: return CommandContext() filler = Filler() def build(current, next): return CommandContext(next(filler), current) return functools.reduce(build, context_objects, None)
Create a CommandContext chain from context_objects, using a Filler object to pass to each CommandContext. Can be used to validate a format string.
build_filled_context
python
Yelp/paasta
paasta_tools/tron/tron_command_context.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_command_context.py
Apache-2.0
def __init__(self, base=None, next=None): """ base - Object to look for attributes in next - Next place to look for more pieces of context Generally this will be another instance of CommandContext """ self.base = base or {} self.next = next or {}
base - Object to look for attributes in next - Next place to look for more pieces of context Generally this will be another instance of CommandContext
__init__
python
Yelp/paasta
paasta_tools/tron/tron_command_context.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_command_context.py
Apache-2.0
def cleanup_job_status(self): """Provide 'SUCCESS' or 'FAILURE' to a cleanup action context based on the status of the other steps """ if self.job_run.action_runs.is_failed: return "FAILURE" elif self.job_run.action_runs.is_complete_without_cleanup: return "SUCCESS" return "UNKNOWN"
Provide 'SUCCESS' or 'FAILURE' to a cleanup action context based on the status of the other steps
cleanup_job_status
python
Yelp/paasta
paasta_tools/tron/tron_command_context.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_command_context.py
Apache-2.0
def __getitem__(self, name): """Attempt to parse date arithmetic syntax and apply to run_time.""" run_time = self.job_run.run_time time_value = tron_timeutils.DateArithmetic.parse(name, run_time) if time_value: return time_value raise KeyError(name)
Attempt to parse date arithmetic syntax and apply to run_time.
__getitem__
python
Yelp/paasta
paasta_tools/tron/tron_command_context.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_command_context.py
Apache-2.0
def delta_total_seconds(td): """Equivalent to timedelta.total_seconds() available in Python 2.7.""" microseconds, seconds, days = td.microseconds, td.seconds, td.days return (microseconds + (seconds + days * 24 * 3600) * 10**6) / 10**6
Equivalent to timedelta.total_seconds() available in Python 2.7.
delta_total_seconds
python
Yelp/paasta
paasta_tools/tron/tron_timeutils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_timeutils.py
Apache-2.0
def macro_timedelta(start_date, years=0, months=0, days=0, hours=0): """Since datetime doesn't provide timedeltas at the year or month level, this function generates timedeltas of the appropriate sizes. """ delta = datetime.timedelta(days=days, hours=hours) new_month = start_date.month + months while new_month > 12: new_month -= 12 years += 1 while new_month < 1: new_month += 12 years -= 1 end_date = datetime.datetime( start_date.year + years, new_month, start_date.day, start_date.hour ) delta += end_date - start_date return delta
Since datetime doesn't provide timedeltas at the year or month level, this function generates timedeltas of the appropriate sizes.
macro_timedelta
python
Yelp/paasta
paasta_tools/tron/tron_timeutils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_timeutils.py
Apache-2.0
def duration(start_time, end_time=None): """Get a timedelta between end_time and start_time, where end_time defaults to now(). """ if not start_time: return None last_time = end_time if end_time else current_time() return last_time - start_time
Get a timedelta between end_time and start_time, where end_time defaults to now().
duration
python
Yelp/paasta
paasta_tools/tron/tron_timeutils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_timeutils.py
Apache-2.0
def parse(cls, date_str, dt=None): """Parse a date arithmetic pattern (Ex: 'shortdate-1'). Supports date strings: shortdate, year, month, day, unixtime, daynumber. Supports subtraction and addition operations of integers. Time unit is based on date format (Ex: seconds for unixtime, days for day). """ dt = dt or current_time() match = cls.DATE_TYPE_PATTERN.match(date_str) if not match: return attr, value = match.groups() delta = int(value) if value else 0 if attr in ("shortdate", "year", "month", "day", "hour"): if delta: kwargs = {"days" if attr == "shortdate" else attr + "s": delta} dt += macro_timedelta(dt, **kwargs) return dt.strftime(cls.DATE_FORMATS[attr]) if attr == "unixtime": return int(to_timestamp(dt)) + delta if attr == "daynumber": return dt.toordinal() + delta
Parse a date arithmetic pattern (Ex: 'shortdate-1'). Supports date strings: shortdate, year, month, day, unixtime, daynumber. Supports subtraction and addition operations of integers. Time unit is based on date format (Ex: seconds for unixtime, days for day).
parse
python
Yelp/paasta
paasta_tools/tron/tron_timeutils.py
https://github.com/Yelp/paasta/blob/master/paasta_tools/tron/tron_timeutils.py
Apache-2.0
async def test_async_ttl_cache_dont_overwrite_new_cache_entry(): """Make sure that we don't overwrite a new cache entry that was placed while we were waiting to handle the result of a previously cached future """ range_continue_event = asyncio.Event() update_cache_event = asyncio.Event() return_values = iter(range(10)) # Wait until awaiter has had a chance to get the in-flight future out of # the cache, then signal to the cache_updater to replace the cached future # before returning. Because cache_updater is signalled first, it will # replace the previously cached future before async_ttl_cache decides # whether save the result of that future in the cache async def range_coroutine(): await range_continue_event.wait() update_cache_event.set() return next(return_values) range_coroutine_future = asyncio.ensure_future(range_coroutine()) cache_key = functools._make_key((), {}, typed=False) cache = {cache_key: (range_coroutine_future, float("Inf"))} cached_range_coroutine = async_ttl_cache(cache=cache, ttl=0)(range_coroutine) new_range_coroutine_future = asyncio.ensure_future(range_coroutine()) async def awaiter(): range_continue_event.set() await cached_range_coroutine() async def cache_updater(): await update_cache_event.wait() cache[cache_key] = (new_range_coroutine_future, float("Inf")) await asyncio.gather(awaiter(), cache_updater()) assert cache[cache_key] == (new_range_coroutine_future, float("Inf"))
Make sure that we don't overwrite a new cache entry that was placed while we were waiting to handle the result of a previously cached future
test_async_ttl_cache_dont_overwrite_new_cache_entry
python
Yelp/paasta
tests/test_async_utils.py
https://github.com/Yelp/paasta/blob/master/tests/test_async_utils.py
Apache-2.0
async def test_async_ttl_cache_recover_if_cache_entry_removed(): """Ensure we handle the case where we encounter an exception in the cached future but another coroutine awaiting the same future ran first and alraedy deleted the cache entry""" range_continue_event = asyncio.Event() num_awaiters_awaiting = DataHolder(value=0) class TestException(Exception): pass async def range_coroutine(): await range_continue_event.wait() raise TestException range_coroutine_future = asyncio.ensure_future(range_coroutine()) cache_key = functools._make_key((), {}, typed=False) cache = {cache_key: (range_coroutine_future, float("Inf"))} cached_range_coroutine = async_ttl_cache(cache=cache, ttl=0)(range_coroutine) async def awaiter(): num_awaiters_awaiting.value += 1 if num_awaiters_awaiting.value == 2: range_continue_event.set() try: await cached_range_coroutine() except TestException: pass # should not raise a KeyError! await asyncio.gather(awaiter(), awaiter())
Ensure we handle the case where we encounter an exception in the cached future but another coroutine awaiting the same future ran first and alraedy deleted the cache entry
test_async_ttl_cache_recover_if_cache_entry_removed
python
Yelp/paasta
tests/test_async_utils.py
https://github.com/Yelp/paasta/blob/master/tests/test_async_utils.py
Apache-2.0
async def test_async_ttl_cache_for_class_members_doesnt_leak_mem(): """Ensure that we aren't leaking memory""" x = 42 instance_caches = defaultdict(dict) class TestClass: @async_ttl_cache(ttl=None, cleanup_self=True, cache=instance_caches) async def f(self): return x o1 = TestClass() w1 = weakref.ref(o1) assert w1() is not None assert await o1.f() == x assert len(instance_caches) == 1 assert list(instance_caches.keys())[0]() == o1 del o1 assert len(instance_caches) == 0 assert w1() is None o2, o3, o4 = TestClass(), TestClass(), TestClass() assert await o2.f() == x assert await o3.f() == x assert await o4.f() == x assert len(instance_caches) == 3 del o2, o4 assert len(instance_caches) == 1 del o3 assert len(instance_caches) == 0
Ensure that we aren't leaking memory
test_async_ttl_cache_for_class_members_doesnt_leak_mem
python
Yelp/paasta
tests/test_async_utils.py
https://github.com/Yelp/paasta/blob/master/tests/test_async_utils.py
Apache-2.0
def test_brutal_bounce_no_existing_apps(self): """When marathon is unaware of a service, brutal bounce should try to create a marathon app.""" new_config = {"id": "foo.bar.12345"} happy_tasks = [] assert bounce_lib.brutal_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=[], ) == {"create_app": True, "tasks_to_drain": set()}
When marathon is unaware of a service, brutal bounce should try to create a marathon app.
test_brutal_bounce_no_existing_apps
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_brutal_bounce_done(self): """When marathon has the desired app, and there are no other copies of the service running, brutal bounce should neither start nor stop anything.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.brutal_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=[], ) == {"create_app": False, "tasks_to_drain": set()}
When marathon has the desired app, and there are no other copies of the service running, brutal bounce should neither start nor stop anything.
test_brutal_bounce_done
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_brutal_bounce_mid_bounce(self): """When marathon has the desired app, but there are other copies of the service running, brutal bounce should stop the old ones.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.brutal_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == { "create_app": False, "tasks_to_drain": set( old_app_live_happy_tasks + old_app_live_unhappy_tasks ), }
When marathon has the desired app, but there are other copies of the service running, brutal bounce should stop the old ones.
test_brutal_bounce_mid_bounce
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_brutal_bounce_old_but_no_new(self): """When marathon does not have the desired app, but there are other copies of the service running, brutal bounce should stop the old ones and start the new one.""" new_config = {"id": "foo.bar.12345", "instances": 5} old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.brutal_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=[], old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == { "create_app": True, "tasks_to_drain": set( old_app_live_happy_tasks + old_app_live_unhappy_tasks ), }
When marathon does not have the desired app, but there are other copies of the service running, brutal bounce should stop the old ones and start the new one.
test_brutal_bounce_old_but_no_new
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_upthendown_bounce_no_existing_apps(self): """When marathon is unaware of a service, upthendown bounce should try to create a marathon app.""" new_config = {"id": "foo.bar.12345"} happy_tasks = [] assert bounce_lib.upthendown_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=[], ) == {"create_app": True, "tasks_to_drain": set()}
When marathon is unaware of a service, upthendown bounce should try to create a marathon app.
test_upthendown_bounce_no_existing_apps
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_upthendown_bounce_old_but_no_new(self): """When marathon has the desired app, but there are other copies of the service running, upthendown bounce should start the new one. but not stop the old one yet.""" new_config = {"id": "foo.bar.12345", "instances": 5} old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.upthendown_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=[], old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": True, "tasks_to_drain": set()}
When marathon has the desired app, but there are other copies of the service running, upthendown bounce should start the new one. but not stop the old one yet.
test_upthendown_bounce_old_but_no_new
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_upthendown_bounce_mid_bounce(self): """When marathon has the desired app, and there are other copies of the service running, but the new app is not fully up, upthendown bounce should not stop the old ones.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(3)] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.upthendown_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": False, "tasks_to_drain": set()}
When marathon has the desired app, and there are other copies of the service running, but the new app is not fully up, upthendown bounce should not stop the old ones.
test_upthendown_bounce_mid_bounce
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_upthendown_bounce_cleanup(self): """When marathon has the desired app, and there are other copies of the service running, and the new app is fully up, upthendown bounce should stop the old ones.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.upthendown_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == { "create_app": False, "tasks_to_drain": set( old_app_live_happy_tasks + old_app_live_unhappy_tasks ), }
When marathon has the desired app, and there are other copies of the service running, and the new app is fully up, upthendown bounce should stop the old ones.
test_upthendown_bounce_cleanup
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_upthendown_bounce_done(self): """When marathon has the desired app, and there are no other copies of the service running, upthendown bounce should neither start nor stop anything.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [] assert bounce_lib.upthendown_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": False, "tasks_to_drain": set()}
When marathon has the desired app, and there are no other copies of the service running, upthendown bounce should neither start nor stop anything.
test_upthendown_bounce_done
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_no_existing_apps(self): """When marathon is unaware of a service, crossover bounce should try to create a marathon app.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [] assert bounce_lib.crossover_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": True, "tasks_to_drain": set()}
When marathon is unaware of a service, crossover bounce should try to create a marathon app.
test_crossover_bounce_no_existing_apps
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_old_but_no_new(self): """When marathon only has old apps for this service, crossover bounce should start the new one, but not kill any old tasks yet.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [] assert bounce_lib.crossover_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": True, "tasks_to_drain": set()}
When marathon only has old apps for this service, crossover bounce should start the new one, but not kill any old tasks yet.
test_crossover_bounce_old_but_no_new
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_old_app_is_happy_but_no_new_app_happy_tasks(self): """When marathon only has old apps for this service and margin_factor != 1, crossover bounce should start the new app and kill some old tasks.""" new_config = {"id": "foo.bar.12345", "instances": 100} happy_tasks = [] old_app_live_happy_tasks = [mock.Mock() for _ in range(100)] old_app_live_unhappy_tasks = [] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, margin_factor=0.95, ) assert actual["create_app"] is True assert len(actual["tasks_to_drain"]) == 5
When marathon only has old apps for this service and margin_factor != 1, crossover bounce should start the new app and kill some old tasks.
test_crossover_bounce_old_app_is_happy_but_no_new_app_happy_tasks
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_some_unhappy_old_some_happy_old_no_new(self): """When marathon only has old apps for this service, and some of them are unhappy (maybe they've been recently started), the crossover bounce should start a new app and prefer killing the unhappy tasks over the happy ones. """ new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": False, "tasks_to_drain": set(old_app_live_unhappy_tasks)}
When marathon only has old apps for this service, and some of them are unhappy (maybe they've been recently started), the crossover bounce should start a new app and prefer killing the unhappy tasks over the happy ones.
test_crossover_bounce_some_unhappy_old_some_happy_old_no_new
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_some_unhappy_old_no_happy_old_no_new_tasks_no_excess( self, ): """When marathon only has old apps for this service, and all of their tasks are unhappy, and there are no excess tasks, the crossover bounce should start a new app and not kill any old tasks. """ new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] assert bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": False, "tasks_to_drain": set()}
When marathon only has old apps for this service, and all of their tasks are unhappy, and there are no excess tasks, the crossover bounce should start a new app and not kill any old tasks.
test_crossover_bounce_some_unhappy_old_no_happy_old_no_new_tasks_no_excess
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_lots_of_unhappy_old_no_happy_old_no_new(self): """When marathon has a new app and multiple old apps, no new tasks are up, all old tasks are unhappy, and there are too many tasks running, the crossover bounce should kill some (but not all) of the old tasks. This represents a situation where """ new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(10)] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) assert actual["create_app"] is False assert len(actual["tasks_to_drain"]) == 5
When marathon has a new app and multiple old apps, no new tasks are up, all old tasks are unhappy, and there are too many tasks running, the crossover bounce should kill some (but not all) of the old tasks. This represents a situation where
test_crossover_bounce_lots_of_unhappy_old_no_happy_old_no_new
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_lots_of_unhappy_old_some_happy_old_new_app_exists_no_new_tasks( self, ): """When marathon has a new app and multiple old apps, no new tasks are up, one of the old apps is healthy and the other is not, only unhealthy tasks should get killed. """ new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) assert actual["create_app"] is False assert actual["tasks_to_drain"] == set(old_app_live_unhappy_tasks) # Since there are plenty of unhappy old tasks, we should not kill any new ones. assert len(actual["tasks_to_drain"] & set(old_app_live_happy_tasks)) == 0
When marathon has a new app and multiple old apps, no new tasks are up, one of the old apps is healthy and the other is not, only unhealthy tasks should get killed.
test_crossover_bounce_lots_of_unhappy_old_some_happy_old_new_app_exists_no_new_tasks
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_mid_bounce(self): """When marathon has the desired app, and there are other copies of the service running, but the new app is not fully up, crossover bounce should only stop a few of the old instances.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(3)] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) assert actual["create_app"] is False assert len(actual["tasks_to_drain"]) == 3
When marathon has the desired app, and there are other copies of the service running, but the new app is not fully up, crossover bounce should only stop a few of the old instances.
test_crossover_bounce_mid_bounce
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_mid_bounce_some_happy_old_some_unhappy_old(self): """When marathon has the desired app, and there are other copies of the service running, and some of those older tasks are unhappy, we should prefer killing the unhappy tasks.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(3)] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(1)] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) assert actual["create_app"] is False assert len(actual["tasks_to_drain"]) == 4 # There are fewer unhappy old tasks than excess tasks, so we should kill all unhappy old ones, plus a few # happy ones. assert set(old_app_live_unhappy_tasks).issubset(actual["tasks_to_drain"])
When marathon has the desired app, and there are other copies of the service running, and some of those older tasks are unhappy, we should prefer killing the unhappy tasks.
test_crossover_bounce_mid_bounce_some_happy_old_some_unhappy_old
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_mid_bounce_some_happy_old_lots_of_unhappy_old(self): """When marathon has the desired app, and there are other copies of the service running, and there are more unhappy old tasks than excess tasks, we should only kill unhappy tasks. """ new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(3)] old_app_live_happy_tasks = [mock.Mock() for _ in range(2)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) assert actual["create_app"] is False # There are as many unhappy old tasks as excess tasks, so all tasks that we kill should be old unhappy ones. assert len(actual["tasks_to_drain"]) == 5 assert actual["tasks_to_drain"] == set(old_app_live_unhappy_tasks)
When marathon has the desired app, and there are other copies of the service running, and there are more unhappy old tasks than excess tasks, we should only kill unhappy tasks.
test_crossover_bounce_mid_bounce_some_happy_old_lots_of_unhappy_old
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_mid_bounce_no_happy_old_lots_of_unhappy_old(self): """When marathon has the desired app, and there are other copies of the service running, but none of the old tasks are happy, and there are excess tasks, we should kill some (but not all) unhappy old tasks.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(3)] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(6)] actual = bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) assert actual["create_app"] is False assert len(actual["tasks_to_drain"]) == 4
When marathon has the desired app, and there are other copies of the service running, but none of the old tasks are happy, and there are excess tasks, we should kill some (but not all) unhappy old tasks.
test_crossover_bounce_mid_bounce_no_happy_old_lots_of_unhappy_old
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_crossover_bounce_done(self): """When marathon has the desired app, and there are no other copies of the service running, crossover bounce should neither start nor stop anything.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [] assert bounce_lib.crossover_bounce( new_config=new_config, new_app_running=True, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": False, "tasks_to_drain": set()}
When marathon has the desired app, and there are no other copies of the service running, crossover bounce should neither start nor stop anything.
test_crossover_bounce_done
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_downthenup_bounce_no_existing_apps(self): """When marathon is unaware of a service, downthenup bounce should try to create a marathon app.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [] old_app_live_unhappy_tasks = [] assert bounce_lib.downthenup_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == {"create_app": True, "tasks_to_drain": set()}
When marathon is unaware of a service, downthenup bounce should try to create a marathon app.
test_downthenup_bounce_no_existing_apps
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0
def test_downthenup_bounce_old_but_no_new(self): """When marathon has only old copies of the service, downthenup_bounce should kill them and not start a new one yet.""" new_config = {"id": "foo.bar.12345", "instances": 5} happy_tasks = [] old_app_live_happy_tasks = [mock.Mock() for _ in range(5)] old_app_live_unhappy_tasks = [mock.Mock() for _ in range(1)] assert bounce_lib.downthenup_bounce( new_config=new_config, new_app_running=False, happy_new_tasks=happy_tasks, old_non_draining_tasks=old_app_live_happy_tasks + old_app_live_unhappy_tasks, ) == { "create_app": False, "tasks_to_drain": set( old_app_live_happy_tasks + old_app_live_unhappy_tasks ), }
When marathon has only old copies of the service, downthenup_bounce should kill them and not start a new one yet.
test_downthenup_bounce_old_but_no_new
python
Yelp/paasta
tests/test_bounce_lib.py
https://github.com/Yelp/paasta/blob/master/tests/test_bounce_lib.py
Apache-2.0