nvd_api.low_api package

Subpackages

Submodules

nvd_api.low_api.api_client module

NVD API 2.0 Python API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: 0.1.0 Contact: 15080890+kannkyo@users.noreply.github.com Generated by: https://openapi-generator.tech

class nvd_api.low_api.api_client.ApiClient(configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1)[source]

Bases: object

Generic API client for OpenAPI client library builds.

OpenAPI generic API client. This client handles the client- server communication, and is invariant across implementations. Specifics of the methods and models for each application are generated from the OpenAPI templates.

NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually.

Parameters:
  • configuration – .Configuration object for this client

  • header_name – a header to pass when making calls to the API.

  • header_value – a header value to pass when making calls to the API.

  • cookie – a cookie to include in the header when making calls to the API

  • pool_threads – The number of threads to use for async requests to the API. More threads means more concurrent API requests.

call_api(resource_path: str, method: str, path_params: Dict[str, Any] | None = None, query_params: List[Tuple[str, Any]] | None = None, header_params: Dict[str, Any] | None = None, body: Any | None = None, post_params: List[Tuple[str, Any]] | None = None, files: Dict[str, List[IOBase]] | None = None, response_type: Tuple[Any] | None = None, auth_settings: List[str] | None = None, async_req: bool | None = None, _return_http_data_only: bool | None = None, collection_formats: Dict[str, str] | None = None, _preload_content: bool = True, _request_timeout: int | float | Tuple | None = None, _host: str | None = None, _check_type: bool | None = None, _request_auths: List[Dict[str, Any]] | None = None)[source]

Makes the HTTP request (synchronous) and returns deserialized data.

To make an async_req request, set the async_req parameter.

