10.5.1. Container for API Object Modules

class pytan3.api_objects.ApiObjects(module_file, adhoc_warn=True)[source]

Bases: object

Encapsulation object for an API Object module.

__init__(module_file, adhoc_warn=True)[source]

Constructor.

Parameters:
  • module_file (str) – API Object module file name in import string format.
  • adhoc_warn (bool, optional) –

    Enable warnings about adhoc added simple attributes to API Objects.

    Defaults to: True.

_module = None

pytan3.api_objects – Imported API Objects module.

_models = None

pytan3.api_models – API Models module.

__str__()[source]

Show object info.

Returns:str
__repr__()[source]

Show object info.

Returns:str
control_adhoc_warnings(enable=False)[source]

Enable or disable warnings about adhoc added simple attributes.

Parameters:enable (bool, optional) –

Enable warnings.

Defaults to: True.

ApiModel

Get the ApiModel.

Returns:pytan3.api_models.ApiModel
ApiItem

Get the ApiItem.

Returns:pytan3.api_models.ApiItem
ApiList

Get the ApiList.

Returns:pytan3.api_models.ApiList
module

Get the API objects module.

Returns:object
module_type

Get the API type.

Returns:str
module_version

Get the API version.

Returns:str
module_dt

Get the date time format string.

Returns:str
module_dt_format(dt)[source]

Format a datetime string using module_dt.

Parameters:dt (str) – String to format.
Returns:datetime.datetime
module_version_dict

Get the API version.

Returns:dict
cls_item

Get all of the ApiItem classes.

Returns:list of pytan3.api_models.ApiItem
cls_list

Get all of the ApiItem classes.

Returns:list of pytan3.api_models.ApiList
cls_all

Get all of the ApiItem and ApiList classes.

Returns:list of pytan3.api_models.ApiModel
cls_name_map_item

Get a map of API key name to class for all ApiItem classes.

Returns:dict
cls_name_map_list

Get a map of API key name to class for all ApiList classes.

Returns:dict
cls_name_map_all

Get a map of API key name to class for all ApiItem and ApiList classes.

Returns:dict
cls_item_by_name(name)[source]

Get an ApiItem class by API name.

Parameters:name (str) – Name of object used in API calls.
Returns:pytan3.api_models.ApiItem
cls_list_by_name(name)[source]

Get an ApiList class by API name.

Parameters:name (str) – Name of object used in API calls.
Returns:pytan3.api_models.ApiList
cls_by_name(name)[source]

Get an ApiItem or ApiList by API name.

Parameters:name (str) – Name of object used in API calls.
Returns:pytan3.api_models.ApiModel
classmethod load(api_type='soap', veq='', vmax='', vmin='', vshrink=True)[source]

Import an API module for version and type.

Parameters:
  • api_type (str, optional) –

    Type of object module to load, must be one of API_TYPES.

    Defaults to: DEFAULT_TYPE.

  • veq (str, optional) –

    Exact version that API object module file must match.

    Defaults to: “”.

  • vmin (str, optional) –

    Minimum version that API object module file must match.

    Defaults to: “”.

  • vmax (str, optional) –

    Maximum version that API object module file must match.

    Defaults to: “”.

  • vshrink (bool or int, optional) –

    If True, shrink API object module file version down to match the same length as veq, vmax, and vmin.

    If False, do not shrink API object module file version at all.

    If int, shrink API object module file version, veq, vmax, and vmin down to this length.

    Defaults to: True.

Raises:

exceptions.ModuleError – If api_type not in API_TYPES.

Returns:

ApiObjects