Merge pull request #1620 from lukpueh/misc-metadata-api-docs

Add missing method args docs in metadata API
This commit is contained in:
lukpueh 2021-10-20 15:51:07 +02:00 committed by GitHub
commit 0cf6ba2258
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -575,9 +575,11 @@ def to_securesystemslib_key(self) -> Dict[str, Any]:
@classmethod
def from_securesystemslib_key(cls, key_dict: Dict[str, Any]) -> "Key":
"""
Creates a Key object from a securesystemlib key dict representation
"""Creates a Key object from a securesystemlib key dict representation
removing the private key from keyval.
Args:
key_dict: A key in securesystemlib dict representation.
"""
key_meta = sslib_keys.format_keyval_to_metadata(
key_dict["keytype"],
@ -762,10 +764,13 @@ def to_dict(self) -> Dict[str, Any]:
)
return root_dict
# Update key for a role.
def add_key(self, role: str, key: Key) -> None:
"""Adds new signing key for delegated role 'role'.
Args:
role: The name of the role, for which 'key' is added.
key: The signing key to be added for 'role'.
Raises:
ValueError: If 'role' doesn't exist.
"""
@ -777,6 +782,10 @@ def add_key(self, role: str, key: Key) -> None:
def remove_key(self, role: str, keyid: str) -> None:
"""Removes key from 'role' and updates the key store.
Args:
role: The name of the role, for which a signing key is removed.
key: The identifier of the key to be removed for 'role'.
Raises:
ValueError: If 'role' doesn't exist or if 'role' doesn't include
the key.
@ -1151,6 +1160,10 @@ def is_delegated_path(self, target_filepath: str) -> bool:
supported as target path separator. Leading separators are not handled
as special cases (see `TUF specification on targetpath
<https://theupdateframework.github.io/specification/latest/#targetpath>`_).
Args:
target_filepath: URL path to a target file, relative to a base
targets URL.
"""
if self.path_hash_prefixes is not None:
@ -1440,6 +1453,10 @@ def update(self, fileinfo: TargetFile) -> None:
def add_key(self, role: str, key: Key) -> None:
"""Adds new signing key for delegated role 'role'.
Args:
role: The name of the role, for which 'key' is added.
key: The signing key to be added for 'role'.
Raises:
ValueError: If there are no delegated roles or if 'role' is not
delegated by this Target.
@ -1453,6 +1470,10 @@ def remove_key(self, role: str, keyid: str) -> None:
"""Removes key from delegated role 'role' and updates the delegations
key store.
Args:
role: The name of the role, for which a signing key is removed.
key: The identifier of the key to be removed for 'role'.
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'.