Skip to content

AccountOperations

Access via client.account. Self-service operations — no admin required.

crucible.resources.account.AccountOperations

Self-service account operations.

Access via: client.account.profile(), client.account.list_api_keys(), etc. All methods require a valid API key but do not require admin permissions.

whoami()

Return full auth context for the current API key.

Returns ORCID, access group list, and user profile in one response. For just the user profile use account.profile().

Returns:

Name Type Description
Dict Dict

user_unique_id, access_group_ids, user_info (UserRead)

profile(privilege_mode=None)

Return the authenticated caller's own user profile.

Parameters:

Name Type Description Default
privilege_mode Optional[str]

Per-call privilege mode. The capability flags describe the authority of the mode they were fetched under.

None

Returns:

Name Type Description
Dict Dict

UserRead with unique_id, username, first_name, last_name, and email, plus the authorization and capabilities blocks.

update_profile(**kwargs)

Partially update the authenticated caller's own profile.

Accepted fields: first_name, last_name, email, username. Pass username=None to clear the username. Account type cannot be changed through profile updates.

Returns:

Name Type Description
Dict Dict

Updated UserRead profile

create_api_key(name, expires_at=None)

Create another API key for the caller.

Needs a recent sign-in, not an API key: a key gets 403 hub_session_required. At most 10 keys can be active (409 too_many_keys).

Parameters:

Name Type Description Default
name str

What the key is for, such as the machine or script that uses it (1 to 100 characters).

required
expires_at Optional[Union[datetime, str]]

When the key stops working, at most a year away; a year when omitted. A datetime should be timezone-aware.

None

Returns:

Name Type Description
Dict Dict

ApiKeyCreated. api_key holds the key and is returned only here, so store it now.

list_api_keys(state='active', limit=DEFAULT_LIMIT, cursor=None)

List the caller's API keys, newest first, never the keys themselves.

Works with an API key.

Parameters:

Name Type Description Default
state str

'active', or 'inactive' for expired and revoked keys.

'active'
limit Optional[int]

Maximum number of keys. None fetches all.

DEFAULT_LIMIT
cursor Optional[str]

Continuation token from a previous result's next_cursor.

None

Returns:

Type Description
ListResult

ListResult[Dict]: ApiKeyInfo records.

rename_api_key(key_id, name)

Rename one of the caller's API keys.

Raises:

Type Description
HTTPError 404

The key is not one of the caller's.

Returns:

Name Type Description
Dict Dict

The updated ApiKeyInfo.

revoke_api_key(key_id)

Revoke one of the caller's API keys. It stops working within a minute.

Revoking the key this client uses ends its access too.

Raises:

Type Description
HTTPError 404

The key is not one of the caller's.

verify()

Return the validity and expiry info for the presented API key.

With a Hub session instead of a key, describes the newest key, with valid False once it has expired.

Returns:

Name Type Description
Dict Dict

{valid: bool, created_at: str, expires_at: str, last_used_at: str | None}

join_requests(status=None, limit=DEFAULT_LIMIT, offset=0, cursor=None)

Return the caller's own join-request history, across all projects.

Same as client.access_groups.list_join_requests(scope='submitted'), which also takes the other filters and sorts.

Parameters:

Name Type Description Default
status Optional[str]

One status or a list of them, from crucible.constants.JOIN_REQUEST_STATUSES.

None
limit int

Maximum number of results.

DEFAULT_LIMIT
offset int

Starting position in the full result set.

0
cursor str

Continuation token from a previous result's next_cursor; the listing resumes there.

None

Returns:

Type Description
List[Dict]

List[Dict]: JoinRequest records where requester_id == caller.

sync_projects()

Refresh the caller's project memberships from the MF proposal database.

Additive — projects are only ever added, never removed.

Returns:

Name Type Description
Dict Dict

{orcid, projects_added, projects_already_member, projects_not_found}