mgnipy.V2.mgnifier.describe module#
- class DescribeEmgapiModule(endpoint_module)[source]#
Bases:
objectA class to describe and interact with an endpoint module from the metagenomics API v2. This class provides methods to list supported parameters, validate keyword arguments, construct URLs, and retrieve endpoint documentation. It also includes functionality to determine if the endpoint is private or a list endpoint, and to calculate pagination details based on the number of items and page size.
- Parameters:
endpoint_module (ModuleType) – The endpoint module to describe.
- describe_endpoint(as_dict=False)[source]#
Provides a description of the endpoint from the openapi documentation i.e., https://www.ebi.ac.uk/metagenomics/api/v2/openapi.json
- property emgapi_resource: str | None #
Retrieves the name of the endpoint resource based on the endpoint module. E.g., if the endpoint module corresponds to the “studies” resource, this property would return “studies”.
- Returns:
The name of the endpoint resource, or None if the endpoint module is not set.
- Return type:
str or None
- get_num_pages(num_items, page_size=None)[source]#
Calculates the total number of pages based on the total count and default page size.
- property id_param_key: str #
Get the parameter name used to identify this resource.
- Returns:
The identifier parameter (e.g., “accession”, “biome_lineage”).
- Return type:
- page_param_iter(num_pages)[source]#
Generates a list of parameter dictionaries for each page based on the total number of pages.
- resolve_query_string(**kwargs)[source]#
Resolves the query string for the endpoint based on the current parameters.
- Parameters:
**kwargs – Keyword arguments to validate and include in the query string.
- Returns:
The resolved query string.
- Return type:
- sub_url(**kwargs)[source]#
Constructs the sub-URL for the endpoint based on the current parameters.
- Returns:
The constructed sub-URL, or None if the endpoint module is not set.
- Return type:
str or None
- url_path(**kwargs)[source]#
Constructs the full URL path for the endpoint based on the current parameters.
- Parameters:
**kwargs – Keyword arguments to validate and include in the URL construction.
- Returns:
The constructed URL path.
- Return type:
- validate_endpoint_kwargs(**kwargs)[source]#
Validates the provided keyword arguments against the supported parameters of the endpoint module.
- Parameters:
**kwargs – Keyword arguments to validate.
- Returns:
The validated keyword arguments.
- Return type:
dict of str to Any
- Raises:
ValueError – If any provided keyword argument is not supported by the endpoint module.