Users¶
NomadUser
¶
Represents a user in the NOMAD system.
This class defines the structure for storing user information as retrieved from the NOMAD system. It includes both mandatory and optional fields, with some fields being hidden from the representation for privacy or security reasons.
Attributes:
Name | Type | Description |
---|---|---|
user_id |
str
|
A unique identifier for the user, not shown in the representation. |
name |
str
|
The full name of the user. |
first_name |
str
|
The user's first name, not shown in the representation. |
last_name |
str
|
The user's last name, not shown in the representation. |
username |
str
|
The user's username, not shown in the representation. |
affiliation |
str
|
The user's affiliated institution or organization, not shown in the representation. |
affiliation_address |
str
|
The address of the affiliated institution or organization, not shown in the representation. |
email |
Optional[str]
|
The user's email address, optional and not shown in the representation. |
is_oasis_admin |
Optional[bool]
|
Flag indicating if the user is an OASIS admin, optional and not shown in the representation. |
is_admin |
Optional[bool]
|
Flag indicating if the user is an admin, optional and not shown in the representation. |
repo_user_id |
Optional[str]
|
A repository-specific user identifier, optional and not shown in the representation. |
created |
Optional[datetime]
|
The date and time when the user was created, optional and not shown in the representation. |
Source code in martignac/nomad/users.py
get_user_by_id(user_id, use_prod=True, timeout_in_sec=10)
¶
Retrieves a user's information from the NOMAD system by their unique user ID.
This function makes a request to the NOMAD system to fetch the details of a user specified by their unique identifier. It allows the choice between querying the production or test environment of the NOMAD system. The function also supports specifying a timeout for the request. The results are cached to optimize performance and reduce the load on the NOMAD system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id |
str
|
The unique identifier of the user to retrieve. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to True. |
True
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
NomadUser |
NomadUser
|
An instance of |
Note
The function is decorated with @ttl_cache
to cache the results for 180 seconds and limit the cache size to 128 entries.
Source code in martignac/nomad/users.py
search_users_by_name(user_name, use_prod=True, timeout_in_sec=10)
¶
Searches for users in the NOMAD system by name.
This function queries the NOMAD system for users whose names match the provided prefix. It leverages caching to reduce the number of requests made for the same query. The search can be directed to either the production or test environment of the NOMAD system. A timeout can be specified to limit the duration of the request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_name |
str
|
The prefix of the user name to search for. |
required |
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to True. |
True
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
NomadUser |
NomadUser
|
An instance or list of |
Note
The function is decorated with @ttl_cache
to cache the results for 180 seconds and limit the cache size to 128 entries.
Source code in martignac/nomad/users.py
who_am_i(use_prod=True, timeout_in_sec=10)
¶
Retrieves the information of the currently authenticated user from the NOMAD system.
This function makes a request to the NOMAD system to fetch the details of the currently authenticated user. It allows specifying whether to query the production or test environment of the NOMAD system. Additionally, a timeout for the request can be defined to manage how long the function waits for a response from the NOMAD system. The results are cached to improve performance and reduce the load on the NOMAD system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
use_prod |
bool
|
Flag indicating whether to use the production environment of the NOMAD system. Defaults to True. |
True
|
timeout_in_sec |
int
|
The maximum time in seconds to wait for a response from the NOMAD system. Defaults to 10 seconds. |
10
|
Returns:
Name | Type | Description |
---|---|---|
NomadUser |
NomadUser
|
An instance of |
Note
The function is decorated with @ttl_cache
to cache the results for 180 seconds and limit the cache size to 128 entries.