Exemple #1
0
 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()
Exemple #2
0
 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)
Exemple #3
0
 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()
Exemple #4
0
 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()
Exemple #5
0
 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)