Skip to content

Accountclient

Classes

AccountClient

AccountClient(
    rucio_host=None,
    auth_host=None,
    account=None,
    ca_cert=None,
    auth_type=None,
    creds=None,
    timeout=600,
    user_agent="rucio-clients",
    vo=None,
    logger=LOG,
)

Account client class for working with Rucio accounts

Methods:

add_account
add_account(account, type_, email)

Create a new account. Accounts can be used to set permissions, identities, and quotas.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

type_

The account type. Choose from USER (for a single user), GROUP (an account shared across multiple users) or SERVICE (operator or for automated processes).

TYPE: Literal['USER', 'GROUP', 'SERVICE']

email

The email address associated with the account.

TYPE: str

RETURNS DESCRIPTION
True if account was created.
RAISES DESCRIPTION
Duplicate

If account already exists.

Examples:

Example

Create a new user account for jdoe.

from rucio.client.client import Client
client = Client()
client.add_account('jdoe', 'USER', 'jdoe@cern.ch')
See Also

rucio.client.accountclient.AccountClient.delete_account rucio.client.accountclient.AccountClient.get_account rucio.client.accountclient.AccountClient.add_identity rucio.client.accountclient.AccountClient.set_account_limit

delete_account
delete_account(account)

Disable an account. When an account is disabled, the account can no longer be used for authentication, but it will still exist in the system. Alternatively, an account can temporary disabled by suspending the account via update_account(account, 'status', 'suspended').

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

RETURNS DESCRIPTION
True if account was disabled successfully.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

Examples:

Example

Delete the 'jdoe' account.

from rucio.client.client import Client
client = Client()
client.delete_account('jdoe')
See Also

rucio.client.accountclient.AccountClient.add_account rucio.client.accountclient.AccountClient.get_account rucio.client.accountclient.AccountClient.list_accounts rucio.client.accountclient.AccountClient.update_account

get_account
get_account(account)

Send the request to get information about a given account.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

RETURNS DESCRIPTION
A dictionary of settings for an account.

** account [str]: The name of the account. ** type [str]: The account type (USER, GROUP, or SERVICE). ** email [str]: The email address associated with the account. ** status [str]: The account status (active, disabled, or suspended). ** created_at [datetime.datetime]: When the account was created. ** updated_at [datetime.datetime]: When the account was last updated. ** deleted_at [datetime.datetime]: When the account was deleted. None if the account is not deleted. ** suspended_at [datetime.datetime]: When the account was suspended. None if the account is not suspended.

RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.add_account rucio.client.accountclient.AccountClient.update_account rucio.client.accountclient.AccountClient.add_account_attribute

update_account
update_account(account, key, value)

Update a property of an account.

PARAMETER DESCRIPTION
account

Name of the account.

TYPE: str

key

Account property. Choose from status (active, disabled, or suspended) or account_type (USER, GROUP, or SERVICE), or email.

TYPE: Literal['status', 'account_type', 'email']

value

Property value.

TYPE: Any

RETURNS DESCRIPTION
True if successful.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

Examples:

Example

Suspend the 'jdoe' account, can be used a 'ban' operation to temporarily disable an account.

from rucio.client.client import Client
client = Client()
client.update_account('jdoe', 'status', 'suspended')
Example

Change the email associated with a service account

from rucio.client.client import Client
client = Client()
client.update_account('my_service_account', 'email', 'new.services@cern.ch')
list_accounts
list_accounts(
    account_type=None, identity=None, filters=None
)

List all accounts, with the ablity to filter based on type, identity, or other account attributes.

PARAMETER DESCRIPTION
account_type

The account type.

TYPE: Optional[str] DEFAULT: None

identity

The identity key name. For example, x509 DN or a username.

TYPE: Optional[str] DEFAULT: None

filters

A dictionary of key-value pairs to filter on accounts. Can be an acount setting or an account attribute.

TYPE: Optional[dict[str, Any]] DEFAULT: None

