Skip to content

Commit

Permalink
Update documentation and implement rule D417
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Jun 28, 2024
1 parent 926b3f5 commit a0cd8d8
Show file tree
Hide file tree
Showing 158 changed files with 1,108 additions and 438 deletions.
5 changes: 3 additions & 2 deletions aries_cloudagent/admin/request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from typing import Mapping, Optional, Type

from ..core.profile import Profile, ProfileSession
from ..config.injector import Injector, InjectionError, InjectType
from ..config.injection_context import InjectionContext
from ..config.injector import InjectionError, Injector, InjectType
from ..config.settings import Settings
from ..core.profile import Profile, ProfileSession
from ..utils.classloader import DeferLoad

IN_MEM = DeferLoad("aries_cloudagent.core.in_memory.InMemoryProfile")
Expand Down Expand Up @@ -78,6 +78,7 @@ def inject(
Args:
cls: The base class to retrieve an instance of
base_cls: The base class to retrieve an instance of
settings: An optional mapping providing configuration to the provider
Returns:
Expand Down
23 changes: 14 additions & 9 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def __init__(
"""Initialize an instance of `AdminResponder`.
Args:
send: Function to send outbound message
profile (Profile): The profile for this responder.
send (Coroutine): Function to send outbound message.
**kwargs: Additional keyword arguments.
"""
super().__init__(**kwargs)
Expand All @@ -98,6 +100,7 @@ async def send_outbound(
Args:
message: The `OutboundMessage` to be sent
**kwargs: Additional keyword arguments
"""
profile = self._profile()
if not profile:
Expand Down Expand Up @@ -227,14 +230,16 @@ def __init__(
"""Initialize an AdminServer instance.
Args:
host: Host to listen on
port: Port to listen on
context: The application context instance
outbound_message_router: Coroutine for delivering outbound messages
webhook_router: Callable for delivering webhooks
conductor_stop: Conductor (graceful) stop for shutdown API call
task_queue: An optional task queue for handlers
conductor_stats: Conductor statistics API call
host (str): The host to listen on.
port (int): The port to listen on.
context (InjectionContext): The application context instance.
root_profile (Profile): The root profile.
outbound_message_router (Coroutine): Coroutine for delivering
outbound messages.
webhook_router (Callable): Callable for delivering webhooks.
conductor_stop (Coroutine): Conductor (graceful) stop for shutdown API call.
task_queue (TaskQueue, optional): An optional task queue for handlers.
conductor_stats (Coroutine, optional): Conductor statistics API call.
"""
self.app = None
self.admin_api_key = context.settings.get("admin.admin_api_key")
Expand Down
14 changes: 10 additions & 4 deletions aries_cloudagent/anoncreds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def __init__(
"""Initialize an instance.
Args:
message: Message
obj_id: Object ID
obj: Generic Object
message (str): The message associated with the instance.
obj_id (str): The ID of the object.
obj (T, optional): The generic object associated with the instance.
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
"""
super().__init__(message, obj_id, obj, *args, **kwargs)
self._message = message
Expand Down Expand Up @@ -124,7 +126,11 @@ async def get_revocation_registry_definition(

@abstractmethod
async def get_revocation_list(
self, profile: Profile, revocation_registry_id: str, timestamp: int
self,
profile: Profile,
revocation_registry_id: str,
timestamp_from: Optional[int] = 0,
timestamp_to: Optional[int] = None,
) -> GetRevListResult:
"""Get a revocation list from the registry."""

Expand Down
15 changes: 11 additions & 4 deletions aries_cloudagent/anoncreds/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,18 @@ async def _get_credential(self, credential_id: str) -> Credential:
async def credential_revoked(
self, ledger: BaseLedger, credential_id: str, fro: int = None, to: int = None
) -> bool:
"""Check ledger for revocation status of credential by cred id.
"""Check ledger for revocation status of credential by credential id.
Args:
credential_id: Credential id to check
ledger (BaseLedger): The ledger to check for revocation status.
credential_id (str): The ID of the credential to check.
fro (int, optional): The earliest timestamp to consider for revocation status.
Defaults to None.
to (int, optional): The latest timestamp to consider for revocation status.
Defaults to None.
Returns:
bool: True if the credential is revoked, False otherwise.
"""
cred = await self._get_credential(credential_id)
rev_reg_id = cred.rev_reg_id
Expand Down Expand Up @@ -652,8 +659,8 @@ async def create_revocation_state(
Args:
cred_rev_id: credential revocation id in revocation registry
rev_reg_def: revocation registry definition
rev_reg_delta: revocation delta
timestamp: delta timestamp
rev_list: revocation registry
tails_file_path: path to tails file
Returns:
the revocation state
Expand Down
16 changes: 11 additions & 5 deletions aries_cloudagent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,19 @@ async def create_and_register_schema(
"""Create a new credential schema and store it in the wallet.
Args:
issuer_id: the DID issuing the credential definition
name: the schema name
version: the schema version
attr_names: a sequence of schema attribute names
issuer_id (str): The DID issuing the credential definition.
name (str): The schema name.
version (str): The schema version.
attr_names (Sequence[str]): A sequence of schema attribute names.
options (Optional[dict]): Additional options for schema creation.
Defaults to None.
Returns:
A SchemaResult instance
SchemaResult: An instance of SchemaResult.
Raises:
AnonCredsSchemaAlreadyExists: If a similar schema already exists in
the records.
"""
options = options or {}
Expand Down
5 changes: 5 additions & 0 deletions aries_cloudagent/anoncreds/models/anoncreds_cred_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, n: str, s: str, r: dict, rctxt: str, z: str, **kwargs):
z: is equal to s^(xz), where xz is a randomly selected integer between 2
and p'q'-1. This makes up part of the CL-RSA public key, independent of
the message blocks being signed.
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.n = n
Expand Down Expand Up @@ -172,6 +173,7 @@ def __init__(
Args:
primary: Cred Def value primary
revocation: Cred Def value revocation
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.primary = primary
Expand Down Expand Up @@ -223,6 +225,7 @@ def __init__(
type: Type
tag: Tag
value: Cred Def value
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -362,6 +365,7 @@ def __init__(
credential_definition_state: Cred Def state
registration_metadata: Registration metadata
credential_definition_metadata: Cred Def metadata
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down Expand Up @@ -409,6 +413,7 @@ def __init__(
credential_definition: Cred Def
resolution_metadata: Resolution metadata
credential_definition_metadata: Cred Def metadata
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.credential_definition_id = credential_definition_id
Expand Down
7 changes: 7 additions & 0 deletions aries_cloudagent/anoncreds/models/anoncreds_revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(
max_cred_num: Max. number of Creds
tails_location: Tails file location
tails_hash: Tails file hash
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.public_keys = public_keys
Expand Down Expand Up @@ -99,6 +100,7 @@ def __init__(
cred_def_id: Cred Def ID
tag: Tag
value: Rev Reg Def Value
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -238,6 +240,7 @@ def __init__(
revocation_registry_definition_state: Rev Reg Def state
registration_metadata: Registration metadata
revocation_registry_definition_metadata: Rev Reg Def metadata
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down Expand Up @@ -299,6 +302,7 @@ def __init__(
revocation_registry_id: Revocation Registry ID
resolution_metadata: Resolution metadata
revocation_registry_metadata: Revocation Registry metadata
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.revocation_registry = revocation_registry
Expand Down Expand Up @@ -347,6 +351,7 @@ def __init__(
revocation_list: Revocation list
current_accumulator: Current accumulator
timestamp: Timestamp
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -487,6 +492,7 @@ def __init__(
revocation_list_state: Revocation list state
registration_metadata: Registration metadata
revocation_list_metadata: Revocation list metadata
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down Expand Up @@ -537,6 +543,7 @@ def __init__(
revocation_list: Revocation list
resolution_metadata: Resolution metadata
revocation_registry_metadata: Rev Reg metadata
kwargs: Keyword arguments
"""
super().__init__(**kwargs)
self.revocation_list = revocation_list
Expand Down
3 changes: 3 additions & 0 deletions aries_cloudagent/anoncreds/models/anoncreds_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
attr_names: Schema Attribute Name list
name: Schema name
version: Schema version
kwargs: Addiiotnal keyword arguments
"""
super().__init__(**kwargs)
self.issuer_id = issuer_id
Expand Down Expand Up @@ -100,6 +101,7 @@ def __init__(
schema_id: Schema ID
resolution_metadata: Resolution Metdata
schema_metadata: Schema Metadata
kwargs: Additional keyword arguments
"""
super().__init__(**kwargs)
self.schema_value = schema
Expand Down Expand Up @@ -212,6 +214,7 @@ def __init__(
schema_state: Schema state
registration_metadata: Registration Metdata
schema_metadata: Schema Metadata
kwargs: Additional keyword arguments
"""
super().__init__(**kwargs)
self.job_id = job_id
Expand Down
3 changes: 2 additions & 1 deletion aries_cloudagent/anoncreds/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def non_revoc_intervals(self, pres_req: dict, pres: dict, cred_defs: dict) -> li
Args:
pres_req: presentation request
pres: corresponding presentation
cred_defs: credential definitions by cred def id
"""
msgs = []
for req_proof_key, pres_key in {
Expand Down Expand Up @@ -453,6 +453,7 @@ async def verify_presentation(
credential_definitions: credential definition data
rev_reg_defs: revocation registry definitions
rev_reg_entries: revocation registry entries
rev_lists: revocation lists
"""

msgs = []
Expand Down
7 changes: 4 additions & 3 deletions aries_cloudagent/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ def inject(
"""Get the provided instance of a given class identifier.
Args:
cls: The base class to retrieve an instance of
settings: An optional mapping providing configuration to the provider
base_cls (Type[InjectType]): The base class to retrieve an instance of.
settings (Optional[Mapping[str, Any]]): An optional mapping providing
configuration to the provider.
Returns:
An instance of the base class, or None
InjectType: An instance of the base class, or None.
"""

Expand Down
9 changes: 5 additions & 4 deletions aries_cloudagent/config/injection_context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Injection context implementation."""

from collections import namedtuple
import copy
from collections import namedtuple
from typing import Mapping, Optional, Type

from .base import BaseInjector, InjectionError
Expand Down Expand Up @@ -81,11 +81,12 @@ def inject(
"""Get the provided instance of a given class identifier.
Args:
cls: The base class to retrieve an instance of
settings: An optional mapping providing configuration to the provider
base_cls (Type[InjectType]): The base class to retrieve an instance of.
settings (Optional[Mapping[str, object]]): An optional mapping providing
configuration to the provider.
Returns:
An instance of the base class, or None
InjectType: An instance of the base class, or None.
"""
return self.injector.inject(base_cls, settings)
Expand Down
14 changes: 9 additions & 5 deletions aries_cloudagent/config/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from typing import Dict, Mapping, Optional, Type

from .base import BaseProvider, BaseInjector, InjectionError, InjectType
from .provider import InstanceProvider, CachedProvider
from .base import BaseInjector, BaseProvider, InjectionError, InjectType
from .provider import CachedProvider, InstanceProvider
from .settings import Settings


Expand Down Expand Up @@ -118,11 +118,15 @@ def inject(
"""Get the provided instance of a given class identifier.
Args:
cls: The base class to retrieve an instance of
params: An optional dict providing configuration to the provider
base_cls (Type[InjectType]): The base class to retrieve an instance of.
settings (Optional[Mapping[str, object]]): An optional dictionary providing
configuration to the provider.
Returns:
An instance of the base class, or None
InjectType: An instance of the base class, or None.
Raises:
InjectionError: If no instance is provided for the given class identifier.
"""
result = self.inject_or(base_cls, settings)
Expand Down
Loading

0 comments on commit a0cd8d8

Please sign in to comment.