10.6.2. Base class for all API item objects

class pytan3.api_models.ApiItem(**kwargs)[source]

Bases: pytan3.api_models.ApiModel

Model for a complex item in the API.

API_LIST_API_NAME = None

str – Name of API_LIST_CLS used in API calls.

API_LIST_CLS = None

ApiList – List class that holds this item class.

__init__(**kwargs)[source]

Constructor.

Parameters:**kwargs – Set and checked using ApiModel.api_attrs().
__len__()[source]

Return number of ApiModel.api_attrs() that are not None.

Returns:int
__str__()[source]

Show object info using ApiModel.api_attrs_str().

Returns:str
__repr__()[source]

Show object info using ApiModel.api_attrs_repr().

Returns:str
__setattr__(attr, value)[source]

Enforce type using ApiModel.api_coerce_value().

serialize(empty=False, list_attrs=False, exclude_attrs=None, only_attrs=None, wrap_name=True, wrap_item_attr=True)[source]

Serialize this object into a dict.

Parameters:
  • empty (bool, optional) –

    Include attrs that have a value of None when serializing.

    Defaults to: False.

  • list_attrs (bool, optional) –

    Include simple attrs of ApiList when serializing.

    Defaults to: False.

  • exclude_attrs (list of str, optional) –

    Exclude these attrs when serializing.

    Defaults to: None.

  • only_attrs (list of str, optional) –

    Include only these attrs when serializing.

    Defaults to: None.

  • wrap_name (bool, optional) –

    Wrap return in a dict with key of ApiModel.API_NAME and value of return.

    Defaults to: True.

  • wrap_item_attr (bool, optional) –

    Wrap return in a dict with key of ApiList.API_ITEM_ATTR and value of return.

    Only used when serializing items of type ApiList.

    Defaults to: True.

Notes

All child objects will get wrap_name=False.

Returns:dict