Skip to content

Commit d2b0e2f

Browse files
rawe0diocas
authored andcommitted
Add GetQuota to file.py
1 parent a040d68 commit d2b0e2f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cs3client/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_token(self) -> tuple[str, str]:
7676

7777
if not self._client_secret:
7878
self._log.error("Attempted to authenticate, client secret was not set")
79-
raise SecretNotSetException("The client secret (e.g. token, passowrd) is not set")
79+
raise SecretNotSetException("The client secret (e.g. token, password) is not set")
8080

8181
try:
8282
self.check_token(self._token)

cs3client/file.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,3 +690,21 @@ def unlock(self, auth_token: tuple, resource: Resource, app_name, lock_id: Union
690690
self._status_code_handler.handle_errors(res.status, "unlock", resource.get_file_ref_str())
691691
self._log.debug(f'msg="Invoked Unlock" {resource.get_file_ref_str()} result="{res.status.trace}" '
692692
f'value="{lock_id}"')
693+
694+
@handle_grpc_error
695+
def get_quota(self, auth_token: tuple, resource: Resource):
696+
"""
697+
Get the quota for a given path
698+
:param auth_token: tuple in the form ('x-access-token', <token>) (see auth.get_token/auth.check_token)
699+
:param resource: Resource to get the quota for.
700+
:return: The quota for the given resource.
701+
:raises: NotFoundException (File not found)
702+
:raises: AuthenticationException (Authentication Failed)
703+
:raises: UnknownException (Unknown Error)
704+
"""
705+
706+
get_quota_request = cs3spr.GetQuotaRequest(ref=resource.ref)
707+
res = self._gateway.GetQuota(request=get_quota_request, metadata=[auth_token])
708+
self._status_code_handler.handle_errors(res.status, "get quota", resource.get_file_ref_str())
709+
self._log.debug(f'msg="Invoked GetQuota" trace="{res.status.trace}"')
710+
return res

0 commit comments

Comments
 (0)