phpypam.core package¶
Submodules¶
phpypam.core.api module¶
-
class
phpypam.core.api.
Api
(url, app_id, username=None, password=None, token=None, encryption=False, timeout=None, ssl_verify=True, user_agent=None)[source]¶ Bases:
object
The main class. It generates tha API object where you can run different actions again to create, update and delete entities. It also provides functions with informational character only.
-
controllers
()[source]¶ This method is used to report all known controllers of phpIPAM API. Unfortunately the API doesn’t report all nor the correct paths for all ‘controllers’.
- Returns
Returns a tuple of controller paths.
- Return type
tuple
-
create_entity
(controller, controller_path=None, data=None, params=None)[source]¶ Create an entity
- Parameters
controller (str) – Name of the controller to use.
controller_path (str, optional) – The path which is used to query for entities, defaults to None
data (dict) – Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request
.params (dict, optional) – Dictionary list of tuples or bytes to send in the query string for the
Request
., defaults to None
- Returns
Returns the newly created entity.
- Return type
Union[dict, list]
-
delete_entity
(controller, controller_path, params=None)[source]¶ This method is used to delete an entity.
- Parameters
controller (str) – Name of the controller to use.
controller_path (str) – The path wich is used to access the entity to delete.
params (dict, optional) – Dictionary, list of tuples or bytes to send in the query string for the
Request
., defaults to None
- Returns
Returns True if entity was deleted successfully or either ‘dict’ or ‘list’ of entities to work on.
- Return type
Union[book, dict, list]
-
get_entity
(controller, controller_path=None, params=None)[source]¶ Method to get an existing entity
- Parameters
controller (str) – Name of the controller to request entity from.
controller_path (str, optional) – The path which is used to query for entities, defaults to None
params (dict, optional) – Request parameters which have to be append to the request URI, defaults to None
- Returns
Result of the query. It can be either a ‘list’ or ‘dict’.
- Return type
Union[dict, list]
-
get_token
()[source]¶ Method to grap last login token
- Returns
Returns the api token from the last successful login.
- Return type
str
-
update_entity
(controller, controller_path=None, data=None, params=None)[source]¶ This method is used to update an entity.
- Parameters
controller (str) – Name of the controller to use.
controller_path (str, optional) – The path which is used to access the entity to update., defaults to None
data (dict, optional) – Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request
., defaults to Noneparams (dict, optional) – Dictionary list of tuples or bytes to send in the query string for the
Request
., defaults to None
- Returns
Returns either a ‘dict’ or ‘list’ of the changed entity
- Return type
Union[dict, list]
-
phpypam.core.exceptions module¶
-
exception
phpypam.core.exceptions.
PHPyPAMEntityNotFoundException
(*args, **kwargs)[source]¶ Bases:
Exception
Exception PHPyPAMEntityNotFoundException, children of
Exception
. This Exception is raised if an entity was not found.
-
exception
phpypam.core.exceptions.
PHPyPAMException
(*args, code=None, message=None)[source]¶ Bases:
Exception
PHPyPAMExeption, children of
Exception
. This exception is raised if anythings inphpypam.api
doesn’t work out.