RETURNS DESCRIPTION
An iterator of dictionaries of settings for accounts.
** `account`** [str]: The name of the account.
** `type`** [str]: The account type (USER, GROUP, or SERVICE).
** `email`** [str]: The email address associated with the account.

If no accounts match the provided criteria, an empty iterator is returned.

Examples:

Example

List all 'USER' account names.

from rucio.client.client import Client
client = Client()
user_accounts = client.list_accounts(account_type='USER')
for account in user_accounts:
    print(account['account'])

Example

List all service account names with an 'admin' attribute

from rucio.client.client import Client
client = Client()
service_accounts = client.list_accounts(account_type='SERVICE', filters={'admin': True})
for account in service_accounts:
    print(account['account'])

whoami
whoami()

Get information about account whose token is used. Recommended as a debugging tool to check authentication via client.

RETURNS DESCRIPTION
Settings for the authenticated account.

** account [str]: The name of the account. ** type [str]: The account type (USER, GROUP, or SERVICE). ** email [str]: The email address associated with the account. ** status [str]: The account status (active, disabled, or suspended). ** created_at [datetime.datetime]: When the account was created. ** updated_at [datetime.datetime]: When the account was last updated. ** deleted_at [datetime.datetime]: When the account was deleted. None if the account is not deleted. ** suspended_at [datetime.datetime]: When the account was suspended. None if the account is not suspended.

See Also

rucio.client.accountclient.AccountClient.get_account

add_identity
add_identity(
    account,
    identity,
    authtype,
    email,
    default=False,
    password=None,
)

Add a membership association between identity and account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

identity

The identity key name. For example x509 DN, or a username.

TYPE: str

authtype

The type of the authentication (x509, gss, userpass).

TYPE: str

email

The Email address associated with the identity.

TYPE: str

default

If True, the account should be used by default with the provided identity.

TYPE: bool DEFAULT: False

password

Password if authtype is userpass.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
True if successful.
RAISES DESCRIPTION
IdentityError

If you are missing a required element of the identity

Duplicate

If the identity is already associated with the account.

del_identity
del_identity(account, identity, authtype)

Delete an identity's membership association with an account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

identity

The identity key name. For example x509 DN, or a username.

TYPE: str

authtype

The type of the authentication (x509, gss, userpass).

TYPE: str

RETURNS DESCRIPTION
True if successful.
RAISES DESCRIPTION
IdentityError

Identity does not exist or is not associated with the account.

list_identities
list_identities(account)

List all identities on an account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

RETURNS DESCRIPTION
An iterator of dictionaries of settings for identities associated with the account.

** type ** [str]: The type of the authentication (x509, gss, userpass). ** identity ** [str]: The identity key name. For example x509 DN, or a username. ** email ** [str]: The Email address associated with the identity.

RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

list_account_rules
list_account_rules(account)

List the associated rules that an account owns.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

RETURNS DESCRIPTION
An iterator of dictionaries of settings for rules associated with the account.

Keys are the attributes of the rule as given by RuleClient.get_replication_rule

See Also

rucio.client.ruleclient.RuleClient.get_replication_rule rucio.client.ruleclient.RuleClient.add_replication_rule

get_account_limits
get_account_limits(account, rse_expression, locality)

Return the account limits for the given rse and locality.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

rse_expression

Valid RSE expression.

TYPE: str

locality

The scope of the account limit. 'local' or 'global'.

TYPE: Literal['local', 'global']

RETURNS DESCRIPTION
Dictionary with keys of the RSEs and the account limit for each RSE in bytes.

If the RSE expression resolves to no RSEs, {rse_expression: None} is returned.

RAISES DESCRIPTION
UnsupportedOperation

If the provided locality is not 'local' or 'global'.

AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.get_global_account_limit rucio.client.accountclient.AccountClient.get_local_account_limit

set_account_limit
set_account_limit(account, rse, bytes_, locality)

Sets an account limit for a given limit scope. Limits are defined as a combination of rse{_expression} and locality. A "local" limit applied a limit to a specific RSE, while a "global" limit applies to all RSEs that match the provided RSE expression.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

