name: Restore (full)

args:
  -
    name: backup.blob
    label: Backup to restore
    input_type: text
    python_type: str
    placeholder: Enter blob id
    meta:
      seals:
        - urn/seal/user/svnplace/Backup - Full
        - "{repo.seal.api_id}"
      allow_write: false


role:
  policies:
    - urn/api/policy/svnplace/Allow Everything
  parents:
    - urn/api/role/{user.username}/
    - urn/api/role/svnplace/Backup Restorer

jobs:

  setup:
    steps:
      -
        name: Setup
        python: |
          blob = '{escape(backup.blob)}'
          print(f'Restoring backup {{blob} to {repo.urn}')
          from datetime import datetime, timezone
          import os
          import subprocess
          from api_api import API

          api = API('https://svnplace.com/api', ['~/.svnplace/config'])

          root = api.repos.create_reporepository(
              repo='{repo.urn}',
              kind='BackupRestoration',
              name='Restore$'+datetime.now(timezone.utc).strftime('%Y%m%d_%H%M.%f'),
              process='urn/process/process/svnplace/processes/12/repo_from_backup.yaml',
              input={{'blob': blob},
          )
