|
9 | 9 | @APIRouter('rgw/accounts', Scope.RGW) |
10 | 10 | @APIDoc("RGW User Accounts API", "RgwUserAccounts") |
11 | 11 | class RgwUserAccountsController(RESTController): |
12 | | - |
| 12 | + @EndpointDoc("Update RGW account info", |
| 13 | + parameters={'account_name': (str, 'Account name'), |
| 14 | + 'email': (str, 'Email'), |
| 15 | + 'tenant': (str, 'Tenant'), |
| 16 | + 'max_buckets': (int, 'Max buckets'), |
| 17 | + 'max_users': (int, 'Max users'), |
| 18 | + 'max_roles': (int, 'Max roles'), |
| 19 | + 'max_group': (int, 'Max groups'), |
| 20 | + 'max_access_keys': (int, 'Max access keys')}) |
13 | 21 | @allow_empty_body |
14 | | - def create(self, account_name: Optional[str] = None, |
15 | | - account_id: Optional[str] = None, email: Optional[str] = None): |
16 | | - return RgwAccounts.create_account(account_name, account_id, email) |
| 22 | + def create(self, account_name: str, tenant: Optional[str] = None, |
| 23 | + email: Optional[str] = None, max_buckets: Optional[int] = None, |
| 24 | + max_users: Optional[int] = None, max_roles: Optional[int] = None, |
| 25 | + max_group: Optional[int] = None, |
| 26 | + max_access_keys: Optional[int] = None): |
| 27 | + """ |
| 28 | + Create an account |
| 29 | +
|
| 30 | + :param account_name: Account name |
| 31 | + :return: Returns account resource. |
| 32 | + :rtype: Dict[str, Any] |
| 33 | + """ |
| 34 | + return RgwAccounts.create_account(account_name, tenant, email, |
| 35 | + max_buckets, max_users, max_roles, |
| 36 | + max_group, max_access_keys) |
17 | 37 |
|
18 | 38 | def list(self, detailed: bool = False): |
| 39 | + """ |
| 40 | + List all account ids or all detailed account info based on the 'detailed' query parameter. |
| 41 | +
|
| 42 | + - If detailed=True, returns detailed account info. |
| 43 | + - If detailed=False, returns only account ids. |
| 44 | + """ |
19 | 45 | detailed = str_to_bool(detailed) |
20 | 46 | return RgwAccounts.get_accounts(detailed) |
21 | 47 |
|
22 | 48 | @EndpointDoc("Get RGW Account by id", |
23 | 49 | parameters={'account_id': (str, 'Account id')}) |
24 | 50 | def get(self, account_id: str): |
| 51 | + """ |
| 52 | + Get an account by account id |
| 53 | + """ |
25 | 54 | return RgwAccounts.get_account(account_id) |
26 | 55 |
|
27 | 56 | @EndpointDoc("Delete RGW Account", |
28 | 57 | parameters={'account_id': (str, 'Account id')}) |
29 | 58 | def delete(self, account_id): |
| 59 | + """ |
| 60 | + Removes an account |
| 61 | +
|
| 62 | + :param account_id: account identifier |
| 63 | + :return: None. |
| 64 | + """ |
30 | 65 | return RgwAccounts.delete_account(account_id) |
31 | 66 |
|
32 | 67 | @EndpointDoc("Update RGW account info", |
33 | | - parameters={'account_id': (str, 'Account id')}) |
| 68 | + parameters={'account_id': (str, 'Account id'), |
| 69 | + 'account_name': (str, 'Account name'), |
| 70 | + 'email': (str, 'Email'), |
| 71 | + 'tenant': (str, 'Tenant'), |
| 72 | + 'max_buckets': (int, 'Max buckets'), |
| 73 | + 'max_users': (int, 'Max users'), |
| 74 | + 'max_roles': (int, 'Max roles'), |
| 75 | + 'max_group': (int, 'Max groups'), |
| 76 | + 'max_access_keys': (int, 'Max access keys')}) |
34 | 77 | @allow_empty_body |
35 | | - def set(self, account_id: str, account_name: Optional[str] = None, |
36 | | - email: Optional[str] = None): |
37 | | - return RgwAccounts.modify_account(account_id, account_name, email) |
| 78 | + def set(self, account_id: str, account_name: str, |
| 79 | + email: Optional[str] = None, tenant: Optional[str] = None, |
| 80 | + max_buckets: Optional[int] = None, max_users: Optional[int] = None, |
| 81 | + max_roles: Optional[int] = None, max_group: Optional[int] = None, |
| 82 | + max_access_keys: Optional[int] = None): |
| 83 | + """ |
| 84 | + Modifies an account |
| 85 | +
|
| 86 | + :param account_id: Account identifier |
| 87 | + :return: Returns modified account resource. |
| 88 | + :rtype: Dict[str, Any] |
| 89 | + """ |
| 90 | + return RgwAccounts.modify_account(account_id, account_name, email, tenant, |
| 91 | + max_buckets, max_users, max_roles, |
| 92 | + max_group, max_access_keys) |
38 | 93 |
|
39 | 94 | @EndpointDoc("Set RGW Account/Bucket quota", |
40 | 95 | parameters={'account_id': (str, 'Account id'), |
41 | | - 'max_size': (str, 'Max size')}) |
| 96 | + 'quota_type': (str, 'Quota type'), |
| 97 | + 'max_size': (str, 'Max size'), |
| 98 | + 'max_objects': (str, 'Max objects')}) |
42 | 99 | @RESTController.Resource(method='PUT', path='/quota') |
43 | 100 | @allow_empty_body |
44 | | - def set_quota(self, quota_type: str, account_id: str, max_size: str, max_objects: str): |
45 | | - return RgwAccounts.set_quota(quota_type, account_id, max_size, max_objects) |
| 101 | + def set_quota(self, quota_type: str, account_id: str, max_size: str, max_objects: str, |
| 102 | + enabled: bool): |
| 103 | + """ |
| 104 | + Modifies quota |
| 105 | +
|
| 106 | + :param account_id: Account identifier |
| 107 | + :param quota_type: 'account' or 'bucket' |
| 108 | + :return: Returns modified quota. |
| 109 | + :rtype: Dict[str, Any] |
| 110 | + """ |
| 111 | + return RgwAccounts.set_quota(quota_type, account_id, max_size, max_objects, enabled) |
46 | 112 |
|
47 | 113 | @EndpointDoc("Enable/Disable RGW Account/Bucket quota", |
48 | | - parameters={'account_id': (str, 'Account id')}) |
| 114 | + parameters={'account_id': (str, 'Account id'), |
| 115 | + 'quota_type': (str, 'Quota type'), |
| 116 | + 'quota_status': (str, 'Quota status')}) |
49 | 117 | @RESTController.Resource(method='PUT', path='/quota/status') |
50 | 118 | @allow_empty_body |
51 | 119 | def set_quota_status(self, quota_type: str, account_id: str, quota_status: str): |
| 120 | + """ |
| 121 | + Enable/Disable quota |
| 122 | +
|
| 123 | + :param account_id: Account identifier |
| 124 | + :param quota_type: 'account' or 'bucket' |
| 125 | + :param quota_status: 'enable' or 'disable' |
| 126 | + :return: Returns modified quota. |
| 127 | + :rtype: Dict[str, Any] |
| 128 | + """ |
52 | 129 | return RgwAccounts.set_quota_status(quota_type, account_id, quota_status) |
0 commit comments