dl.resClient module¶
Client methods for the Data Lab Resource Management Service.
Resource Manager¶
createUser (username, password, email, name, institute)
getUser (token, username, keyword)
setUser (token, username, keyword, value)
deleteUser (token, username)
passwordReset (token, user, password)
sendPasswordLink (token, user)
listFields ()
createGroup (token, group)
getGroup (token, group, keyword)
setGroup (token, group, keyword, value)
deleteGroup (token, group)
createResource (token, resource)
getResource (token, resource, keyword)
setResource (token, resource, keyword, value)
deleteResource (token, resource)
createJob (token, jobid, job_type, query=None, task=None)
getJob (token, jobid, keyword)
setJob (token, jobid, keyword, value)
deleteJob (token, jobid)
findJobs (token, jobid, format='text', status='all',
option='list')
set_svc_url (svc_url)
get_svc_url ()
set_profile (profile)
get_profile ()
list_profiles (token, profile=None, format='text')
Import via
from dl import resClient
- dl.resClient.createGroup(token, group, profile='default')[source]¶
Create a new Group in the system.
- Parameters:
token (str) – User identity token
group (str) – Group name to create
- Returns:
resp – Service response
- Return type:
str
- dl.resClient.createResource(token, resource, profile='default')[source]¶
Create a new Resource in the system.
- Parameters:
token (str) – User identity token
resource (str) – Resource URI to create
- Returns:
resp – Service response
- Return type:
str
- dl.resClient.createUser(username, password, email, name, institute, profile='default')[source]¶
Create a new user in the system.
- Parameters:
username (str) – Account username
password (str) – Account password
email (str) – User’s contact email address
name (str) – User’s full name
institute (str) – User’s home institution
- Return type:
Service response
- dl.resClient.deleteGroup(token, group, profile='default')[source]¶
Delete a Group in the system.
- Parameters:
token (str) – User identity token.
group (str) – Name of Group to be deleted. The token must identify the owner of the Group to be deleted.
- dl.resClient.deleteResource(token, resource, profile='default')[source]¶
Delete a Resource in the system.
- Parameters:
token (str) – User identity token. The token must identify the owner of the Resource to be deleted.
resource (str) – Name of Resource to be deleted. The token must identify the owner of the Group to be deleted.
- dl.resClient.deleteUser(token, username, profile='default')[source]¶
Delete a user in the system.
- Parameters:
token (str) – User identity token.
username (str) – Name of user to be deleted.
- Return type:
Service response
- dl.resClient.getGroup(token, group, keyword, profile='default')[source]¶
Read info about a Group in the system.
- Parameters:
token (str) – User identity token
group (str) – Group name to create
keyword (str) – Group record field to retrieve
- Returns:
value – Value of record field
- Return type:
str
- dl.resClient.getResource(token, resource, keyword, profile='default')[source]¶
Read info about a Resource in the system.
- Parameters:
token (str) – User identity token
resource (str) – Resource URI to create
keyword (str) – Resource record to retrieve
- Returns:
value – Resource record value
- Return type:
str
- dl.resClient.getUser(token, username, keyword, profile='default')[source]¶
Read info about a user in the system.
- Parameters:
username (str) – User name
keyword (str) – User record field to be set
- Return type:
Nothing
Example
from dl import resClient resClient.client.set_svc_url("http://localhost:7001/")
- dl.resClient.get_profile()[source]¶
Get the requested service profile.
- Parameters:
None
- Returns:
profile – The currently requested service profile.
- Return type:
str
Example
from dl import resClient profile = resClient.client.get_profile()
- dl.resClient.get_svc_url()[source]¶
Return the currently-used Resource Management Service URL.
- Parameters:
None
- Returns:
service_url – The currently-used Resource Management Service URL.
- Return type:
str
Example
from dl import resClient service_url = resClient.client.get_svc_url()
- dl.resClient.listFields(profile='default')[source]¶
List available user fields.
- Parameters:
None
- Return type:
Service response
- dl.resClient.list_profiles(token, profile=None, format='text')[source]¶
List the service profiles which can be accessed by the user.
- Returns:
profiles
- Return type:
JSON string
Example
from dl import resClient profiles = resClient.client.list_profiles(token, profile, format)
- dl.resClient.passwordReset(token, user, password, profile='default')[source]¶
Change a user’s password.
- Parameters:
token (str) – User identity token
user (str) – User account name. Token must match the user or root token.
password (str) – New password
- Return type:
Nothing
Example
from dl import resClient resClient.client.set_svc_url("http://localhost:7001/")
- class dl.resClient.resClient[source]¶
Bases:
object
- RESCLIENT – Client-side methods to access the Data Lab
Resource Management Service.
- approveUser(token, user, profile='default')[source]¶
Approve a pending user request.
- Parameters:
token (str) – User identity token
user (str) – User account to approve. Token must have authority to manage users.
- Return type:
Service response
- clientRead(token, what, key, keyword, profile='default')[source]¶
Generic method to call a /get service.
- clientUpdate(token, what, key, keyword, value, profile='default')[source]¶
Generic method to call a /set service.
- createGroup(token, group, profile='default')[source]¶
Create a new Group in the system.
- Parameters:
token (str) – User identity token
group (str) – Group name to create
- Returns:
resp – Service response
- Return type:
str
- createJob(token, jobid, job_type, query=None, task=None, profile='default')[source]¶
Create a new Job record in the system.
- Parameters:
token (str) – User identity token
jobid (str) – Job ID to create
type (str) – Type of job: currently only ‘query’ or ‘compute’
query (str) – If ‘type’ is ‘query’, the SQL/ADQL query string
task (str) – If ‘type’ is ‘compute’, the name of the task being run
- Returns:
resp – Service response
- Return type:
str
- createResource(token, resource, profile='default')[source]¶
Create a new Resource in the system.
- Parameters:
token (str) – User identity token
resource (str) – Resource URI to create
- Returns:
resp – Service response
- Return type:
str
- createUser(username, password, email, name, institute, profile='default')[source]¶
Create a new user in the system.
- Parameters:
username (str) – Account username
password (str) – Account password
email (str) – User’s contact email address
name (str) – User’s full name
institute (str) – User’s home institution
- Return type:
Service response
- deleteGroup(token, group, profile='default')[source]¶
Delete a Group in the system.
- Parameters:
token (str) – User identity token.
group (str) – Name of Group to be deleted. The token must identify the owner of the Group to be deleted.
- deleteJob(token, jobid, profile='default')[source]¶
Delete a Job in the system.
- Parameters:
token (str) – User identity token. The token must identify the owner of the Job to be deleted.
jobid (str) – ID of Job to be deleted. The token must identify the owner of the Job to be deleted.
- deleteResource(token, resource, profile='default')[source]¶
Delete a Resource in the system.
- Parameters:
token (str) – User identity token. The token must identify the owner of the Resource to be deleted.
resource (str) – Name of Resource to be deleted. The token must identify the owner of the Group to be deleted.
- deleteUser(token, username, profile='default')[source]¶
Delete a user in the system.
- Parameters:
token (str) – User identity token.
username (str) – Name of user to be deleted.
- Return type:
Service response
- disapproveUser(token, user, profile='default')[source]¶
Disapprove a pending user request.
- Parameters:
token (str) – User identity token
user (str) – User account to decline. Token must have authority to manage users.
- Return type:
Service response
- findJobs(token, jobid, format='text', status='all', option='list')[source]¶
- Find job records. If jobid is None or ‘*’, all records for the user
identified by the token are returned, otherwise the specific job record is returned.
- Parameters:
token (str) – User identity token. The token must identify the owner of the Job to be deleted.
jobid (str) – Job ID to match.
format (str) – Output format: ‘text’ or ‘json’
status (str) – Job phase status to match. Default to ‘all’ but may be one of EXECUTING, COMPLETED, ERROR, ABORT or WAITING.
option (str) – Processing option: ‘list’ will return a listing of the matching records in the format specified by ‘format’; ‘delete’ will delete all matching records from the server except for EXECUTING jobs.
- Return type:
A JSON string of Job records matching the user or jobid.
- getGroup(token, group, keyword, profile='default')[source]¶
Read info about a Group in the system.
- Parameters:
token (str) – User identity token
group (str) – Group name to create
keyword (str) – Group record field to retrieve
- Returns:
value – Value of record field
- Return type:
str
- getJob(token, jobid, keyword, profile='default')[source]¶
Read info about a Job in the system.
- Parameters:
token (str) – User identity token
jobid (str) – Job ID to create
keyword (str) – Job record to retrieve
- Returns:
value – Job record value
- Return type:
str
- getResource(token, resource, keyword, profile='default')[source]¶
Read info about a Resource in the system.
- Parameters:
token (str) – User identity token
resource (str) – Resource URI to create
keyword (str) – Resource record to retrieve
- Returns:
value – Resource record value
- Return type:
str
- getUser(token, username, keyword, profile='default')[source]¶
Read info about a user in the system.
- Parameters:
username (str) – User name
keyword (str) – User record field to be set
- Return type:
Nothing
Example
from dl import resClient resClient.client.set_svc_url("http://localhost:7001/")
- get_profile()[source]¶
Get the requested service profile.
- Parameters:
None
- Returns:
profile – The currently requested service profile.
- Return type:
str
Example
from dl import resClient profile = resClient.client.get_profile()
- get_svc_url()[source]¶
Return the currently-used Resource Management Service URL.
- Parameters:
None
- Returns:
service_url – The currently-used Resource Management Service URL.
- Return type:
str
Example
from dl import resClient service_url = resClient.client.get_svc_url()
- isAlive(svc_url='https://datalab.noirlab.edu/res')[source]¶
- Check whether the ResManager service at the given URL is
alive and responding. This is a simple call to the root service URL or ping() method.
- Parameters:
svc_url (str) – Resource Management service base URL to call.
- Return type:
Nothing
Example
from dl import resClient resClient.client.set_svc_url("http://localhost:7001/")
- listFields(profile='default')[source]¶
List available user fields.
- Parameters:
None
- Return type:
Service response
- listPending(token, verbose=False, profile='default')[source]¶
List all pending user accounts.
- Parameters:
token (str) – User identity token
verbose (bool) – Return verbose listing?
- Return type:
List of use accounts pending approval
- list_profiles(token, profile=None, format='text')[source]¶
List the service profiles which can be accessed by the user.
- Returns:
profiles
- Return type:
JSON string
Example
from dl import resClient profiles = resClient.client.list_profiles(token, profile, format)
- passwordReset(token, user, password, profile='default')[source]¶
Change a user’s password.
- Parameters:
token (str) – User identity token
user (str) – User account name. Token must match the user or root token.
password (str) – New password
- Return type:
Nothing
Example
from dl import resClient resClient.client.set_svc_url("http://localhost:7001/")
- sendPasswordLink(token, user, profile='default')[source]¶
Send a password-reset link to the user.
- Parameters:
token (str) – User identity token
user (str) – User account name.
- Return type:
Service response
- setField(token, user, field, value, profile='default')[source]¶
Set a specific user record field
- Parameters:
token (str) – User identity token
user (str) – User name to modify. If None then identity is take from token, a root token is required to modify other users.
field (str) – Record field to be set
value (str) – Field value
- Return type:
‘OK’ is field was set, else a service error message.
- setGroup(token, group, keyword, value, profile='default')[source]¶
Update info about a Group in the system.
- Parameters:
token (str) – User identity token
group (str) – Group name to create
keyword (str) – Group record field to be set
value (str) – Value of field to set
- setJob(token, jobid, keyword, value, profile='default')[source]¶
Update info about a Job in the system.
- Parameters:
token (str) – User identity token
jobid (str) – Job ID to create
keyword (str) – Job record field to be set
value (str) – Value of field to set
- Returns:
status – ‘OK’ if record was set
- Return type:
str
- setResource(token, resource, keyword, value, profile='default')[source]¶
Update info about a Resource in the system.
- Parameters:
token (str) – User identity token
resource (str) – Resource URI to create
keyword (str) – Resource record field to be set
value (str) – Value of field to set
- Returns:
status – ‘OK’ if record was set
- Return type:
str
- setUser(token, username, keyword, value, profile='default')[source]¶
Update info about a user in the system.
- Parameters:
username (str) – User name
keyword (str) – User record field to be set
value (str) – Value of field to set
- Return type:
Service response
- set_profile(profile)[source]¶
Set the requested service profile.
- Parameters:
profile (str) – Requested service profile string.
- Return type:
Nothing
Example
from dl import resClient token = resClient.client.set_profile("dev")
- set_svc_url(svc_url)[source]¶
Set the URL of the Resource Management Service to be used.
- Parameters:
svc_url (str) – Resource Management service base URL to call.
- Return type:
Nothing
Example
from dl import resClient resClient.client.set_svc_url("http://localhost:7001/")
- svcGet(token, url)[source]¶
Utility method to call a Resource Manager service.
- Parameters:
token (str) – User identity token
url (str) – URL to call with HTTP/GET
- Return type:
Service response
- userRecord(token, user, value, fmt, profile='default')[source]¶
Get a value from the User record.
- Parameters:
token (str) – User identity token
user (str) – User account name to retrieve. Token must match the use name or be a root token to access other records
value (str) – Value to retrieve. The special ‘all’ value will return all fields accessible to the token.
format (str) – ‘text’ for a single value, or ‘json’ for a complete record
- Return type:
User record
- dl.resClient.sendPasswordLink(token, user, profile='default')[source]¶
Send a password-reset link to the user.
- Parameters:
token (str) – User identity token
user (str) – User account name.
- Return type:
Service response
- dl.resClient.setGroup(token, group, keyword, value, profile='default')[source]¶
Update info about a Group in the system.
- Parameters:
token (str) – User identity token
group (str) – Group name to create
keyword (str) – Group record field to be set
value (str) – Value of field to set
- dl.resClient.setResource(token, resource, keyword, value, profile='default')[source]¶
Update info about a Resource in the system.
- Parameters:
token (str) – User identity token
resource (str) – Resource URI to create
keyword (str) – Resource record field to be set
value (str) – Value of field to set
- Returns:
status – ‘OK’ if record was set
- Return type:
str
- dl.resClient.setUser(token, username, keyword, value, profile='default')[source]¶
Update info about a user in the system.
- Parameters:
username (str) – User name
keyword (str) – User record field to be set
value (str) – Value of field to set
- Return type:
Service response
- dl.resClient.set_profile(profile)[source]¶
Set the requested service profile.
- Parameters:
profile (str) – Requested service profile string.
- Return type:
Nothing
Example
from dl import resClient token = resClient.client.set_profile("dev")