Core¶
The dyn.core module contains functionality that is core to the behavior
of the rest of the library. In particular this is where a lot of the “heavy lifting”
for sessions is done.
Singleton¶
SessionEngine¶
-
class
dyn.core.SessionEngine(host=None, port=443, ssl=True)[source]¶ Base object representing a DynectSession Session
-
__init__(host=None, port=443, ssl=True)[source]¶ Initialize a Dynect Rest Session object and store the provided credentials
Parameters: - host – DynECT API server address
- port – Port to connect to DynECT API server
- ssl – Enable SSL
Returns: SessionEngine object
-
classmethod
close_session()[source]¶ Remove the current session from the dict of instances and return it. If there was not currently a session being stored, return None. If, after removing this session, there is nothing under the current key, delete that key’s entry in the _instances dict.
-
connect()[source]¶ Establishes a connection to the REST API server as defined by the host, port and ssl instance variables
-
execute(uri, method, args=None, final=False)[source]¶ Execute a commands against the rest server
Parameters: - uri – The uri of the resource to access. /REST/ will be prepended if it is not at the beginning of the uri
- method – One of ‘DELETE’, ‘GET’, ‘POST’, or ‘PUT’
- args – Any arguments to be sent as a part of the request
- final – boolean flag representing whether or not we have already failed executing once or not
-
classmethod
get_session()[source]¶ Return the current session for this Session type or None if there is not an active session
-
name¶ A human readable version of the name of this object
-
poll_response(response, body)[source]¶ Looks at a response from a REST command, and while indicates that the job is incomplete, poll for response
Parameters: - response – the JSON response containing return codes
- body – the body of the HTTP response
-
send_command(uri, method, args)[source]¶ Responsible for packaging up the API request and sending it to the server over the established connection
Parameters: - uri – The uri of the resource to interact with
- method – The HTTP method to use
- args – Encoded arguments to send to the server
-
uri_root= '/'¶
-
wait_for_job_to_complete(job_id, timeout=120)[source]¶ When a response comes back with a status of “incomplete” we need to wait and poll for the status of that job until it comes back with success or failure
Parameters: - job_id – the id of the job to poll for a response from
- timeout – how long (in seconds) we should wait for a valid response before giving up on this request
-