pydent.aqsession.AqSession¶
-
class
pydent.aqsession.
AqSession
(login, password, aquarium_url, name=None, aqhttp=None)[source]¶ Bases:
pydent.sessionabc.SessionABC
Holds an AqHTTP with login information. Creates SessionInterfaces for models.
session1 = AqSession(username, password, aquarium_url) session1.User.find(1) # <User(id=1,...)>
Initializes a new trident Session.
- Parameters
login (str) – the Aquarium login for the user
password (str) – the password for the Aquarium login. This will not be stored anywhere. However, login headers for Aquarium will be stored in .__aqhttp. This may change in the future with changes authentication for the Aquarium API
aquarium_url (str) – the http formatted Aquarium url
name (str or None) – (optional) name for this session
-
__init__
(login, password, aquarium_url, name=None, aqhttp=None)[source]¶ Initializes a new trident Session.
- Parameters
login (str) – the Aquarium login for the user
password (str) – the password for the Aquarium login. This will not be stored anywhere. However, login headers for Aquarium will be stored in .__aqhttp. This may change in the future with changes authentication for the Aquarium API
aquarium_url (str) – the http formatted Aquarium url
name (str or None) – (optional) name for this session
Methods
__init__
(login, password, aquarium_url[, …])Initializes a new trident Session.
clear_cache
()copy
()init_cache
()Returns whether the user is logged in.
model_interface
(model_name[, interface_class])Returns model interface by name.
open
()Open Aquarium in a web browser window.
ping
([num])Performs a number of simple requests (pings) to estimate the speed of the server.
set_timeout
(timeout_in_seconds)Sets the request timeout.
set_verbose
(verbose[, tb_limit])with_cache
([using_requests, using_models, …])- type using_requests
Optional
[bool
]
with_requests_off
([using_cache, …])- rtype
Attributes
Account
AllowableFieldType
Budget
Code
Collection
DataAssociation
FieldType
FieldValue
Group
Invoice
Item
Job
JobAssociation
Library
Membership
ObjectType
Operation
OperationType
PartAssociation
Plan
PlanAssociation
Sample
SampleType
Upload
User
UserBudgetAssociation
Wire
browser
Returns the current User associated with this session.
Returns the session’s interface class.
Logs into aquarium, generating the necessary headers to perform requests to Aquarium.
Returns list of all models available.
Return self.
Returns the aquarium_url for this session.
using_cache
- rtype
bool
using_requests
- rtype
bool
Instantiates a utility interface.
-
_aqhttp
= None¶ requests interface
-
_browser
= None¶ the sessions browser
-
property
current_user
¶ Returns the current User associated with this session.
Returns None if no user is found (as in cases where the Aquarium connection is down).
- Return type
-
property
interface_class
¶ Returns the session’s interface class.
- Return type
Type
-
logged_in
()[source]¶ Returns whether the user is logged in. If the session is able to return the User model instance using the session’s login credentials, the user is considered to be logged in.
- Returns
whether user is currently logged in
- Return type
boolean
-
property
login
¶ Logs into aquarium, generating the necessary headers to perform requests to Aquarium.
- Return type
str
-
model_interface
(model_name, interface_class=None)[source]¶ Returns model interface by name.
- Return type
-
property
models
¶ Returns list of all models available.
- Return type
List
[str
]
-
ping
(num=5)[source]¶ Performs a number of simple requests (pings) to estimate the speed of the server.
Displays a message about the average time each ping took.
- Return type
Optional
[int
]
-
query
(data, use_cache=False)[source]¶ Perform a complex query a complex JSON query object.
Check out the JSON Schema page for more information.
You may also checkout AqSession.query_schema to view the JSON schema that validates the input.
{ "__model__": "Item", "__description__": "Get available primers in last 7 days", "query": { "object_type": { "query": { "sample_type": { "query": { "name": "Primer" } } } }, "created_at": { "__time__": { "__days__": -7 } }, "location": { "__not__": "deleted" } "__options__": { "limit": 1 } } }
- ..versionadded:: 0.1.5a16
Added query method for complex queries
Changed in version 0.1.5a23: query key now changed to __query__
- Parameters
data (
Dict
) – data queryuse_cache (
bool
) – whether to inherit the cache from the provided session (default: False)
- Return type
List
[ModelBase
]- Returns
list of models fitting the query
- Raises
AquariumQueryLanguageValidationError if input data is invalid.
-
property
url
¶ Returns the aquarium_url for this session.
-
property
utils
¶ Instantiates a utility interface.
-
with_cache
(using_requests=None, using_models=False, timeout=None, verbose=None)[source]¶ - Parameters
using_requests (
Optional
[bool
]) – if False, ForbiddenRequest will be raised if requests are made using the session.using_models (
bool
) – if True (default: False), derived session will inherit the current sessions model_cachetimeout (
Optional
[int
]) – the requests timeout in secondsverbose – if True, verbose mode will be activated for the derived session
- Return type
- Returns