Skip to content

Types

Object dataclass

Distributed/Stored media representation. This class is used to represent any media decentralized and already stored in IPFS.

Usage:

# generally, these objects are returned by storage operations
stored_object = Object("bafyjvzacdjrk37kqvy5hbqepmcraz3txt3igs7dbjwwhlfm3433a","image",250)
Source code in nucleus/sdk/storage/types.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
@dataclass(slots=True)
class Object:
    """Distributed/Stored media representation.
    This class is used to represent any media decentralized and already stored in IPFS.

    Usage:

        # generally, these objects are returned by storage operations
        stored_object = Object("bafyjvzacdjrk37kqvy5hbqepmcraz3txt3igs7dbjwwhlfm3433a","image",250)
    """

    hash: CID
    name: str
    size: int

Pin dataclass

Represents ipfs pin output

Usage:

# generally, returned by pinning operations
pin = Pin("bafyjvzacdjrk37kqvy5hbqepmcraz3txt3igs7dbjwwhlfm3433a","pinned", "image.jpg")
Source code in nucleus/sdk/storage/types.py
23
24
25
26
27
28
29
30
31
32
33
34
35
@dataclass(slots=True)
class Pin:
    """Represents ipfs pin output

    Usage:

        # generally, returned by pinning operations
        pin = Pin("bafyjvzacdjrk37kqvy5hbqepmcraz3txt3igs7dbjwwhlfm3433a","pinned", "image.jpg")
    """

    cid: CID
    status: str
    name: Optional[str]

Client

Bases: Protocol

Provides an standard interface for handling IPFS storage services. Each storage service represents a remote cache service, such as Estuary.

Source code in nucleus/sdk/storage/types.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@runtime_checkable
class Client(Protocol):
    """Provides an standard interface for handling IPFS storage services. Each storage service
    represents a remote cache service, such as Estuary.
    """

    def pin(self, obj: Object) -> Pin:
        """Pin cid to storage service

        :param obj: Object to pin
        :return: Pin object
        """
        ...

    def unpin(self, cid: CID) -> CID:
        """Remove pin from storage service

        :param cid: The cid to remove from service
        :return: The just removed object cid
        """
        ...

pin(obj)

Pin cid to storage service

Parameters:

Name Type Description Default
obj Object

Object to pin

required

Returns:

Type Description
Pin

Pin object

Source code in nucleus/sdk/storage/types.py
50
51
52
53
54
55
56
def pin(self, obj: Object) -> Pin:
    """Pin cid to storage service

    :param obj: Object to pin
    :return: Pin object
    """
    ...

unpin(cid)

Remove pin from storage service

Parameters:

Name Type Description Default
cid CID

The cid to remove from service

required

Returns:

Type Description
CID

The just removed object cid

Source code in nucleus/sdk/storage/types.py
58
59
60
61
62
63
64
def unpin(self, cid: CID) -> CID:
    """Remove pin from storage service

    :param cid: The cid to remove from service
    :return: The just removed object cid
    """
    ...