def user(self): response = self.client.get(routes.ACCOUNT_DETAILS) if response.status_code == status.HTTP_401_UNAUTHORIZED: raise exc.AuthRequiredError() if response.status_code != status.HTTP_200_OK: raise exc.UserRetrievingError(response.status_code) return response.json()
def delete_backup(self, backup_hash): response = self.client.post('{}{}'.format(routes.BACKUP_DELETE, backup_hash)) if response.status_code == status.HTTP_400_BAD_REQUEST: raise exc.AuthRequiredError() elif response.status_code != status.HTTP_201_CREATED: raise exc.BackupDeletingError(response.status_code)
def backups(self): response = self.client.get(routes.BACKUPS) if response.status_code == status.HTTP_401_UNAUTHORIZED: raise exc.AuthRequiredError() elif response.status_code != status.HTTP_200_OK: raise exc.ReadingBackupsError(response.status_code) return response.json()
def download_backup(self, backup_hash): response = self.client.get('{}{}'.format(routes.BACKUP_DETAILS, backup_hash)) if response.status_code == status.HTTP_401_UNAUTHORIZED: raise exc.AuthRequiredError() elif response.status_code != status.HTTP_200_OK: raise exc.BackupDownloadingError(response.status_code) return response.json()
def upload_backup(self, backup): response = self.client.post(routes.BACKUP_CREATE, data=backup) if response.status_code == status.HTTP_401_UNAUTHORIZED: raise exc.AuthRequiredError() if response.status_code == status.HTTP_400_BAD_REQUEST: raise exc.BackupAlreadyExistsError() elif response.status_code != status.HTTP_201_CREATED: raise exc.BackupUploadingError(response.status_code)