Parameters:
  • resource_path – Path to method endpoint.

  • method – Method to call.

  • path_params – Path parameters in the url.

  • query_params – Query parameters in the url.

  • header_params – Header parameters to be placed in the request header.

  • body – Request body.

  • dict (post_params) – Request post form parameters, for application/x-www-form-urlencoded, multipart/form-data.

  • list (auth_settings) – Auth Settings names for the request.

  • response_type – For the response, a tuple containing: valid classes a list containing valid classes (for list schemas) a dict containing a tuple of valid classes as the value Example values: (str,) (Pet,) (float, none_type) ([int, none_type],) ({str: (bool, str, int, float, date, datetime, str, none_type)},)

  • files (dict) – key -> field name, value -> a list of open file objects for multipart/form-data.

  • bool (async_req) – execute request asynchronously

  • _return_http_data_only (bool, optional) – response data without head status code and headers

  • collection_formats (dict, optional) – dict of collection formats for path, query, header, and post parameters.

  • _preload_content (bool, optional) – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _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.

  • _check_type (bool, optional) – boolean describing if the data back from the server should have its type checked.

  • _request_auths (list, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

Returns:

If async_req parameter is True, the request will be called asynchronously. The method will return the request thread. If parameter async_req is False or missing, then the method will return the response directly.

close()[source]
deserialize(response, response_type, _check_type)[source]

Deserializes response into an object.

Parameters:
  • response – RESTResponse object to be deserialized.

  • response_type – For the response, a tuple containing: valid classes a list containing valid classes (for list schemas) a dict containing a tuple of valid classes as the value Example values: (str,) (Pet,) (float, none_type) ([int, none_type],) ({str: (bool, str, int, float, date, datetime, str, none_type)},)

  • _check_type (bool) – boolean, whether to check the types of the data received from the server

Returns:

deserialized object.

files_parameters(files: Dict[str, List[IOBase]] | None = None)[source]

Builds form parameters.

Parameters:

files – None or a dict with key=param_name and value is a list of open file objects

Returns:

List of tuples of form parameters with file data

static get_file_data_and_close_file(file_instance: IOBase) bytes[source]
parameters_to_multipart(params, collection_types)[source]

Get parameters as list of tuples, formatting as json if value is collection_types

Parameters:
  • params – Parameters as list of two-tuples

  • collection_types (dict) – Parameter collection types

Returns:

Parameters as list of tuple or urllib3.fields.RequestField

parameters_to_tuples(params, collection_formats)[source]

Get parameters as list of tuples, formatting collections.

Parameters:
  • params – Parameters as dict or list of two-tuples

  • collection_formats (dict) – Parameter collection formats

Returns:

Parameters as list of tuples, collections formatted

property pool

Create thread pool on first request avoids instantiating unused threadpool for blocking clients.

request(method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)[source]

Makes the HTTP request using RESTClient.

classmethod sanitize_for_serialization(obj)[source]

Prepares data for transmission before it is sent with the rest client If obj is None, return None. If obj is str, int, long, float, bool, return directly. If obj is datetime.datetime, datetime.date

convert to string in iso8601 format.

If obj is list, sanitize each element in the list. If obj is dict, return the dict. If obj is OpenAPI model, return the properties dict. If obj is io.IOBase, return the bytes :param obj: The data to serialize. :return: The serialized form of data.

select_header_accept(accepts)[source]

Returns Accept based on an array of accepts provided.

Parameters:

accepts – List of headers.

Returns:

Accept (e.g. application/json).

select_header_content_type(content_types, method=None, body=None)[source]

Returns Content-Type based on an array of content_types provided.

Parameters:
  • content_types – List of content-types.

  • method – http method (e.g. POST, PATCH).

  • body – http body to send.

Returns:

Content-Type (e.g. application/json).

set_default_header(header_name, header_value)[source]
update_params_for_auth(headers, queries, auth_settings, resource_path, method, body, request_auths=None)[source]

Updates header and query params based on authentication setting.

Parameters:
  • headers – Header parameters dict to be updated.

  • queries – Query parameters tuple list to be updated.

  • auth_settings – Authentication setting identifiers list.

  • resource_path – A string representation of the HTTP request resource path.

  • method – A string representation of the HTTP request method.

  • body – A object representing the body of the HTTP request. The object type is the return value of _encoder.default().

  • request_auths – if set, the provided settings will override the token in the configuration.

property user_agent

User agent for this API client

class nvd_api.low_api.api_client.Endpoint(settings=None, params_map=None, root_map=None, headers_map=None, api_client=None, callable=None)[source]

Bases: object

call_with_http_info(**kwargs)[source]

nvd_api.low_api.configuration module

NVD API 2.0 Python API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: 0.1.0 Contact: 15080890+kannkyo@users.noreply.github.com Generated by: https://openapi-generator.tech

class nvd_api.low_api.configuration.Configuration(host=None, api_key=None, api_key_prefix=None, access_token=None, username=None, password=None, discard_unknown_keys=False, disabled_client_side_validations='', server_index=None, server_variables=None, server_operation_index=None, server_operation_variables=None, ssl_ca_cert=None)[source]

Bases: object

NOTE: This class is auto generated by OpenAPI Generator

Ref: https://openapi-generator.tech Do not edit the class manually.

param host:

Base url

param api_key:

Dict to store API key(s). Each entry in the dict specifies an API key. The dict key is the name of the security scheme in the OAS specification. The dict value is the API key secret.

param api_key_prefix:

Dict to store API prefix (e.g. Bearer) The dict key is the name of the security scheme in the OAS specification. The dict value is an API key prefix when generating the auth data.

param username:

Username for HTTP basic authentication

param password:

Password for HTTP basic authentication

param discard_unknown_keys:

Boolean value indicating whether to discard unknown properties. A server may send a response that includes additional properties that are not known by the client in the following scenarios: 1. The OpenAPI document is incomplete, i.e. it does not match the server

implementation.

  1. The client was generated using an older version of the OpenAPI document and the server has been upgraded since then.

If a schema in the OpenAPI document defines the additionalProperties attribute, then all undeclared properties received by the server are injected into the additional properties map. In that case, there are undeclared properties, and nothing to discard.

param disabled_client_side_validations (string):

Comma-separated list of JSON schema validation keywords to disable JSON schema structural validation rules. The following keywords may be specified: multipleOf, maximum, exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, maxItems, minItems. By default, the validation is performed for data generated locally by the client and data received from the server, independent of any validation performed by the server side. If the input data does not satisfy the JSON schema validation rules specified in the OpenAPI document, an exception is raised. If disabled_client_side_validations is set, structural validation is disabled. This can be useful to troubleshoot data validation problem, such as when the OpenAPI document validation rules do not match the actual API data received by the server.

param server_index:

Index to servers configuration.

param server_variables:

Mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

param server_operation_index:

Mapping from operation ID to an index to server configuration.

param server_operation_variables:

Mapping from operation ID to a mapping with string values to replace variables in templated server configuration. The validation of enums is performed for variables with defined enum values before.

param ssl_ca_cert:

str - the path to a file of concatenated CA certificates in PEM format

Example:

API Key Authentication Example. Given the following security scheme in the OpenAPI specification:

components:
securitySchemes:
cookieAuth: # name for the security scheme

type: apiKey in: cookie name: JSESSIONID # cookie name

You can programmatically set the cookie:

conf = nvd_api.Configuration(

api_key={‘cookieAuth’: ‘abc123’} api_key_prefix={‘cookieAuth’: ‘JSESSIONID’}

)

The following cookie will be added to the HTTP request:

Cookie: JSESSIONID abc123

assert_hostname

Set this to True/False to enable/disable SSL hostname verification.

auth_settings()[source]

Gets Auth Settings dict for api client.

Returns:

The Auth Settings information dict.

cert_file

client certificate file

connection_pool_maxsize

urllib3 connection pool’s maximum number of connections saved per pool. urllib3 uses 1 connection as default value, but this is not the best value when you are making a lot of possibly parallel requests to the same host, which is often the case here. cpu_count * 5 is used as default value to increase performance.

property debug

Debug switch

get_api_key_with_prefix(identifier, alias=None)[source]

Gets API key (with prefix if set).

Parameters:
  • identifier – The identifier of apiKey.

  • alias – The alternative identifier of apiKey.

Returns:

The token for api key authentication.

get_basic_auth_token()[source]

Gets HTTP basic authentication header (string).

Returns:

The token for basic HTTP authentication.

classmethod get_default_copy()[source]

Return new instance of configuration.

This method returns newly created, based on default constructor, object of Configuration class or returns a copy of default configuration passed by the set_default method.

Returns:

The configuration object.

get_host_from_settings(index, variables=None, servers=None)[source]

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_settings()[source]

Gets an array of host settings

Returns:

An array of host settings

property host

Return generated host.

key_file

client key file

logger

Logging Settings

property logger_file

Debug file location

logger_file_handler

Log file handler

property logger_format

Log format

logger_stream_handler

Log stream handler

no_proxy

bypass proxy for host in the no_proxy list.

password

Password for HTTP basic authentication

proxy

Proxy URL

proxy_headers

Proxy headers

refresh_api_key_hook

function hook to refresh API key if expired

retries

Adding retries to override urllib3 default value 3

safe_chars_for_path_param

Safe chars for path_param

server_operation_index

Default server index

server_operation_variables

Default server variables

classmethod set_default(default)[source]

Set default instance of configuration.

It stores default configuration, which can be returned by get_default_copy method.

Parameters:

default – object of Configuration

ssl_ca_cert

Set this to customize the certificate file to verify the peer.

temp_folder_path

Temp file folder for downloading files

to_debug_report()[source]

Gets the essential information for debugging.

Returns:

The report for debugging.

username

Username for HTTP basic authentication

verify_ssl

SSL/TLS verification Set this to false to skip verifying SSL certificate when calling API from https server.

nvd_api.low_api.exceptions module

NVD API 2.0 Python API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: 0.1.0 Contact: 15080890+kannkyo@users.noreply.github.com Generated by: https://openapi-generator.tech

exception nvd_api.low_api.exceptions.ApiAttributeError(msg, path_to_item=None)[source]

Bases: OpenApiException, AttributeError

exception nvd_api.low_api.exceptions.ApiException(status=None, reason=None, http_resp=None)[source]

Bases: OpenApiException

exception nvd_api.low_api.exceptions.ApiKeyError(msg, path_to_item=None)[source]

Bases: OpenApiException, KeyError

exception nvd_api.low_api.exceptions.ApiTypeError(msg, path_to_item=None, valid_classes=None, key_type=None)[source]

Bases: OpenApiException, TypeError

exception nvd_api.low_api.exceptions.ApiValueError(msg, path_to_item=None)[source]

Bases: OpenApiException, ValueError

exception nvd_api.low_api.exceptions.ForbiddenException(status=None, reason=None, http_resp=None)[source]

Bases: ApiException

exception nvd_api.low_api.exceptions.NotFoundException(status=None, reason=None, http_resp=None)[source]

Bases: ApiException

exception nvd_api.low_api.exceptions.OpenApiException[source]

Bases: Exception

The base exception class for all OpenAPIExceptions

exception nvd_api.low_api.exceptions.ServiceException(status=None, reason=None, http_resp=None)[source]

Bases: ApiException

exception nvd_api.low_api.exceptions.UnauthorizedException(status=None, reason=None, http_resp=None)[source]

Bases: ApiException

nvd_api.low_api.exceptions.render_path(path_to_item)[source]

Returns a string representation of a path

nvd_api.low_api.model_utils module

NVD API 2.0 Python API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: 0.1.0 Contact: 15080890+kannkyo@users.noreply.github.com Generated by: https://openapi-generator.tech

class nvd_api.low_api.model_utils.ModelComposed(*args, **kwargs)[source]

Bases: OpenApiModel

the parent class of models whose type == object in their swagger/openapi and have oneOf/allOf/anyOf

When one sets a property we use var_name_to_model_instances to store the value in the correct class instances + run any type checking + validation code. When one gets a property we use var_name_to_model_instances to get the value from the correct class instances. This allows multiple composed schemas to contain the same property with additive constraints on the value.

_composed_schemas (dict) stores the anyOf/allOf/oneOf classes key (str): allOf/oneOf/anyOf value (list): the classes in the XOf definition.

Note: none_type can be included when the openapi document version >= 3.1.0

_composed_instances (list): stores a list of instances of the composed schemas defined in _composed_schemas. When properties are accessed in the self instance, they are returned from the self._data_store or the data stores in the instances in self._composed_schemas _var_name_to_model_instances (dict): maps between a variable name on self and the composed instances (self included) which contain that data key (str): property name value (list): list of class instances, self or instances in _composed_instances which contain the value that the key is referring to.

get(name, default=None)[source]

returns the value of an attribute or some default value if the attribute was not set

to_dict()[source]

Returns the model properties as a dict

to_str()[source]

Returns the string representation of the model

class nvd_api.low_api.model_utils.ModelNormal(*args, **kwargs)[source]

Bases: OpenApiModel

the parent class of models whose type == object in their swagger/openapi

get(name, default=None)[source]

returns the value of an attribute or some default value if the attribute was not set

to_dict()[source]

Returns the model properties as a dict

to_str()[source]

Returns the string representation of the model

class nvd_api.low_api.model_utils.ModelSimple(*args, **kwargs)[source]

Bases: OpenApiModel

the parent class of models whose type != object in their swagger/openapi

get(name, default=None)[source]

returns the value of an attribute or some default value if the attribute was not set

to_str()[source]

Returns the string representation of the model

class nvd_api.low_api.model_utils.OpenApiModel(*args, **kwargs)[source]

Bases: object

The base class for all OpenAPIModels

set_attribute(name, value)[source]
nvd_api.low_api.model_utils.allows_single_value_input(cls)[source]

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

nvd_api.low_api.model_utils.attempt_convert_item(input_value, valid_classes, path_to_item, configuration, spec_property_naming, key_type=False, must_convert=False, check_type=True)[source]
Parameters:
  • 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:
class nvd_api.low_api.model_utils.cached_property(fn)[source]

Bases: object

result_key = '_results'
nvd_api.low_api.model_utils.change_keys_js_to_python(input_dict, model_class)[source]

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).

