Glacier - Update impl cov (#4381)

This commit is contained in:
Bert Blommers 2021-10-08 10:05:01 +00:00 committed by GitHub
parent 0b9f5adec2
commit bb2796e949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 12 deletions

View File

@ -1936,7 +1936,7 @@
## glacier
<details>
<summary>21% implemented</summary>
<summary>24% implemented</summary>
- [ ] abort_multipart_upload
- [ ] abort_vault_lock
@ -1951,7 +1951,7 @@
- [X] describe_job
- [ ] describe_vault
- [ ] get_data_retrieval_policy
- [ ] get_job_output
- [X] get_job_output
- [ ] get_vault_access_policy
- [ ] get_vault_lock
- [ ] get_vault_notifications

View File

@ -224,6 +224,13 @@ class GlacierBackend(BaseBackend):
vault = self.get_vault(vault_name)
return vault.list_jobs()
def get_job_output(self, vault_name, job_id):
vault = self.get_vault(vault_name)
if vault.job_ready(job_id):
return vault.get_job_output(job_id)
else:
return None
def upload_archive(self, vault_name, body, description):
vault = self.get_vault(vault_name)
return vault.create_archive(body, description)

View File

@ -162,14 +162,12 @@ class GlacierResponse(BaseResponse):
def _vault_jobs_output_response(self, request, full_url, headers):
vault_name = full_url.split("/")[-4]
job_id = full_url.split("/")[-2]
vault = self.glacier_backend.get_vault(vault_name)
if vault.job_ready(job_id):
output = vault.get_job_output(job_id)
if isinstance(output, dict):
headers["content-type"] = "application/json"
return 200, headers, json.dumps(output)
else:
headers["content-type"] = "application/octet-stream"
return 200, headers, output
else:
output = self.glacier_backend.get_job_output(vault_name, job_id)
if output is None:
return 404, headers, "404 Not Found"
if isinstance(output, dict):
headers["content-type"] = "application/json"
return 200, headers, json.dumps(output)
else:
headers["content-type"] = "application/octet-stream"
return 200, headers, output