Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dimastbk committed Jun 9, 2024
1 parent 9f3fb2c commit cc66b17
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
13 changes: 12 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ["sphinx_rtd_theme", "sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.autosectionlabel"]
extensions = [
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.autosectionlabel",
"sphinx.ext.intersphinx",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand All @@ -58,3 +64,8 @@
version = "3.0.4"

master_doc = "index"

# Looks for objects in external projects
intersphinx_mapping = {
"grpc": ("https://grpc.github.io/grpc/python/", None),
}
2 changes: 2 additions & 0 deletions docs/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ All ``pyzeebe`` errors inherit from :py:class:`PyZeebeError`

.. autoexception:: pyzeebe.errors.InvalidCamundaCloudCredentialsError

.. autoexception:: pyzeebe.errors.UnkownGrpcStatusCodeError


=================
Exception Handler
Expand Down
4 changes: 2 additions & 2 deletions pyzeebe/credentials/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class CredentialsABC(abc.ABC):
"""TODO."""
"""A specification for credentials manager. Passed to :py:class:`AuthMetadataPlugin`."""

@abc.abstractmethod
def get_auth_metadata(self, context: CallContext) -> AuthMetadata:
Expand All @@ -13,6 +13,6 @@ def get_auth_metadata(self, context: CallContext) -> AuthMetadata:
context (grpc.AuthMetadataContext): Provides information to call credentials metadata plugins.
Returns:
Tuple[Tuple[str, Union[str, bytes]], ...]: The `metadata` used to construct the grpc.CallCredentials.
Tuple[Tuple[str, Union[str, bytes]], ...]: The `metadata` used to construct the :py:class:`grpc.CallCredentials`.
"""
raise NotImplementedError
6 changes: 3 additions & 3 deletions pyzeebe/credentials/camunda_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class CamundaIdentityCredentials(CredentialsABC):
oauth_url (str): The Keycloak auth endpoint url.
client_id (str): The client id provided by Camunda Platform
client_secret (str): The client secret provided by Camunda Platform
audience (str):
refresh_threshold_seconds (int):
audience (str): Audience for Zeebe. Default: zeebe-api
refresh_threshold_seconds (int): Will try to refresh token if it expires in this number of seconds or less. Default: 20
"""

def __init__(
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_auth_metadata(self, context: CallContext) -> AuthMetadata:
context (grpc.AuthMetadataContext): Provides information to call credentials metadata plugins.
Returns:
Tuple[Tuple[str, Union[str, bytes]], ...]: The `metadata` used to construct the grpc.CallCredentials.
Tuple[Tuple[str, Union[str, bytes]], ...]: The `metadata` used to construct the :py:class:`grpc.CallCredentials`.
Raises:
InvalidOAuthCredentialsError: One of the provided camunda credentials is not correct
Expand Down
13 changes: 4 additions & 9 deletions pyzeebe/credentials/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


class AuthMetadataPlugin(grpc.AuthMetadataPlugin):
"""TODO.
"""Custom authentication plugin with exception catching.
Args:
credentials (CredentialsABC): TODO
credentials (CredentialsABC): A credentials manager.
"""

def __init__(self, *, credentials: CredentialsABC) -> None:
Expand All @@ -30,11 +30,6 @@ def __call__(self, context: grpc.AuthMetadataContext, callback: grpc.AuthMetadat
try:
metadata = self._credentials.get_auth_metadata(context)
except Exception as e:
self._sign_request(callback, (), e)
callback((), e)
else:
self._sign_request(callback, metadata, None)

def _sign_request(
self, callback: grpc.AuthMetadataPluginCallback, metadata: AuthMetadata, error: Optional[Exception]
) -> None:
callback(metadata, error)
callback(metadata, None)

0 comments on commit cc66b17

Please sign in to comment.