• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Objects-Related APIs
  5. POST Object restore

POST Object restore

API Description

You can use this API to restore an object in the OBS Cold storage class in a specified bucket.

Method Definition

ObsClient.restoreObject(bucketName, objectKey, days, tier, versionId)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

days

int

Mandatory

Retention period of the restored object, in days. The value ranges from 1 to 30.

tier

str

Optional

Restore option. Possible values are:

  • Expedited: Data can be restored within 1 to 5 minutes.
  • Standard: Data can be restored within 3 to 5 hours. This is the default value.
  • Bulk: Data can be restored within 5 to 12 hours.

versionId

str

Optional

Version ID of the to-be-restored object in the OBS Cold storage class

Returned Result

Type

Description

GetResult

SDK common result object

NOTE:

If GetResult.status is 202, the object is being restored. If GetResult.status is 200, the object has been restored.

Sample Code

try:
    resp = obsClient.restoreObject('bucketname', 'objectkey', 1, 'Expedited') 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())