def initiate(session: Session, instance: Instance, backup_path: str) -> Restore: """Initiate a Tamr restore. Args: session: Tamr session instance: Tamr instance backup_path: Path to the backup Returns: Initiated restore Raises: restore.InvalidOperation: If attempting an invalid operation """ url = URL(instance=instance, path="instance/restore") r = session.post(str(url), data=backup_path) if r.status_code == 400: raise InvalidOperation(str(url), r.json()["message"]) return _from_json(url, response.successful(r).json())
def initiate(session: Session, instance: Instance) -> Backup: """Initiate a Tamr backup. Args: session: Tamr session instance: Tamr instance Returns: Initiated backup Raises: backup.InvalidOperation: If attempting an invalid operation """ url = URL(instance=instance, path="backups") r = session.post(str(url)) if r.status_code == 400: raise InvalidOperation(str(url), r.json()["message"]) data = response.successful(r).json() return _from_json( URL(instance=instance, path=f'backups/{data["relativeId"]}'), data)
def cancel(session: Session, backup: Backup) -> Backup: """Cancel a Tamr backup. Args: session: Tamr session backup: A Tamr backup Returns: Canceled backup Raises: backup.NotFound: If no backup found at the specified URL backup.InvalidOperation: If attempting an invalid operation """ cancel_url = f"{backup.url}:cancel" r = session.post(cancel_url) if r.status_code == 404: raise NotFound(cancel_url) if r.status_code == 400: raise InvalidOperation(cancel_url, r.json()["message"]) return _from_json(backup.url, response.successful(r).json())
def cancel(session: Session, restore: Restore) -> Restore: """Cancel a Tamr restore. Args: session: Tamr session restore: A Tamr restore Returns: Canceled restore Raises: restore.NotFound: If no backup file found at the specified path restore.InvalidOperation: If attempting an invalid operation """ cancel_url = f"{restore.url}:cancel" r = session.post(cancel_url) if r.status_code == 404: raise NotFound(cancel_url) if r.status_code == 400: raise InvalidOperation(cancel_url, r.json()["message"]) return _from_json(restore.url, response.successful(r).json())