nvd_api.low_api.model_utils.check_allowed_values(allowed_values, input_variable_path, input_values)[source]

Raises an exception if the input_values are not allowed

Parameters:
  • 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

nvd_api.low_api.model_utils.check_validations(validations, input_variable_path, input_values, configuration=None)[source]

Raises an exception if the input_values are invalid

Parameters:
  • 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.

nvd_api.low_api.model_utils.composed_model_input_classes(cls)[source]

This function returns a list of the possible models that can be accepted as inputs. TODO: lru_cache this

nvd_api.low_api.model_utils.convert_js_args_to_python_args(fn)[source]
nvd_api.low_api.model_utils.deserialize_file(response_data, configuration, content_disposition=None)[source]

Deserializes body to file

Saves response body into a file in a temporary folder, using the filename from the Content-Disposition header if provided.

Parameters:
  • response_data (param) – the file data to write

  • configuration (Configuration) – the instance to use to convert files

Keyword Arguments:

content_disposition (str) – the value of the Content-Disposition header

Returns:

the deserialized file which is open

The user is responsible for closing and reading the file

Return type:

(file_type)

nvd_api.low_api.model_utils.deserialize_model(model_data, model_class, path_to_item, check_type, configuration, spec_property_naming)[source]

Deserializes model_data to model instance.

