Skip to content

Commit

Permalink
Document public API for tuf.api and tuf.ngclient
Browse files Browse the repository at this point in the history
Signed-off-by: Fridolin Pokorny <[email protected]>
  • Loading branch information
Fridolin Pokorny committed Dec 18, 2022
1 parent c6f8b58 commit bf15c00
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
67 changes: 67 additions & 0 deletions tuf/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright New York University and the TUF contributors
# SPDX-License-Identifier: MIT OR Apache-2.0

"""Public API for ``tuf.api``."""

from .metadata import (
BaseFile,
DelegatedRole,
Delegations,
Key,
MetaFile,
Metadata,
Role,
Root,
SPECIFICATION_VERSION,
Signed,
Snapshot,
SuccinctRoles,
TOP_LEVEL_ROLE_NAMES,
TargetFile,
Targets,
Timestamp,
)

from .exceptions import (
BadVersionNumberError,
DownloadError,
DownloadHTTPError,
DownloadLengthMismatchError,
EqualVersionNumberError,
ExpiredMetadataError,
LengthOrHashMismatchError,
RepositoryError,
SlowRetrievalError,
StorageError,
UnsignedMetadataError,
)

__all__ = [
"SPECIFICATION_VERSION",
"TOP_LEVEL_ROLE_NAMES",
BadVersionNumberError.__name__,
BaseFile.__name__,
DelegatedRole.__name__,
Delegations.__name__,
DownloadError.__name__,
DownloadHTTPError.__name__,
DownloadLengthMismatchError.__name__,
EqualVersionNumberError.__name__,
ExpiredMetadataError.__name__,
Key.__name__,
LengthOrHashMismatchError.__name__,
MetaFile.__name__,
Metadata.__name__,
RepositoryError.__name__,
Role.__name__,
Root.__name__,
Signed.__name__,
SlowRetrievalError.__name__,
Snapshot.__name__,
StorageError.__name__,
SuccinctRoles.__name__,
TargetFile.__name__,
Targets.__name__,
Timestamp.__name__,
UnsignedMetadataError.__name__,
]
7 changes: 5 additions & 2 deletions tuf/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

#### Repository errors ####

# pylint: disable=unused-import
from securesystemslib.exceptions import StorageError
from securesystemslib.exceptions import StorageError as _SecureSystemsLibStorageError


class RepositoryError(Exception):
Expand Down Expand Up @@ -41,6 +40,10 @@ class LengthOrHashMismatchError(RepositoryError):
"""An error while checking the length and hash values of an object."""


class StorageError(_SecureSystemsLibStorageError, RepositoryError):
"""An error raised when a file cannot be read or written."""


#### Download Errors ####


Expand Down
12 changes: 12 additions & 0 deletions tuf/api/serialization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import TYPE_CHECKING

from tuf.api.exceptions import RepositoryError
from .json import CanonicalJSONSerializer

if TYPE_CHECKING:
# pylint: disable=cyclic-import
Expand Down Expand Up @@ -57,3 +58,14 @@ class SignedSerializer(metaclass=abc.ABCMeta):
def serialize(self, signed_obj: "Signed") -> bytes:
"""Serialize Signed object to bytes."""
raise NotImplementedError


__all__ = [
CanonicalJSONSerializer.__name__,
DeserializationError.__name__,
MetadataDeserializer.__name__,
MetadataSerializer.__name__,
RepositoryError.__name__,
SerializationError.__name__,
SignedSerializer.__name__,
]
6 changes: 6 additions & 0 deletions tuf/ngclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
from tuf.ngclient.config import UpdaterConfig
from tuf.ngclient.fetcher import FetcherInterface
from tuf.ngclient.updater import Updater

__all__ = [
FetcherInterface.__name__,
Updater.__name__,
UpdaterConfig.__name__,
]

0 comments on commit bf15c00

Please sign in to comment.