Targets class

class Targets(version, spec_version, expires, targets, delegations=None, unrecognized_fields=None)

A container for the signed part of targets metadata.

Targets contains verifying information about target files and also delegates responsibility to other Targets roles.

All parameters named below are not just constructor arguments but also instance attributes.

Parameters
  • version (int) – The metadata version number.

  • spec_version (str) – The supported TUF specification version number.

  • expires (datetime.datetime) – The metadata expiry date.

  • targets (Dict[str, TargetFile]) – A dictionary of target filenames to TargetFiles

  • delegations (Optional[Delegations]) – Defines how this Targets delegates responsibility to other Targets Metadata files.

  • unrecognized_fields (Optional[Mapping[str, Any]]) – Dictionary of all unrecognized fields.

Return type

None

add_key(role, key)

Adds new signing key for delegated role ‘role’.

Raises

ValueError – If there are no delegated roles or if ‘role’ is not delegated by this Target.

Parameters
  • role (str) –

  • key (Key) –

Return type

None

remove_key(role, keyid)

Removes key from delegated role ‘role’ and updates the delegations key store.

Raises

ValueError – If there are no delegated roles or if ‘role’ is not delegated by this Target or if key is not used by ‘role’.

Parameters
  • role (str) –

  • keyid (str) –

Return type

None

update(fileinfo)

Assigns passed target file info to meta dict.

Parameters

fileinfo (TargetFile) –

Return type

None