syncano.connection¶
- class Connection(host=None, **kwargs)[source]¶
Bases: object
Base connection class.
Variables: - host – Syncano API host
- email – Your Syncano email address
- password – Your Syncano password
- api_key – Your Syncano Account Key or instance Api Key
- user_key – Your Syncano User Key
- instance_name – Your Syncano Instance Name
- logger – Python logger instance
- timeout – Default request timeout
- verify_ssl – Verify SSL certificate
- CONTENT_TYPE = 'application/json'¶
- ACCOUNT_SUFFIX = 'v1.1/account/'¶
- SOCIAL_AUTH_SUFFIX = 'v1.1/account/auth/{social_backend}/'¶
- USER_AUTH_SUFFIX = 'v1.1/instances/{name}/user/auth/'¶
- USER_INFO_SUFFIX = 'v1.1/instances/{name}/user/'¶
- REGISTER_SUFFIX = 'v1.1/account/register/'¶
- LOGIN_PARAMS = set(['password', 'email'])¶
- ALT_LOGIN_PARAMS = set(['api_key'])¶
- USER_LOGIN_PARAMS = set(['instance_name', 'username', 'password', 'api_key'])¶
- USER_ALT_LOGIN_PARAMS = set(['instance_name', 'user_key', 'api_key'])¶
- SOCIAL_LOGIN_PARAMS = set(['social_backend', 'token'])¶
- AUTH_SUFFIX = 'v1.1/account/auth'¶
- build_params(params)[source]¶
Parameters: params (dict) – Params which will be passed to request Return type: dict Returns: Request params
- build_url(path)[source]¶
Ensures proper format for provided path.
Parameters: path (string) – Request path Return type: string Returns: Request URL
- request(method_name, path, **kwargs)[source]¶
Simple wrapper around make_request() which will ensure that request is authenticated.
Parameters: - method_name (string) – HTTP request method e.g: GET
- path (string) – Request path or full URL
Return type: dict
Returns: JSON response
- make_request(method_name, path, **kwargs)[source]¶
Parameters: - method_name (string) – HTTP request method e.g: GET
- path (string) – Request path or full URL
Return type: dict
Returns: JSON response
Raises: - SyncanoValueError – if invalid request method was chosen
- SyncanoRequestError – if something went wrong during the request
- is_authenticated()[source]¶
Checks if current session is authenticated.
Return type: boolean Returns: Session authentication state