@@ -104,6 +104,14 @@ class Metadata(Generic[T]):
104104 ``[Root]`` is not validated at runtime (as pure annotations are not available
105105 then).
106106
107+ New Metadata instances can be created from scratch with::
108+
109+ one_day = datetime.utcnow() + timedelta(days=1)
110+ timestamp = Metadata(Timestamp(expires=one_day))
111+
112+ Apart from ``expires`` all of the arguments to the inner constructors have
113+ reasonable default values for new metadata.
114+
107115 *All parameters named below are not just constructor arguments but also
108116 instance attributes.*
109117
@@ -112,6 +120,7 @@ class Metadata(Generic[T]):
112120 ``Snapshot``, ``Timestamp`` or ``Root``.
113121 signatures: Ordered dictionary of keyids to ``Signature`` objects, each
114122 signing the canonical serialized representation of ``signed``.
123+ Default is an empty dictionary.
115124 unrecognized_fields: Dictionary of all attributes that are not managed
116125 by TUF Metadata API. These fields are NOT signed and it's preferable
117126 if unrecognized fields are added to the Signed derivative classes.
@@ -444,9 +453,11 @@ class Signed(metaclass=abc.ABCMeta):
444453 instance attributes.*
445454
446455 Args:
447- version: Metadata version number.
448- spec_version: Supported TUF specification version number.
449- expires: Metadata expiry date.
456+ version: Metadata version number. If None, then 1 is assigned.
457+ spec_version: Supported TUF specification version. If None, then the
458+ version currently supported by the library is assigned.
459+ expires: Metadata expiry date. If None, then current date and time is
460+ assigned.
450461 unrecognized_fields: Dictionary of all attributes that are not managed
451462 by TUF Metadata API
452463
@@ -825,13 +836,17 @@ class Root(Signed):
825836 Parameters listed below are also instance attributes.
826837
827838 Args:
828- version: Metadata version number.
829- spec_version: Supported TUF specification version number.
830- expires: Metadata expiry date.
839+ version: Metadata version number. Default is 1.
840+ spec_version: Supported TUF specification version. Default is the
841+ version currently supported by the library.
842+ expires: Metadata expiry date. Default is current date and time.
831843 keys: Dictionary of keyids to Keys. Defines the keys used in ``roles``.
844+ Default is empty dictionary.
832845 roles: Dictionary of role names to Roles. Defines which keys are
833- required to sign the metadata for a specific role.
846+ required to sign the metadata for a specific role. Default is
847+ a dictionary of top level roles without keys and threshold of 1.
834848 consistent_snapshot: ``True`` if repository supports consistent snapshots.
849+ Default is True.
835850 unrecognized_fields: Dictionary of all attributes that are not managed
836851 by TUF Metadata API
837852
@@ -1122,12 +1137,14 @@ class Timestamp(Signed):
11221137 instance attributes.*
11231138
11241139 Args:
1125- version: Metadata version number.
1126- spec_version: Supported TUF specification version number.
1127- expires: Metadata expiry date.
1140+ version: Metadata version number. Default is 1.
1141+ spec_version: Supported TUF specification version. Default is the
1142+ version currently supported by the library.
1143+ expires: Metadata expiry date. Default is current date and time.
11281144 unrecognized_fields: Dictionary of all attributes that are not managed
11291145 by TUF Metadata API
1130- snapshot_meta: Meta information for snapshot metadata.
1146+ snapshot_meta: Meta information for snapshot metadata. Default is a
1147+ MetaFile with version 1.
11311148
11321149 Raises:
11331150 ValueError: Invalid arguments.
@@ -1183,12 +1200,14 @@ class Snapshot(Signed):
11831200 instance attributes.*
11841201
11851202 Args:
1186- version: Metadata version number.
1187- spec_version: Supported TUF specification version number.
1188- expires: Metadata expiry date.
1203+ version: Metadata version number. Default is 1.
1204+ spec_version: Supported TUF specification version. Default is the
1205+ version currently supported by the library.
1206+ expires: Metadata expiry date. Default is current date and time.
11891207 unrecognized_fields: Dictionary of all attributes that are not managed
11901208 by TUF Metadata API
1191- meta: Dictionary of target metadata filenames to ``MetaFile`` objects.
1209+ meta: Dictionary of targets filenames to ``MetaFile`` objects. Default
1210+ is a dictionary with a Metafile for "snapshot.json" version 1.
11921211
11931212 Raises:
11941213 ValueError: Invalid arguments.
@@ -1650,12 +1669,14 @@ class Targets(Signed):
16501669 instance attributes.*
16511670
16521671 Args:
1653- version: Metadata version number.
1654- spec_version: Supported TUF specification version number.
1655- expires: Metadata expiry date.
1656- targets: Dictionary of target filenames to TargetFiles
1672+ version: Metadata version number. Default is 1.
1673+ spec_version: Supported TUF specification version. Default is the
1674+ version currently supported by the library.
1675+ expires: Metadata expiry date. Default is current date and time.
1676+ targets: Dictionary of target filenames to TargetFiles. Default is an
1677+ empty dictionary.
16571678 delegations: Defines how this Targets delegates responsibility to other
1658- Targets Metadata files.
1679+ Targets Metadata files. Default is None.
16591680 unrecognized_fields: Dictionary of all attributes that are not managed
16601681 by TUF Metadata API
16611682
0 commit comments