rse

The rse name or expression.

TYPE: str

bytes_

The limit in bytes.

TYPE: int

locality

The scope of the account limit.

TYPE: Literal['local', 'global']

RETURNS DESCRIPTION
True if quota was created successfully.
RAISES DESCRIPTION
UnsupportedOperation

If the provided locality is not 'local' or 'global'.

AccountNotFound

If account doesn't exist.

Examples:

Example

Set a local account limit of 10GB for the 'jdoe' account on the 'MOCK' RSE.

from rucio.client.client import Client
client = Client()
client.set_account_limit('jdoe', 'MOCK', 1e10, 'local')
Example

Set a global account limit of 1TB for the 'jdoe' account on all RSEs that match the expression 'MOCK*'. If a local limit already exists for an RSE that matches the expression, the local limit will override the global limit for that RSE.

So if the previous example's limit is already place, this will result in a 10GB limit for 'jdoe' on 'MOCK' and a 1TB limit for 'jdoe' on all other RSEs that match 'MOCK*'.

from rucio.client.client import Client
client = Client()
client.set_account_limit('jdoe', 'MOCK*', 1e12, 'global')
See Also

rucio.client.accountclient.AccountClient.set_local_account_limit rucio.client.accountclient.AccountClient.set_global_account_limit

delete_account_limit
delete_account_limit(account, rse, locality)

Deletes an account limit for a given limit scope.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

rse

The rse name.

TYPE: str

locality

The scope of the account limit.

TYPE: Literal['local', 'global']

RETURNS DESCRIPTION
True if limit was deleted successfully.
RAISES DESCRIPTION
UnsupportedOperation

If the provided locality is not 'local' or 'global'.

AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.set_account_limit

get_global_account_limit
get_global_account_limit(account, rse_expression)

List the account limit for the specific RSE expression.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

rse_expression

The rse expression.

TYPE: str

RETURNS DESCRIPTION
Dictionary with keys of the RSE Expression and the account limit for the RSE Expression in bytes.

Does not resolve each RSE Expression to RSEs.

See Also

rucio.client.accountclient.AccountClient.get_account_limits rucio.client.accountclient.AccountClient.get_local_account_limits rucio.client.rseclient.RSEClient.list_rses

get_global_account_limits
get_global_account_limits(account)

List all RSE expression limits of this account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

RAISES DESCRIPTION
InvalidRSEExpression

If the account has a limit with a RSE Expression limits that do not resolve to RSEs

AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.get_account_limits rucio.client.accountclient.AccountClient.get_local_account_limits

get_local_account_limits
get_local_account_limits(account)

List the all local rse limits of this account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

RETURNS DESCRIPTION
Dictionary with keys of the RSEs and the account limit for each RSE in bytes
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.get_account_limits rucio.client.accountclient.AccountClient.get_global_account_limits

get_local_account_limit
get_local_account_limit(account, rse)

Get the local limit for this account on a specified RSE. Equivalent to get_local_account_limits(account)[rse]

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

rse

The rse name.

TYPE: str

RETURNS DESCRIPTION
Dictionary with keys of the RSE and the account limit for the RSE in bytes.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

RSENotFound

If RSE doesn't exist.

See Also

rucio.client.accountclient.AccountClient.get_account_limits

set_local_account_limit
set_local_account_limit(account, rse, bytes_)

Sends the request to set an account limit for an account.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

rse

The rse name.

TYPE: str

bytes_

The limit in bytes.

TYPE: int

RETURNS DESCRIPTION
True if quota was created successfully.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

RSENotFound

If RSE doesn't exist.

See Also

rucio.client.accountclient.AccountClient.set_global_account_limit rucio.client.accountclient.AccountClient.get_local_account_limit rucio.client.accountclient.AccountClient.get_account_limits

delete_local_account_limit
delete_local_account_limit(account, rse)

Remove a local account limit

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

rse

The rse name.

TYPE: str

RETURNS DESCRIPTION
True if quota was removed successfully.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