Parameters:
  • 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

Raises:
nvd_api.low_api.model_utils.deserialize_primitive(data, klass, path_to_item)[source]

Deserializes string to primitive type.

Parameters:
  • data – str/int/float

  • klass – str/class the class to convert to

Returns:

int, float, str, bool, date, datetime

nvd_api.low_api.model_utils.get_allof_instances(self, model_args, constant_args)[source]
Parameters:
  • self – the class we are handling

  • model_args (dict) – var_name to var_value used to make instances

  • constant_args (dict) – metadata arguments: _check_type _path_to_item _spec_property_naming _configuration _visited_composed_classes

Returns

composed_instances (list)

nvd_api.low_api.model_utils.get_anyof_instances(self, model_args, constant_args)[source]
Parameters:
  • 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)

nvd_api.low_api.model_utils.get_discarded_args(self, composed_instances, model_args)[source]

Gathers the args that were discarded by configuration.discard_unknown_keys

nvd_api.low_api.model_utils.get_discriminated_classes(cls)[source]

Returns all the classes that a discriminator converts to TODO: lru_cache this

nvd_api.low_api.model_utils.get_discriminator_class(model_class, discr_name, discr_value, cls_visited)[source]

Returns the child class specified by the discriminator.

Parameters:
  • 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:

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.

