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

Make system time optional in provision and restore #105

Merged
merged 1 commit into from
Nov 26, 2023
Merged
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
10 changes: 8 additions & 2 deletions nethsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,15 @@
self,
unlock_passphrase: str,
admin_passphrase: str,
system_time: Union[str, datetime],
system_time: Optional[Union[str, datetime]] = None,
) -> None:
from .client.components.schema.provision_request_data import (
ProvisionRequestDataDict,
)

if system_time is None:
system_time = datetime.now(timezone.utc)

Check warning on line 550 in nethsm/__init__.py

View check run for this annotation

Codecov / codecov/patch

nethsm/__init__.py#L550

Added line #L550 was not covered by tests

request_body = ProvisionRequestDataDict(
unlockPassphrase=unlock_passphrase,
adminPassphrase=admin_passphrase,
Expand Down Expand Up @@ -1413,13 +1416,16 @@
)
return response.response.data

def restore(self, backup: Bytes, passphrase: str, time: datetime) -> None:
def restore(self, backup: Bytes, passphrase: str, time: Optional[datetime]) -> None:
try:
from .client.components.schema.restore_request import (
ArgumentsDict,
RestoreRequestDict,
)

if not time:
time = datetime.now(timezone.utc)

Check warning on line 1427 in nethsm/__init__.py

View check run for this annotation

Codecov / codecov/patch

nethsm/__init__.py#L1427

Added line #L1427 was not covered by tests

body = RestoreRequestDict(
arguments=ArgumentsDict(backupPassphrase=passphrase, systemTime=time),
backup_file=backup,
Expand Down