Module: ncbi.datasets.openapi.api_client

NCBI Datasets API

Module: ncbi.datasets.openapi.api_client

NCBI Datasets API

### NCBI Datasets is a resource that lets you easily gather data from NCBI. The Datasets API is still in alpha, and we’re updating it often to add new functionality, iron out bugs and enhance usability. For some larger downloads, you may want to download a [dehydrated bag](https://0-www-ncbi-nlm-nih-gov.brum.beds.ac.uk/datasets/docs/rehydrate/), and retrieve the individual data files at a later time. # noqa: E501

The version of the OpenAPI document: v1 Generated by: https://openapi-generator.tech

class ncbi.datasets.openapi.api_client.ApiClient(configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1)

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.

close()
property pool

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

property user_agent

User agent for this API client

set_default_header(header_name, header_value)
parameters_to_multipart(params, collection_types)

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

classmethod sanitize_for_serialization(obj)

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.

deserialize(response, response_type, _check_type)

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.

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

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.

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.

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

Makes the HTTP request using RESTClient.

parameters_to_tuples(params, collection_formats)

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

static get_file_data_and_close_file(file_instance: io.IOBase) bytes
files_parameters(files: Optional[Dict[str, List[io.IOBase]]] = None)

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

select_header_accept(accepts)

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)

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

Parameters

content_types – List of content-types.

Returns

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

update_params_for_auth(headers, queries, auth_settings, resource_path, method, body)

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

class ncbi.datasets.openapi.api_client.Endpoint(settings=None, params_map=None, root_map=None, headers_map=None, api_client=None, callable=None)

Bases: object

call_with_http_info(**kwargs)
Generated October 22, 2021