RSENotFound

If RSE doesn't exist.

See Also

rucio.client.accountclient.AccountClient.set_account_limit rucio.client.accountclient.AccountClient.set_local_account_limit rucio.client.accountclient.AccountClient.get_local_account_limit rucio.client.accountclient.AccountClient.delete_account_limit

set_global_account_limit
set_global_account_limit(account, rse_expression, bytes_)

Set a global account limit for an account. A global limit applies to all RSEs that match the RSE Expression. If a local limit exists that matches the expression, the local limit takes precedence.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

rse_expression

The rse expression.

TYPE: str

bytes_

The limit in bytes.

TYPE: int

RETURNS DESCRIPTION
True if quota was created successfully.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.set_local_account_limit rucio.client.accountclient.AccountClient.get_global_account_limit

delete_global_account_limit
delete_global_account_limit(account, rse_expression)

Remove a global account limit.

PARAMETER DESCRIPTION
account

The name of the account.

TYPE: str

rse_expression

The rse expression.

TYPE: str

RETURNS DESCRIPTION
True if quota was removed successfully.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.set_account_limit rucio.client.accountclient.AccountClient.set_global_account_limit rucio.client.accountclient.AccountClient.get_global_account_limit

get_local_account_usage
get_local_account_usage(account, rse=None)

List the account usage for one or all rses of this account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

rse

The rse name, used to filter the usage to a specific RSE. If None, all RSEs used by the account are returned.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
An iterator of dictionaries with the keys:

rse : RSE Name. ** bytes : Number of bytes used on the RSE. ** 'files : Number of files on the RSE belonging to the account. ** bytes_limit : If a limit is set, the usage limit for the account. ** bytes_remaining : bytes_limit - bytes_used.

RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.get_global_account_usage

get_global_account_usage
get_global_account_usage(account, rse_expression=None)

List the account usage for one or all RSE expressions of this account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

rse_expression

The rse expression.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
An iterator of dictionaries with the keys:

rse : RSE Name. ** bytes : Number of bytes used on the RSE. ** 'files : Number of files on the RSE belonging to the account. ** bytes_limit : If a limit is set, the usage limit for the account. ** bytes_remaining : bytes_limit - bytes_used.

RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.get_local_account_usage

get_account_usage_history
get_account_usage_history(account, rse)

List the account usage history of this account on rse.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

rse

The rse name.

TYPE: str

list_account_attributes
list_account_attributes(account)

List the attributes for an account. Attributes are attribute key-value pairs that can be added to accounts. They can be used in permission policies or for other custom uses.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

RETURNS DESCRIPTION
An iterator of list of dictionaries of account attributes, as key-value pairs.

Examples:

Example

List all attributes for the 'jdoe' account.

from rucio.client.client import Client
client = Client()
attributes = client.list_account_attributes('jdoe')
for attribute in attributes: # Each attribute is returned as a list of dictionaries
    print(f"Attribute key: {attribute[0]['key']}, Attribute value: {attribute[0]['value']}")
See Also

rucio.client.accountclient.AccountClient.add_account_attribute rucio.client.accountclient.AccountClient.delete_account_attribute

add_account_attribute
add_account_attribute(account, key, value)

Add an attribute to an account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

key

The attribute key.

TYPE: str

value

The attribute value.

TYPE: Any

RETURNS DESCRIPTION
True if successful.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist.

See Also

rucio.client.accountclient.AccountClient.list_account_attributes rucio.client.accountclient.AccountClient.delete_account_attribute

delete_account_attribute
delete_account_attribute(account, key)

Delete an attribute for an account.

PARAMETER DESCRIPTION
account

The account name.

TYPE: str

key

The attribute key.

TYPE: str

RETURNS DESCRIPTION
True if successful.
RAISES DESCRIPTION
AccountNotFound

If account doesn't exist or does not have the attribute key.

See Also

rucio.client.accountclient.AccountClient.list_account_attributes rucio.client.accountclient.AccountClient.add_account_attribute

Functions: