Skip to content

Commit

Permalink
Metadata API: Document constructor default arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
Jussi Kukkonen committed Mar 24, 2022
1 parent 96b2cd4 commit 8148efb
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ class Metadata(Generic[T]):
``[Root]`` is not validated at runtime (as pure annotations are not available
then).
New Metadata instances can created from scratch with::
one_day = datetime.utcnow() + timedelta(days=1)
timestamp = Metadata(Timestamp(expires=one_day))
Apart from ``expires`` all of the arguments to the inner constructors have
reasonable default values for new metadata.
*All parameters named below are not just constructor arguments but also
instance attributes.*
Expand All @@ -112,6 +120,7 @@ class Metadata(Generic[T]):
``Snapshot``, ``Timestamp`` or ``Root``.
signatures: Ordered dictionary of keyids to ``Signature`` objects, each
signing the canonical serialized representation of ``signed``.
Default is an empty dictionary.
unrecognized_fields: Dictionary of all attributes that are not managed
by TUF Metadata API. These fields are NOT signed and it's preferable
if unrecognized fields are added to the Signed derivative classes.
Expand Down Expand Up @@ -444,9 +453,10 @@ class Signed(metaclass=abc.ABCMeta):
instance attributes.*
Args:
version: Metadata version number.
spec_version: Supported TUF specification version number.
expires: Metadata expiry date.
version: Metadata version number. Default is 1.
spec_version: Supported TUF specification version. Default is the
version currently supported by the library.
expires: Metadata expiry date. Default is current date and time.
unrecognized_fields: Dictionary of all attributes that are not managed
by TUF Metadata API
Expand Down Expand Up @@ -825,13 +835,17 @@ class Root(Signed):
Parameters listed below are also instance attributes.
Args:
version: Metadata version number.
spec_version: Supported TUF specification version number.
expires: Metadata expiry date.
version: Metadata version number. Default is 1.
spec_version: Supported TUF specification version. Default is the
version currently supported by the library.
expires: Metadata expiry date. Default is current date and time.
keys: Dictionary of keyids to Keys. Defines the keys used in ``roles``.
Default is empty dictionary.
roles: Dictionary of role names to Roles. Defines which keys are
required to sign the metadata for a specific role.
required to sign the metadata for a specific role. Default is
a dictionary of top level roles without keys and threshold of 1.
consistent_snapshot: ``True`` if repository supports consistent snapshots.
Default is True.
unrecognized_fields: Dictionary of all attributes that are not managed
by TUF Metadata API
Expand Down Expand Up @@ -1122,12 +1136,14 @@ class Timestamp(Signed):
instance attributes.*
Args:
version: Metadata version number.
spec_version: Supported TUF specification version number.
expires: Metadata expiry date.
version: Metadata version number. Default is 1.
spec_version: Supported TUF specification version. Default is the
version currently supported by the library.
expires: Metadata expiry date. Default is current date and time.
unrecognized_fields: Dictionary of all attributes that are not managed
by TUF Metadata API
snapshot_meta: Meta information for snapshot metadata.
snapshot_meta: Meta information for snapshot metadata. Default is a
MetaFile with version 1.
Raises:
ValueError: Invalid arguments.
Expand Down Expand Up @@ -1183,12 +1199,14 @@ class Snapshot(Signed):
instance attributes.*
Args:
version: Metadata version number.
spec_version: Supported TUF specification version number.
expires: Metadata expiry date.
version: Metadata version number. Default is 1.
spec_version: Supported TUF specification version. Default is the
version currently supported by the library.
expires: Metadata expiry date. Default is current date and time.
unrecognized_fields: Dictionary of all attributes that are not managed
by TUF Metadata API
meta: Dictionary of target metadata filenames to ``MetaFile`` objects.
Default is a dictionary with a Metafile for "snapshot.json".
Raises:
ValueError: Invalid arguments.
Expand Down Expand Up @@ -1650,12 +1668,14 @@ class Targets(Signed):
instance attributes.*
Args:
version: Metadata version number.
spec_version: Supported TUF specification version number.
expires: Metadata expiry date.
targets: Dictionary of target filenames to TargetFiles
version: Metadata version number. Default is 1.
spec_version: Supported TUF specification version. Default is the
version currently supported by the library.
expires: Metadata expiry date. Default is current date and time.
targets: Dictionary of target filenames to TargetFiles. Default is an
empty dictionary.
delegations: Defines how this Targets delegates responsibility to other
Targets Metadata files.
Targets Metadata files. Default is None.
unrecognized_fields: Dictionary of all attributes that are not managed
by TUF Metadata API
Expand Down

0 comments on commit 8148efb

Please sign in to comment.