API Reference

Core Components

ConsentManager

class oconsent.core.consent.ConsentManager(blockchain_client, proof_generator, timestamp_service)[source]

Bases: object

Manages consent agreements and their lifecycle.

create_agreement(subject_id: str, processor_id: str, purposes: List[ConsentPurpose], valid_from: datetime, valid_until: datetime | None = None, metadata: Dict | None = None) ConsentAgreement[source]

Creates a new consent agreement.

list_agreements(subject_id: str | None = None, processor_id: str | None = None, status: str | None = None) List[ConsentAgreement][source]

Lists consent agreements based on optional filters.

revoke_agreement(agreement_id: str) ConsentAgreement[source]

Revokes an existing consent agreement.

Verifies if consent exists and is valid for a specific purpose.

class ConsentManager:
    """Manages consent agreements and their lifecycle."""

    def create_agreement(
        self,
        subject_id: str,
        processor_id: str,
        purposes: List[Dict],
        valid_from: datetime,
        valid_until: Optional[datetime] = None,
        metadata: Optional[Dict] = None
    ) -> ConsentAgreement:
        """Creates a new consent agreement."""
        pass

    def verify_consent(
        self,
        agreement_id: str,
        purpose_id: str,
        processor_id: str
    ) -> bool:
        """Verifies if consent exists and is valid."""
        pass

Blockchain Components

EthereumClient

class oconsent.blockchain.ethereum.EthereumClient(provider_url: str, contract_address: str, private_key: str | None = None, contract_abi: Dict | None = None)[source]

Bases: object

Handles interactions with Ethereum blockchain.

get_agreement(agreement_id: str) ConsentAgreement | None[source]

Retrieves a consent agreement from the blockchain.

query_agreements(subject_id: str | None = None, processor_id: str | None = None, status: str | None = None) List[ConsentAgreement][source]

Queries consent agreements based on filters.

store_agreement(agreement: ConsentAgreement) str[source]

Stores a consent agreement on the blockchain.

update_agreement(agreement: ConsentAgreement) str[source]

Updates an existing consent agreement on the blockchain.

Storage Components

IPFSStorageProvider