Return type:

used_model_class (class/None)

nvd_api.low_api.model_utils.get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None)[source]

Find the oneOf schema that matches the input data (e.g. payload). If exactly one schema matches the input data, an instance of that schema is returned. If zero or more than one schema match the input data, an exception is raised. In OAS 3.x, the payload MUST, by validation, match exactly one of the schemas described by oneOf.

Parameters:
  • cls – the class we are handling

  • model_kwargs (dict) – var_name to var_value The input data, e.g. the payload that must match a oneOf schema in the OpenAPI document.

  • constant_kwargs (dict) – var_name to var_value args that every model requires, including configuration, server and path to item.

Kwargs:
model_arg: (int, float, bool, str, date, datetime, ModelSimple, None):

the value to assign to a primitive class or ModelSimple class Notes: - this is only passed in when oneOf includes types which are not object - None is used to suppress handling of model_arg, nullable models are handled in __new__

Returns

oneof_instance (instance)

nvd_api.low_api.model_utils.get_possible_classes(cls, from_server_context)[source]
nvd_api.low_api.model_utils.get_required_type_classes(required_types_mixed, spec_property_naming)[source]

Converts the tuple required_types into a tuple and a dict described below

Parameters:
  • 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 (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

Return type:

(valid_classes, dict_valid_class_to_child_types_mixed)

nvd_api.low_api.model_utils.get_simple_class(input_value)[source]

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

Parameters:

input_value (class/class_instance) – the item for which we will return the simple class

nvd_api.low_api.model_utils.get_type_error(var_value, path_to_item, valid_classes, key_type=False)[source]
nvd_api.low_api.model_utils.get_valid_classes_phrase(input_classes)[source]

Returns a string phrase describing what types are allowed

nvd_api.low_api.model_utils.is_json_validation_enabled(schema_keyword, configuration=None)[source]

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.

Parameters:
  • schema_keyword (string) – the name of a JSON schema validation keyword.

  • configuration (Configuration) – the configuration class.

nvd_api.low_api.model_utils.is_type_nullable(input_type)[source]

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.

Parameters:

input_type (type) – the class of the input_value that we are checking

Returns:

bool

nvd_api.low_api.model_utils.is_valid_type(input_class_simple, valid_classes)[source]
Parameters:
  • 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

nvd_api.low_api.model_utils.model_to_dict(model_instance, serialize=True)[source]

Returns the model properties as a dict

Parameters:

model_instance (one of your model instances) – the model instance that will be converted to a dict.

Keyword Arguments:

serialize (bool) – if True, the keys in the dict will be values from attribute_map

nvd_api.low_api.model_utils.order_response_types(required_types)[source]

Returns the required types sorted in coercion order

Parameters:

required_types (list/tuple) – collection of classes or instance of list or dict with class information inside it.

Returns:

coercion order sorted collection of classes or instance

of list or dict with class information inside it.

Return type:

(list)

nvd_api.low_api.model_utils.remove_uncoercible(required_types_classes, current_item, spec_property_naming, must_convert=True)[source]

Only keeps the type conversions that are possible

Parameters:
  • required_types_classes (tuple) – tuple of classes that are required these should be ordered by COERCION_INDEX_BY_TYPE

  • 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.

  • current_item (any) – the current item (input data) to be converted

Keyword Arguments:

must_convert (bool) – if True the item to convert is of the wrong type and we want a big list of coercibles if False, we want a limited list of coercibles

Returns:

the remaining coercible required types, classes only

Return type:

(list)

nvd_api.low_api.model_utils.type_error_message(var_value=None, var_name=None, valid_classes=None, key_type=None)[source]
Keyword Arguments:
  • 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

nvd_api.low_api.model_utils.validate_and_convert_types(input_value, required_types_mixed, path_to_item, spec_property_naming, _check_type, configuration=None)[source]

Raises a TypeError is there is a problem, otherwise returns value

Parameters:
  • 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

nvd_api.low_api.model_utils.validate_get_composed_info(constant_args, model_args, self)[source]

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

Parameters:
  • 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:

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

Return type:

composed_info (list)

nvd_api.low_api.rest module

NVD API 2.0 Python API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: 0.1.0 Contact: 15080890+kannkyo@users.noreply.github.com Generated by: https://openapi-generator.tech

class nvd_api.low_api.rest.RESTClientObject(configuration, pools_size=4, maxsize=None)[source]

Bases: object

DELETE(url, headers=None, query_params=None, body=None, _preload_content=True, _request_timeout=None)[source]
GET(url, headers=None, query_params=None, _preload_content=True, _request_timeout=None)[source]
HEAD(url, headers=None, query_params=None, _preload_content=True, _request_timeout=None)[source]
OPTIONS(url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)[source]
PATCH(url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)[source]
POST(url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)[source]
PUT(url, headers=None, query_params=None, post_params=None, body=None, _preload_content=True, _request_timeout=None)[source]
request(method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None)[source]

Perform requests.

Parameters:
  • method – http request method

  • url – http request url

  • query_params – query parameters in the url

  • headers – http request headers

  • body – request json body, for application/json

  • post_params – request post parameters, application/x-www-form-urlencoded and multipart/form-data

  • _preload_content – if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True.

  • _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.

class nvd_api.low_api.rest.RESTResponse(resp)[source]

Bases: IOBase

getheader(name, default=None)[source]

Returns a given response header.

getheaders()[source]

Returns a dictionary of the response headers.

nvd_api.low_api.rest.in_ipv4net(target, net)[source]

Test if target belongs to given IPv4 network

nvd_api.low_api.rest.is_ipv4(target)[source]

Test if IPv4 address or not

nvd_api.low_api.rest.should_bypass_proxies(url, no_proxy=None)[source]

Yet another requests.should_bypass_proxies Test if proxies should not be used for a particular url.

Module contents

NVD API 2.0 Python API

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

The version of the OpenAPI document: 0.1.0 Contact: 15080890+kannkyo@users.noreply.github.com Generated by: https://openapi-generator.tech