Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document public API for tuf.api and tuf.ngclient #2234

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tuf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
"""TUF
"""

import tuf.api
import tuf.ngclient

# This value is used in the requests user agent.
__version__ = "2.0.0"
__all__ = [
tuf.api.__name__,
tuf.ngclient.__name__,
]
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__,
]
7 changes: 7 additions & 0 deletions tuf/ngclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
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__,
]