Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from icgood/tokens
Use macaroon tokens for admin request auth
- Loading branch information
Showing
36 changed files
with
1,160 additions
and
563 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
from __future__ import annotations | ||
|
||
from grpclib.const import Status | ||
from grpclib.exceptions import GRPCError | ||
from google.rpc.error_details_pb2 import ErrorInfo | ||
|
||
__all__ = ['get_unimplemented_error', 'get_incompatible_version_error'] | ||
|
||
|
||
def get_unimplemented_error(*, domain: str = None, **metadata: str) \ | ||
-> GRPCError: | ||
"""Build a :exc:`~grpclib.exceptions.GRPCError` exception for an | ||
operation that is not implemented by the server. | ||
Args: | ||
domain: The domain string to include in the error. | ||
metadata: Additional metadata to include in the error. | ||
""" | ||
return GRPCError(Status.UNIMPLEMENTED, 'Operation not available', [ | ||
ErrorInfo(reason='UNIMPLEMENTED', domain=domain, metadata=metadata)]) | ||
|
||
|
||
def get_incompatible_version_error(client_version: str, server_version: str, *, | ||
domain: str = None, **metadata: str) \ | ||
-> GRPCError: | ||
"""Build a :exc:`~grpclib.exceptions.GRPCError` exception for an | ||
incompatible version error. | ||
Args: | ||
client_version: The client version string. | ||
server_version: The server version string. | ||
domain: The domain string to include in the error. | ||
metadata: Additional metadata to include in the error. | ||
""" | ||
metadata = {'client_version': client_version, | ||
'server_version': server_version, | ||
**metadata} | ||
return GRPCError(Status.FAILED_PRECONDITION, 'Incompatible version', [ | ||
ErrorInfo(reason='INCOMPATIBLE', domain=domain, metadata=metadata)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.