clabe.aind.validators ¶
ActiveDirectoryUser ¶
Bases: BaseModel
A user record returned by the AIND Active Directory metadata service.
get_aind_rig_name ¶
Return the AIND rig name from the aibs_comp_id environment variable.
Single source of truth for reading the rig identifier from the environment; prefer this
over reading aibs_comp_id directly so the variable name lives in exactly one place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
required
|
bool
|
When True, raise |
False
|
Returns:
| Type | Description |
|---|---|
str | None
|
The rig name, or |
Source code in src/clabe/aind/validators.py
get_active_directory_user ¶
get_active_directory_user(
username: str, timeout: float | None = 2
) -> ActiveDirectoryUser
Fetches a user's record from the AIND Active Directory metadata service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
The username to look up. |
required |
timeout
|
float | None
|
Timeout in seconds for the HTTP request. Defaults to 2. |
2
|
Returns:
| Type | Description |
|---|---|
ActiveDirectoryUser
|
The user's record. |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If the request fails or the user is not found. |
ValidationError
|
If the response payload is malformed. |
Source code in src/clabe/aind/validators.py
validate_username ¶
Validates if the given username exists in the AIND Active Directory.
Queries the AIND metadata service to verify the username exists. Returns None (instead of raising) on network errors or an invalid username so callers can decide how to handle the degraded state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
The username to validate. |
required |
timeout
|
float | None
|
Timeout in seconds for the HTTP request. Defaults to 2. |
2
|
Returns:
| Type | Description |
|---|---|
str | None
|
The canonical username from the Active Directory record (which may differ in |
str | None
|
case from the input), or None if the username is invalid. |
Source code in src/clabe/aind/validators.py
validate_rig_computer_name ¶
Ensures rig and computer name are set from environment variables if available, otherwise defaults to rig configuration values.