AWS SDK를 사용하여 Amazon S3 Glacier 작업 설명 - AWS SDK 코드 예제

AWS문서 AWS SDK 예제 리포지토리에 더 많은 SDK 예제가 있습니다. GitHub

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK를 사용하여 Amazon S3 Glacier 작업 설명

다음 코드 예시에서는 Amazon S3 Glacier 작업을 설명하는 방법을 보여줍니다.

CLI
AWS CLI

다음 명령은 my-vault라는 볼트의 인벤토리 검색 작업에 대한 정보를 검색합니다.

aws glacier describe-job --account-id - --vault-name my-vault --job-id zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW

출력:

{ "InventoryRetrievalParameters": { "Format": "JSON" }, "VaultARN": "arn:aws:glacier:us-west-2:0123456789012:vaults/my-vault", "Completed": false, "JobId": "zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW", "Action": "InventoryRetrieval", "CreationDate": "2015-07-17T20:23:41.616Z", "StatusCode": "InProgress" }

작업 ID는 aws glacier initiate-jobaws glacier list-jobs의 출력에서 찾을 수 있습니다. Amazon Glacier에서는 작업을 수행할 때 계정 ID 인수가 필요하지만 하이픈을 사용하여 사용 중인 계정을 지정할 수 있습니다.

  • API에 대한 자세한 내용은 명령 참조를 참조하십시오 DescribeJob. AWS CLI

Python
SDK for Python (Boto3)
참고

자세한 내용은 에서 확인할 수 GitHub 있습니다. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

class GlacierWrapper: """Encapsulates Amazon S3 Glacier API operations.""" def __init__(self, glacier_resource): """ :param glacier_resource: A Boto3 Amazon S3 Glacier resource. """ self.glacier_resource = glacier_resource @staticmethod def get_job_status(job): """ Gets the status of a job. :param job: The job to query. :return: The current status of the job. """ try: job.load() logger.info( "Job %s is performing action %s and has status %s.", job.id, job.action, job.status_code, ) except ClientError: logger.exception("Couldn't get status for job %s.", job.id) raise else: return job.status_code
  • API에 대한 자세한 내용은 파이썬용 AWS SDK (Boto3) API 레퍼런스를 참조하십시오 DescribeJob.