python sdk api reference - huawei cloud...obs is the global namespace of obs python sdk. all data...

144
Object Storage Service Python SDK API Reference Issue 10 Date 2019-09-05 HUAWEI TECHNOLOGIES CO., LTD.

Upload: others

Post on 04-Jun-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Object Storage Service

Python SDK API Reference

Issue 10

Date 2019-09-05

HUAWEI TECHNOLOGIES CO., LTD.

Page 2: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Copyright © Huawei Technologies Co., Ltd. 2020. All rights reserved.

No part of this document may be reproduced or transmitted in any form or by any means without priorwritten consent of Huawei Technologies Co., Ltd. Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei andthe customer. All or part of the products, services and features described in this document may not bewithin the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,information, and recommendations in this document are provided "AS IS" without warranties, guaranteesor representations of any kind, either express or implied.

The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. i

Page 3: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Contents

1 Overview....................................................................................................................................1

2 Initialization..............................................................................................................................22.1 Namespace................................................................................................................................................................................ 22.2 Initializing an Instance of ObsClient.................................................................................................................................22.3 Initializing an Instance of BucketClient........................................................................................................................... 52.4 Initializing Logs........................................................................................................................................................................ 52.5 Request Parameters................................................................................................................................................................62.6 SDK Common Result Objects.............................................................................................................................................. 6

3 Pre-defined Constants............................................................................................................ 83.1 Permission Types..................................................................................................................................................................... 83.2 Authorizable User Groups.................................................................................................................................................... 93.3 Pre-defined Access Control Policies.................................................................................................................................. 93.4 Storage Classes...................................................................................................................................................................... 103.5 Restore Options..................................................................................................................................................................... 103.6 Event Types............................................................................................................................................................................. 10

4 Data Types...............................................................................................................................124.1 Log Configuration Parameter........................................................................................................................................... 124.2 Additional Header in PUT Bucket....................................................................................................................................124.3 Extended Permissions.......................................................................................................................................................... 134.4 Response Result of GET Buckets......................................................................................................................................134.5 Owner Info.............................................................................................................................................................................. 144.6 Initiator Info............................................................................................................................................................................ 144.7 Bucket Info.............................................................................................................................................................................. 144.8 Response Result of GET Objects...................................................................................................................................... 154.9 Object in a Bucket................................................................................................................................................................ 164.10 Object Name Prefix............................................................................................................................................................164.11 Request Parameter of GET Object versions...............................................................................................................164.12 Response Result of GET Object versions.................................................................................................................... 174.13 Versioning Object in a Bucket........................................................................................................................................ 184.14 Versioning Delete Marker in a Bucket........................................................................................................................ 194.15 Response Header in GET Object versions.................................................................................................................. 194.16 Request Parameter of List Multipart uploads...........................................................................................................20

Object Storage ServicePython SDK API Reference Contents

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. ii

Page 4: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.17 Response Result of List Multipart uploads................................................................................................................ 214.18 Multipart Upload in a Bucket.........................................................................................................................................224.19 Response Result of GET Bucket metadata.................................................................................................................234.20 Response Result of GET Bucket location.................................................................................................................... 234.21 Response Result of GET Bucket storage..................................................................................................................... 244.22 Response Result of GET Bucket quota........................................................................................................................ 244.23 Response Result of GET Bucket storagePolicy..........................................................................................................244.24 ACL.......................................................................................................................................................................................... 254.25 Grantees' Permission Information................................................................................................................................ 254.26 Grantee.................................................................................................................................................................................. 264.27 Log Configuration Info..................................................................................................................................................... 274.28 Bucket Policy........................................................................................................................................................................ 274.29 Bucket Lifecycle Settings.................................................................................................................................................. 274.30 Lifecycle Rule of a Bucket................................................................................................................................................ 284.31 Object Transition Policy.................................................................................................................................................... 304.32 Expiration Time of an Object......................................................................................................................................... 304.33 Transition Policy of a Noncurrent Object Version................................................................................................... 314.34 Expiration Time of a Noncurrent Object Version.................................................................................................... 324.35 UTC Time Object.................................................................................................................................................................324.36 Response Result of GET Bucket lifecycle.................................................................................................................... 324.37 Website Hosting Settings of a Bucket......................................................................................................................... 334.38 Redirection Rule Applying to all Requests................................................................................................................. 334.39 Error Page Settings............................................................................................................................................................ 344.40 Default Page Settings....................................................................................................................................................... 344.41 Redirection Rule.................................................................................................................................................................. 354.42 Matching Condition of a Redirection Rule................................................................................................................ 354.43 Details About a Redirection Request........................................................................................................................... 364.44 Bucket CORS Rules.............................................................................................................................................................374.45 Bucket Message Notification Settings.........................................................................................................................384.46 Event Notification Settings..............................................................................................................................................384.47 FunctionGraph Settings.................................................................................................................................................... 394.48 Filtering Rule........................................................................................................................................................................ 404.49 Additional Parameter of an OPTIONS Request....................................................................................................... 414.50 Response Result of an OPTIONS Request..................................................................................................................414.51 Bucket Tag Set..................................................................................................................................................................... 424.52 Bucket Tag............................................................................................................................................................................ 424.53 Response Result of Initiate Multipart Upload.......................................................................................................... 434.54 SSE-C Header....................................................................................................................................................................... 434.55 SSE-KMS Header.................................................................................................................................................................444.56 Response Result of PUT Part.......................................................................................................................................... 444.57 Response Result of PUT Part - Copy............................................................................................................................ 444.58 Response Result of List Parts..........................................................................................................................................45

Object Storage ServicePython SDK API Reference Contents

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. iii

Page 5: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.59 Uploaded Part...................................................................................................................................................................... 464.60 Request Parameter of Complete Multipart Upload................................................................................................464.61 Part to Be Combined......................................................................................................................................................... 474.62 Response Result of Complete Multipart Upload..................................................................................................... 474.63 Response Result of Obtain Object Metadata........................................................................................................... 484.64 Request Parameter of DELETE Objects....................................................................................................................... 494.65 To-Be-Deleted Object........................................................................................................................................................ 504.66 Response Result of DELETE Objects.............................................................................................................................504.67 Successfully Deleted Object............................................................................................................................................ 504.68 Object Failed to Be Deleted............................................................................................................................................ 514.69 Response Result of DELETE Object.............................................................................................................................. 514.70 Additional Headers in PUT Object - Copy................................................................................................................. 514.71 Response Result of PUT Object - Copy....................................................................................................................... 534.72 Additional Headers in PUT Object................................................................................................................................544.73 Response Result of PUT Object..................................................................................................................................... 554.74 Additional Headers in Resumable Upload.................................................................................................................564.75 Additional Headers in Append Object.........................................................................................................................574.76 Message Body in Append Object.................................................................................................................................. 584.77 Response Result of Append Object.............................................................................................................................. 594.78 Additional Request Parameter of GET Object.......................................................................................................... 604.79 Additional Headers in GET Object................................................................................................................................ 604.80 Response Result of GET Object..................................................................................................................................... 62

5 Bucket-Related APIs..............................................................................................................645.1 PUT Bucket.............................................................................................................................................................................. 645.2 GET Buckets............................................................................................................................................................................ 665.3 HEAD Bucket.......................................................................................................................................................................... 675.4 DELETE Bucket....................................................................................................................................................................... 685.5 GET Objects.............................................................................................................................................................................685.6 GET Object versions............................................................................................................................................................. 705.7 List Multipart uploads......................................................................................................................................................... 715.8 Obtain Bucket Metadata.................................................................................................................................................... 735.9 GET Bucket location............................................................................................................................................................. 745.10 GET Bucket storageinfo.................................................................................................................................................... 755.11 PUT Bucket quota...............................................................................................................................................................765.12 GET Bucket quota............................................................................................................................................................... 775.13 PUT Bucket Storage Policy.............................................................................................................................................. 785.14 GET Bucket storagePolicy................................................................................................................................................ 785.15 Set Bucket ACL.................................................................................................................................................................... 795.16 GET Bucket acl..................................................................................................................................................................... 815.17 PUT Bucket logging........................................................................................................................................................... 825.18 GET Bucket logging........................................................................................................................................................... 835.19 PUT Bucket policy...............................................................................................................................................................84

Object Storage ServicePython SDK API Reference Contents

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. iv

Page 6: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.20 GET Bucket policy............................................................................................................................................................... 855.21 DELETE Bucket policy........................................................................................................................................................ 865.22 PUT Bucket lifecycle.......................................................................................................................................................... 865.23 GET Bucket lifecycle...........................................................................................................................................................875.24 DELETE Bucket lifecycle....................................................................................................................................................885.25 PUT Bucket website........................................................................................................................................................... 895.26 GET Bucket website........................................................................................................................................................... 905.27 DELETE Bucket website.................................................................................................................................................... 925.28 PUT Bucket versioning...................................................................................................................................................... 925.29 GET Bucket versioning...................................................................................................................................................... 935.30 PUT Bucket cors.................................................................................................................................................................. 945.31 GET Bucket cors.................................................................................................................................................................. 955.32 DELETE Bucket cors........................................................................................................................................................... 965.33 PUT Bucket notification....................................................................................................................................................975.34 GET Bucket notification.................................................................................................................................................... 985.35 PUT Bucket tagging.........................................................................................................................................................1005.36 GET Bucket tagging......................................................................................................................................................... 1015.37 DELETE Bucket tagging..................................................................................................................................................102

6 Objects-Related APIs.......................................................................................................... 1036.1 Uploading an Object......................................................................................................................................................... 1036.2 PUT File.................................................................................................................................................................................. 1056.3 Append Object..................................................................................................................................................................... 1066.4 GET Object............................................................................................................................................................................ 1086.5 PUT Object - Copy..............................................................................................................................................................1106.6 DELETE Object..................................................................................................................................................................... 1116.7 DELETE Objects................................................................................................................................................................... 1126.8 Obtain Object Metadata.................................................................................................................................................. 1136.9 PUT Object ACL................................................................................................................................................................... 1156.10 GET Object acl...................................................................................................................................................................1166.11 Initiate Multipart Upload.............................................................................................................................................. 1176.12 PUT Part.............................................................................................................................................................................. 1196.13 PUT Part - Copy................................................................................................................................................................ 1216.14 List Parts.............................................................................................................................................................................. 1236.15 Complete Multipart Upload......................................................................................................................................... 1246.16 DELETE Multipart upload.............................................................................................................................................. 1256.17 POST Object restore........................................................................................................................................................ 126

7 Other APIs.............................................................................................................................1287.1 Create Signed URL............................................................................................................................................................. 1287.2 Generating Browser-Based Upload Parameters with Authentication Information......................................1307.3 Upload File (Resumable Upload)..................................................................................................................................1327.4 Download File (Resumable Download)......................................................................................................................134

Object Storage ServicePython SDK API Reference Contents

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. v

Page 7: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

A Change History....................................................................................................................136

Object Storage ServicePython SDK API Reference Contents

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. vi

Page 8: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

1 Overview

This document describes all APIs of OBS (Object Storage Service) Python SDK,including the API description, method definition, and parameter description.

For details about the end-to-end usage of OBS Python SDK (such as installation,initialization, development, and troubleshooting), application scenarios of APIs,and code examples in various scenarios, see the Object Storage Service PythonSDK Developer Guide.

Object Storage ServicePython SDK API Reference 1 Overview

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 1

Page 9: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

2 Initialization

2.1 Namespaceobs is the global namespace of OBS Python SDK. All data types and APIdefinitions contained in the SDK belong to this namespace.

2.2 Initializing an Instance of ObsClient

API DescriptionObsClient functions as the Python client for accessing OBS. It offers users a seriesof APIs for interaction with OBS. These APIs are used for managing resources, suchas buckets and objects, stored in OBS.

Constructor Parameter DescriptionField Type Optiona

l orMandatory

Description

access_key_id str Optional Access key ID (AK)

secret_access_key str Optional Secret access key (SK)

server str Mandatory

Endpoint for accessing OBS, whichcan contain the protocol type,domain name, and port number.For example, https://your-endpoint:443.You can click here to view theendpoints of OBS.

Object Storage ServicePython SDK API Reference 2 Initialization

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 2

Page 10: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

ssl_verify strorbool

Optional Whether to verify server-sidecertificates. Possible values are:● Path to the server-side root

certificate file in PEM format● True: The certificate list will be

obtained from the rootcertificate library and thecertificates of the operatingsystem (Windows only) will beverified.

● False: The server-side certificateswill not be verified.

The default value is False.

max_retry_count int Optional Maximum number of retries whenan HTTP/HTTPS connection isabnormal. The default value is 3.

max_redirect_count

int Optional Maximum number of times thatthe HTTP/HTTPS request isredirected. The default value is 10.

timeout int Optional Timeout period (in seconds) of anHTTP/HTTPS request. The defaultvalue is 60.

chunk_size int Optional Chunk size (in bytes) set forreading and writing socket streams.The default value is 65536.

long_conn_mode bool Optional Whether to enable the persistentconnection mode. The default valueis False.

proxy_host str Optional Host IP address of the proxy server.This value is null by default.

proxy_port int Optional Port number of the proxy server.This value is null by default.

proxy_username str Optional User name used for connecting tothe proxy server. This value is nullby default.

proxy_password str Optional Password used for connecting tothe proxy server. This value is nullby default.

Object Storage ServicePython SDK API Reference 2 Initialization

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 3

Page 11: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

is_cname bool Optional Whether to use self-defineddomain name to access OBS. Thedefault value is False.

security_providers list Optional Specifies the allowed access keysearch methods. The default valueis None.NOTE

The value of security_providers mustbe in a list. The default value Noneindicates the default search methods toobtain the access keys from theenvironment variables and from ECSs. Ifthis parameter is specified, the defaultsearch methods are not provided.Instead, the search methods specifiedby security_providers are used.

security_provider_policy

str Optional Specifies the allowed access keysearch policy. The default value isNone.NOTE

● This parameter is used to set thesearch policy. The default valueNone indicates the specified accesskeys are displayed. In addition, ifthe access key parameters arespecified, security_provider_policyis ignored.

● If security_provider_policy is set toOBS_DEFAULT, the access keys areobtained by searching in sequence.

● If security_provider_policy is set tothe predefined methods (ENV orECS), the access keys are obtainedusing the corresponding method.

Sample Code# Import the module.from obs import ObsClient

# Create an instance of ObsClient.obsClient = ObsClient( access_key_id='*** Provide your Access Key ***', secret_access_key='*** Provide your Secret Key ***', server='https://your-endpoint', ssl_verify=False, max_retry_count=1, timeout=20, chunk_size=65536, long_conn_mode=False)

Object Storage ServicePython SDK API Reference 2 Initialization

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 4

Page 12: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

2.3 Initializing an Instance of BucketClient

API Description

Except ObsClient.listBuckets, ObsClient.createSignedUrl, andObsClient.createPostSignature, BucketClient can implement the same APIs asObsClient, without requiring the bucketName parameter.

Sample Code# Import the module.from obs import ObsClient

# Create an instance of ObsClient.obsClient = ObsClient( access_key_id='*** Provide your Access Key ***', secret_access_key='*** Provide your Secret Key ***', server='https://your-endpoint')# Create an instance of BucketClient.bucketClient = obsClient.bucketClient('bucketname')

2.4 Initializing Logs

API Description

You can enable the SDK log function to record log information generated duringAPI calling into log files for subsequent data analysis or fault location.

NO TICE

The log module of the OBS Python SDK is thread secure but not process secure. IfObsClient is used in multi-process scenarios, you must configure an independentlog path for each instance of ObsClient to prevent conflicts when multipleprocesses write logs concurrently.

Method DefinitionObsClient.initLog(log_config, log_name)

Parameter Description

Field Type Optional orMandatory

Description

log_config LogConf Mandatory Log configuration parameter

log_name str Optional Log name

Object Storage ServicePython SDK API Reference 2 Initialization

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 5

Page 13: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Sample Code# Import the module.from obs import ObsClient

# Create an instance of ObsClient.obsClient = ObsClient( access_key_id='*** Provide your Access Key ***', secret_access_key='*** Provide your Secret Key ***', server='https://your-endpoint')

# Import the log module.from obs import LogConf

# Specify the path to the log configuration file and initialize logs of ObsClient.obsClient.initLog(LogConf('./log.conf'), 'obsclient');

2.5 Request ParametersAPIs in the instance of ObsClient can be classified into three categories: bucket-related APIs, object-related APIs, and other APIs. For details about requestparameters of these APIs, see the following chapters.

2.6 SDK Common Result Objects

API Description

Each time an ObsClient related API is called (excludingObsClient.createSignedUrl and ObsClient.createPostSignature), an SDKcommon result object will be returned. You can obtain the HTTP status code fromthis object to check whether the operation is successful.

Parameter Description

Field Type Description

status int HTTP status code. If the value is smaller than 300, theoperation succeeds. Otherwise, the operation fails.

reason str Reason description

errorCode

str Error code returned by the OBS server. If the value ofstatus is smaller than 300, the value of this field is None.

errorMessage

str Error description returned by the OBS server. If the valueof status is smaller than 300, the value of this field isNone.

requestId str Request ID returned by the OBS server.

indicator str Error indicator returned by the OBS server

hostId str Requested server ID. If the value of status is smaller than300, the value of this field is None.

Object Storage ServicePython SDK API Reference 2 Initialization

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 6

Page 14: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

resource str Error source (a bucket or an object). If the value of statusis smaller than 300, the value of this field is None.

header list Response header list, composed of tuples. Each tupleconsists of two elements, respectively corresponding to thekey and value of a response header.

body object Result content returned after the operation is successful. Ifthe value of status is larger than 300, the value of thisfield is None. The value varies with the API being called.For details, see the sections "Bucket-Related APIs" and"Object-Related APIs."

Object Storage ServicePython SDK API Reference 2 Initialization

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 7

Page 15: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

3 Pre-defined Constants

3.1 Permission Types

Namespace

obs.Permission

Parameter Description

Constant Description

READ A grantee with this permission for a bucket can obtain the list ofobjects, multipart uploads, and multiple object versions in and thebucket, as well as metadata of the bucket.A grantee with this permission for an object can obtain the objectcontent and metadata.

WRITE A grantee with this permission for a bucket can upload, overwrite,and delete any object or part in the bucket.This permission is not applicable to objects.

READ_ACP

A grantee with this permission can obtain the ACL of a bucket orobject.A bucket or object owner has this permission permanently.

WRITE_ACP

A grantee with this permission can update the ACL of a bucket orobject.A bucket or object owner has this permission permanently.A grantee with this permission can modify the access control policyand thus the grantee obtains full access permissions.

FULL_CONTROL

A grantee with this permission for a bucket has READ, WRITE,READ_ACP, and WRITE_ACP permissions for the bucket.A grantee with this permission for an object has READ, WRITE,READ_ACP, and WRITE_ACP permissions for the object.

Object Storage ServicePython SDK API Reference 3 Pre-defined Constants

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 8

Page 16: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

3.2 Authorizable User Groups

Namespaceobs.Group

Parameter DescriptionConstant Description

ALL_USERS Indicates all users.

AUTHENTICATED_USERS

Indicates the authorized users. This constant is deprecated.

LOG_DELIVERY

Indicates the log delivery group. This constant is deprecated.

3.3 Pre-defined Access Control Policies

Namespaceobs.HeadPermission

Parameter DescriptionConstant Description

PRIVATE Private read/write

PUBLIC_READ Public read

PUBLIC_READ_WRITE

Public read/write

PUBLIC_READ_DELIVERED

Public read on a bucket as well as objects in the bucket

PUBLIC_READ_WRITE_DELIVERED

Public read/write on a bucket as well as objects in thebucket

BUCKET_OWNER_FULL_CONTROL

The owner of a bucket or object has the full controlpermission on the bucket or object.

PUBLIC_READ_DELIVERED and PUBLIC_READ_WRITE_DELIVERED cannot be set toobjects.

Object Storage ServicePython SDK API Reference 3 Pre-defined Constants

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 9

Page 17: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

3.4 Storage Classes

Namespaceobs.StorageClass

Parameter DescriptionConstant Description

STANDARD

OBS Standard

WARM OBS Infrequent Access

COLD OBS Archive

3.5 Restore Options

Namespaceobs.RestoreTier

Parameter DescriptionConstant Description

EXPEDITED Expedited restoration, which restores an object in 1to 5 minutes.

STANDARD Standard restoration, which restores an object in 3to 5 hours.

3.6 Event Types

Namespaceobs.EventType

Parameter DescriptionConstant Description

OBJECT_CREATED_ALL All events for creating objects, including uploadingobjects through PUT and POST, copying objects, andcombining parts

Object Storage ServicePython SDK API Reference 3 Pre-defined Constants

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 10

Page 18: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Constant Description

OBJECT_CREATED_PUT PUT Object events

OBJECT_CREATED_POST POST Object events

OBJECT_CREATED_COPY PUT Object - Copy events

OBJECT_CREATED_COMPLETE_MULTIPART_UPLOAD

Complete Multipart Upload events

OBJECT_REMOVED_ALL Events of calling the APIs for deletion and abortingmultipart uploadsEvents for deleting objects without specifying objectversion IDs, when versioning is enabled, as well asdeleting objects by specifying object version IDs

OBJECT_REMOVED_DELETE

Events for deleting objects by specifying objectversion IDs

OBJECT_REMOVED_DELETE_MARKER_CREATED

Events for deleting objects without specifying objectversion IDs, when versioning is enabled

Object Storage ServicePython SDK API Reference 3 Pre-defined Constants

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 11

Page 19: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4 Data Types

4.1 Log Configuration Parameter

Namespaceobs.LogConf

Parameter DescriptionField Type Optional or

MandatoryDescription

config_file

str Mandatory Path to the log configuration file

sec str Optional Section in the log configuration file

For details about the format of the log configuration file, see the description of theConfigParser module provided by the Python standard library.

4.2 Additional Header in PUT Bucket

Namespaceobs.CreateBucketHeader

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 12

Page 20: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type Optional orMandatory

Description

aclControl

str Optional Pre-defined access control policy thatcan be specified during the bucketcreation

storageClass

str Optional Bucket storage class that can bespecified during the bucket creation

extensionGrants

list ofExtensionGrant

Optional Extended permission list specified duringbucket creation

4.3 Extended Permissions

Namespace

obs.ExtensionGrant

Parameter Description

Field Type Optional orMandatory

Description

granteeId

str Optional Grantee ID

permission

str Optional Granted permissions

4.4 Response Result of GET Buckets

Namespace

obs.ListBucketsResponse

Parameter Description

Field Type Description

buckets list ofBucket

List of buckets

owner Owner Bucket owner

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 13

Page 21: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.5 Owner Info

Namespace

obs.Owner

Parameter Description

Field Type Optional or Mandatory Description

owner_id

str Mandatory when used as arequest parameter

Owner ID

owner_name

str Optional when used as arequest parameter

Owner name

4.6 Initiator Infoobs.Initiator

Parameter Description

Field Type Optional orMandatory

Description

id str Mandatory whenused as a requestparameter

Initiator ID

name str Optional when usedas a requestparameter

Initiator name

4.7 Bucket Info

Namespace

obs.Bucket

Parameter Description

Field Type Description

name str Bucket name

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 14

Page 22: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

create_date

str Creation time of the bucket

location str Bucket location

4.8 Response Result of GET Objects

Namespaceobs.ListObjectsResponse

Parameter DescriptionField Type Description

name str Bucket name

location str Bucket location

prefix str Object name prefix, which isconsistent with that set in therequest

marker str Start position for listing objects,which is consistent with that set inthe request

delimiter str Character used to group objectnames, which is consistent with thatset in the request

max_keys int Maximum number of listed objects,which is consistent with that set inthe request

is_truncated bool Whether all objects are returned. Ifthe field value is True, not all objectsare returned. If the field value isFalse, all objects are returned.

next_marker str Object name to start with upon nextrequest for listing objects

contents list of Content List of objects in the bucket

commonPrefixs list ofCommonPrefix

List of object name prefixes groupedaccording to the delimiterparameter (if specified)

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 15

Page 23: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.9 Object in a Bucket

Namespace

obs.Content

Parameter Description

Field Type Description

key str Object name

lastModified str Time when the last modification was madeto the object

etag str MD5 value of the object (If the object isencrypted using server-side encryption, theETag is not the MD5 value of the object.)

size int Object size in bytes

owner Owner Object owner

storageClass str Storage class of the object

isAppendable bool Whether the object is an appendable object

4.10 Object Name Prefix

Namespace

obs.CommonPrefix

Parameter Description

Field Type Description

prefix str Object name prefix grouped according tothe delimiter parameter

4.11 Request Parameter of GET Object versions

Namespace

obs.Versions

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 16

Page 24: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Optio

nal orMandatory

Description

prefix str Optional

Name prefix that the objects to be listedmust contain

key_marker str Optional

Object name to start with when listingversioning objects in a bucket. Allversioning objects following thisparameter are listed in thelexicographical order.

max_keys intorstr

Optional

Maximum number of objects returned.The value ranges from 1 to 1000. If thevalue is not in this range, 1000 isreturned by default.

delimiter str Optional

Character used to group object names. Ifthe object name contains the delimiterparameter, the character string from thefirst character to the first delimiter inthe object name is grouped under asingle result element, commonPrefix. (Ifa prefix is specified in the request, theprefix must be removed from the objectname.)

version_id_marker str Optional

Version ID to start with when listingobjects in a bucket. All objects are listedin the lexicographical order by objectname and version ID. This parametermust be used together withkey_marker.If the value of version_id_marker is nota version ID specified by key_marker,version_id_marker does not take effect.

4.12 Response Result of GET Object versions

Namespaceobs.ObjectVersions

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 17

Page 25: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Description

head ObjectVersionHead Response header in GET Objectversions

versions list of ObjectVersion List of versioning objects in thebucket

markers list ofObjectDeleteMarker

List of versioning delete markers inthe bucket

commonPrefixs list of CommonPrefix List of object name prefixesgrouped according to thedelimiter parameter (if specified)

4.13 Versioning Object in a Bucket

Namespaceobs.ObjectVersion

Parameter DescriptionField Type Description

key str Object name

versionId str Object version ID

lastModified str Time when the last modification was madeto the object

etag str MD5 value of the object

size int Object size in bytes

owner Owner Object owner

storageClass str Storage class of the object

isLatest bool Whether the object is of the latest version.If the parameter value is True, the object isof the latest version.

isAppendable bool Whether the object is an appendable object

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 18

Page 26: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.14 Versioning Delete Marker in a Bucket

Namespace

obs.ObjectDeleteMarker

Parameter Description

Field Type Description

key str Object name

versionId str Object version ID

isLatest bool Whether the object is of the latest version.If the parameter value is True, the object isof the latest version.

lastModified str Time when the last modification was madeto the object

owner Owner Object owner

4.15 Response Header in GET Object versions

Namespace

obs.ObjectVersionHead

Parameter Description

Field Type Description

name str Bucket name

location str Bucket location

delimiter str Character used to group versioning object names,which is consistent with that set in the request

prefix str Name prefix of versioning objects, which isconsistent with that set in the request

keyMarker str Object name to start with for listing versioningobjects, which is consistent with that set in therequest

versionIdMarker

str Version ID to start with for listing versioningobjects, which is consistent with that set in therequest

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 19

Page 27: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

nextKeyMarker

str Object name to start with upon the next requestfor listing versioning objects in a bucket

nextVersionIdMarker

str Version ID to start with upon the next request forlisting versioning objects. It is used with thenextKeyMarker parameter.

maxKeys int Maximum number of listed versioning objects,which is consistent with that set in the request

isTruncated bool Whether all objects are returned. If the field valueis True, not all objects are returned. If the fieldvalue is False, all objects are returned.

4.16 Request Parameter of List Multipart uploads

Namespaceobs.ListMultipartUploadsRequest

Parameter DescriptionField Type Op

tionalorMandatory

Description

prefix str Optional

Prefix that the object names in themultipart uploads to be listed mustcontain

max_uploads intorstr

Optional

Maximum number of returned multipartuploads. The value ranges from 1 to1000. If the value is not in this range,1000 is returned by default.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 20

Page 28: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

delimiter str Optional

Character used to group object namesinvolved in multipart uploads. If theobject name contains the delimiterparameter, the character string from thefirst character to the first delimiter inthe object name is grouped under asingle result element, commonPrefix.(If a prefix is specified in the request,the prefix must be removed from theobject name.)

key_marker str Optional

Object name to start with when listingmultipart uploads

upload_id_marker str Optional

Upload ID after which the multipartupload listing begins. It is effective onlywhen used with key_marker so thatmultipart uploads afterupload_id_marker of key_marker willbe listed.

4.17 Response Result of List Multipart uploads

Namespace

obs.ListMultipartUploadsResponse

Parameter Description

Field Type Description

bucket str Bucket name

keyMarker str Object name after which listing multipartuploads begins, which is consistent withthat set in the request

uploadIdMarker str Upload ID after which the multipart uploadlisting begins, which is consistent with thatset in the request

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 21

Page 29: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

nextKeyMarker str Object name to start with upon the nextrequest for listing multipart uploads

nextUploadIdMarker str Upload ID to start with upon the nextrequest for listing multipart uploads. It isused with the nextKeyMarker parameter.

maxUploads int Maximum number of listed multipartuploads, which is consistent with the sameparameter in the request

isTruncated bool Whether all uploaded parts are returned. Ifthe field value is True, not all uploadedparts are returned. If the field value isFalse, all uploaded parts are returned.

prefix str Object name prefix in multipart uploads,which is consistent with the sameparameter in the request

delimiter str Character used to group object names inmultipart uploads, which is consistent withthat set in the request

upload list ofUpload

List of multipart uploads

commonPrefixs list ofCommonPrefix

List of object name prefixes groupedaccording to the delimiter parameter (ifspecified)

4.18 Multipart Upload in a Bucket

Namespace

obs.Upload

Parameter Description

Field Type Description

key str Name of the object to be uploaded

uploadId str Multipart upload ID

initiator Initiator Initiator of the multipart upload

owner Owner Owner of the multipart upload, which isconsistent with initiator

storageClass str Storage class of the object to be uploaded

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 22

Page 30: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

initiated str Time when the multipart upload is initiated

4.19 Response Result of GET Bucket metadata

Namespaceobs.GetBucketMetadataResponse

Parameter DescriptionField Type Description

location str Bucket location

storageClass str Storage class of the bucket. When thestorage class is OBS Standard, the value isNone.

accessContorlAllo-wOrigin

str If origin in the request meets the CORSrules of the bucket, allowedOrigin in theCORS rules is returned.

accessContorlAllow-Headers

str If requestHeaders in the request meets theCORS rules of the bucket, allowedHeaderin the CORS rules is returned.

accessContorlAllow-Methods

str allowedMethod in the CORS rules of thebucket

accessContorlExpo-seHeaders

str exposeHeader in the CORS rules of thebucket

accessContorlMax-Age

int maxAgeSecond in the CORS rules of thebucket

obsVersion str OBS server version

4.20 Response Result of GET Bucket location

Namespaceobs.LocationResponse

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 23

Page 31: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type Description

location str Bucket location

4.21 Response Result of GET Bucket storage

Namespace

obs.GetBucketStorageInfoResponse

Parameter Description

Field Type Description

size int Bucket size

objectNumber int Number of objects in the bucket

4.22 Response Result of GET Bucket quota

Namespace

obs.GetBucketQuotaResponse

Parameter Description

Field Type Description

quota int Bucket quota

4.23 Response Result of GET Bucket storagePolicy

Namespace

obs.GetBucketStoragePolicyResponse

Parameter Description

Field Type Description

storageClass str Storage class of the bucket

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 24

Page 32: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.24 ACL

Namespace

obs.ACL

Parameter Description

Field Type Optional orMandatory

Description

owner Owner Mandatorywhen used as arequestparameter

Bucket owner

grants list ofGrant

Mandatorywhen used as arequestparameter

List of grantees' permission information

delivered

bool Optional whenused as arequestparameter

Whether the bucket ACL is applied toobjects in the bucket. This field is validonly when you configure the object ACL.

4.25 Grantees' Permission Information

Namespace

obs.Grant

Parameter Description

Field Type Optional orMandatory

Description

grantee Grantee Mandatorywhen used asa requestparameter

Grantee

permission str Mandatorywhen used asa requestparameter

Granted permissions

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 25

Page 33: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

delivered bool Optionalwhen used asa requestparameter

Whether the bucket ACL is applied toobjects in the bucket. This field isvalid only when you configure theobject ACL.

4.26 Grantee

Namespaceobs.Grantee

Parameter DescriptionField Type Optional or

MandatoryDescription

grantee_id

str Mandatorywhen theparameter isused as arequestparameter andgroup is None

Grantee ID

grantee_name

str Optional whenused as arequestparameter

Grantee name

group str Mandatorywhen theparameter isused as arequestparameter andgrantee_id isNone

Granted user group

grantee_id and grantee_name must be used together and they cannot be used withgroup.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 26

Page 34: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.27 Log Configuration Info

Namespaceobs.Logging

Parameter DescriptionField Type Optional or

MandatoryDescription

targetBucket

str Optional when used asa request parameter

Target bucket for which logs aregenerated

targetPrefix

str Optional when used asa request parameter

Name prefix of a to-be-loggedobject in the target bucket

targetGrants

list ofGrant

Optional when used asa request parameter

List of grantees' permissioninformation

agency str Mandatory when theparameter is in arequest to configure thebucket logging

Agency name

4.28 Bucket Policy

Namespaceobs.Policy

Parameter DescriptionField Type Description

policyJSON str Policy information in JSON format.

4.29 Bucket Lifecycle Settings

Namespaceobs.Lifecycle

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 27

Page 35: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type Optional orMandatory

Description

rule list of Rule Mandatory whenused as a requestparameter

Lifecycle rules of the bucket

4.30 Lifecycle Rule of a Bucket

Namespaceobs.Rule

Parameter Description

Field Type Optional orMandatory

Description

id str Optionalwhenusedas arequestparameter

Rule ID. It is a 1-255 character string.

prefix str Mandatorywhenusedas arequestparameter

Object name prefix identifying oneor more objects to which the ruleapplies The value can be empty,indicating that the rule applies to allobjects in the bucket.

status str Mandatorywhenusedas arequestparameter

Whether this rule is enabled. Possiblevalues are:● Enabled● Disabled

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 28

Page 36: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

transition Transitionorlist ofTransition

Optionalwhenusedas arequestparameter

Object transition policy

expiration Expiration

Optionalwhenusedas arequestparameter

Expiration time of the object

noncurrentVersion-Transition

NoncurrentVersionTransitionorlist ofNoncurrentVersionTransition

Optionalwhenusedas arequestparameter

Transition policy of the noncurrentobject version

noncurrentVersio-nExpiration

NoncurrentVersionExpiration

Optionalwhenusedas arequestparameter

Expiration time of a noncurrentobject version

transition, expiration, noncurrentVersionTransition, and noncurrentVersionExpirationcannot be all null.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 29

Page 37: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.31 Object Transition Policy

Namespaceobs.Transition

Parameter DescriptionField Type Optional or

MandatoryDescription

storageClass

str Mandatory whenused as a requestparameter

Storage class of the object aftertransitionNOTE

The Standard storage class is notsupported.

date strorDateTime

Mandatory whenthe parameter isused as a requestparameter anddays is None

Date when an object will betransited. If the type is str, the valuemust conform to the ISO8601standards and must be at 00:00(UTC time).

days int Mandatory whenthe parameter isused as a requestparameter anddate is None

Number of days after which anobject will be transited since itscreation. The value must be apositive integer.

date and days are mutually exclusive.

4.32 Expiration Time of an Object

Namespaceobs.Expiration

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 30

Page 38: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type OptionalorMandatory

Description

date strorDateTime

Mandatorywhen theparameteris used as arequestparameterand days isNone

Date when an object expires. If thevalue type is str, the value mustconform with the ISO8601 standardsand must be at 00:00 (UTC time), forexample, 2018-01-01T00:00:00Z.

days int Mandatorywhen theparameteris used as arequestparameterand date isNone

Number of days after which an objectexpires since its creation. The value mustbe a positive integer.

date and days are mutually exclusive.

4.33 Transition Policy of a Noncurrent Object Version

Namespace

obs.NoncurrentVersionTransition

Parameter Description

Field Type Optional orMandatory

Description

storageClass

str Mandatorywhen used asa requestparameter

Storage class of the noncurrent objectversion after transitionNOTE

The Standard storage class is not supported.

noncurrentDays

int Mandatorywhen used asa requestparameter

Number of days after which an objectwill be transited since it becomes anoncurrent version. The parameter valuemust be a positive integer.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 31

Page 39: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.34 Expiration Time of a Noncurrent Object Version

Namespace

obs.NoncurrentVersionExpiration

Parameter Description

Field Type Optional orMandatory

Description

noncurrentDays

int Mandatorywhen used asa requestparameter

Number of days after which an objectexpires since it becomes a noncurrentversion. The parameter value must be apositive integer.

4.35 UTC Time Object

Namespace

obs.DateTime

Parameter Description

Field Type Description

year int Year

month int Month

day int Day

hour int Hour

min int Minute

sec int Second

4.36 Response Result of GET Bucket lifecycle

Namespace

obs.LifecycleResponse

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 32

Page 40: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type Description

lifecycleConfig Lifecycle Bucket lifecycle rules

4.37 Website Hosting Settings of a Bucket

Namespace

obs.WebsiteConfiguration

Parameter Description

Field Type Optional orMandatory

Description

redirectAllRequestTo

RedirectAllRequestTo

Optional whenused as a requestparameter

Redirection rule of all requests

indexDocument

IndexDocument

Optional whenused as a requestparameter

Default page configuration,which includes the Suffix field

errorDocument

ErrorDocument

Optional whenused as a requestparameter

Error page configuration,which includes the Key field

routingRules

list ofRoutingRule

Optional whenused as a requestparameter

Redirection rule list

● errorDocument, indexDocument, and routingRules must be used together and theycannot be used with redirectAllRequestsTo.

● When errorDocument, indexDocument, and routingRules are used together,routingRules can be None.

● You must set either these three fields or redirectAllRequestsTo.

4.38 Redirection Rule Applying to all Requests

Namespace

obs.RedirectAllRequestTo

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 33

Page 41: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Optional or

MandatoryDescription

hostName str Mandatory when usedas a requestparameter

Host name used for redirection

protocol str Optional when usedas a requestparameter

Protocol used for redirection.Possible values are:● http● https

4.39 Error Page Settings

Namespaceobs.ErrorDocument

Parameter DescriptionField Type Optional or

MandatoryDescription

key str Optional when usedas a requestparameter

Page that is returned when a 4XXerror occurs

4.40 Default Page Settings

Namespaceobs.IndexDocument

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 34

Page 42: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Optional or

MandatoryDescription

suffix str Mandatorywhen used as arequestparameter

Suffix that is appended to a requestinitiated for a folder. For example, if thesuffix is index.html and you request forsamplebucket/images/, the returneddata will be the object named images/index.html in the samplebucketbucket. The suffix can neither be nullnor contain slashes (/).

4.41 Redirection Rule

Namespaceobs.RoutingRule

Parameter DescriptionField Type Optional or

MandatoryDescription

condition Condition Optional when used asa request parameter

Matching condition of aredirection rule

redirect Redirect Mandatory when usedas a request parameter

Details about a redirectionrequest

4.42 Matching Condition of a Redirection Rule

Namespaceobs.Condition

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 35

Page 43: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type OptionalorMandatory

Description

keyPrefixEquals str Optionalwhenused as arequestparameter

Object name prefix to be matched whena redirection rule takes effect

httpErrorCodeReturnedEquals

int Optionalwhenused as arequestparameter

HTTP error code to be matched when aredirection rule takes effect

4.43 Details About a Redirection Request

Namespace

obs.Redirect

Parameter Description

Field Type Optional orMandatory

Description

protocol str Optional whenused as a requestparameter

Protocol used for redirection.Possible values are:● http● https

hostName str Optional whenused as a requestparameter

Host name used for redirection

replaceKeyPrefixWith

str Optional whenused as a requestparameter

Object name prefix used in theredirection request

replaceKeyWith

str Optional whenused as a requestparameter

Object name used in theredirection request. Thisparameter cannot be usedtogether with replaceKeyPrefix-With.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 36

Page 44: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

httpRedirectCode

int Optional whenused as a requestparameter

HTTP status code in the responseto the redirection request

4.44 Bucket CORS Rules

Namespaceobs.CorsRule

Parameter DescriptionField Type Optional

orMandatory

Description

id str Optionalwhen usedas arequestparameter

CORS rule ID. It is a 1-255 characterstring.

allowedMethod

list of str Mandatorywhen usedas arequestparameter

HTTP methods allowed by the CORSrule. Possible values are:● GET● PUT● HEAD● POST● DELETE

allowedOrigin

list of str Mandatorywhen usedas arequestparameter

Origins (character strings representingdomain names) allowed by the CORSrule. Each allowedOrigin can containup to one wildcard character (*).

allowedHeader

list of str Optionalwhen usedas arequestparameter

Request headers allowed by the CORSrule. Each allowedHeader can containup to one wildcard character (*).

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 37

Page 45: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

maxAgeSecond

intorstr

Optionalwhen usedas arequestparameter

Cache duration (in seconds) of thecross-region request result in the clientallowed by the CORS rule. The valuemust be an integer.

exposeHeader

list of str Optionalwhen usedas arequestparameter

Additional response headers allowed bythe CORS rule. It cannot contain spaces.

4.45 Bucket Message Notification Settings

Namespaceobs.Notification

Parameter DescriptionField Type Optional or

MandatoryDescription

topicConfigurations

list ofTopicConfiguration

Optional when usedas a requestparameter

List of bucket eventnotification settings

functionGraphConfigurations

list ofFunctionGraphConfiguration

Optional when usedas a requestparameter

FunctionGraphconfiguration list

4.46 Event Notification Settings

Namespaceobs.TopicConfiguration

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 38

Page 46: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Optional or

MandatoryDescription

id str Optionalwhen usedas a requestparameter

Event notification setting ID

topic str Mandatorywhen usedas a requestparameter

URN of the event notification topic.After detecting a specific event, OBSsends a message to the topic.

events list of str Mandatorywhen usedas a requestparameter

Event types that need to be notified

filterRules

list ofFilterRule

Optionalwhen usedas a requestparameter

List of filtering rules

4.47 FunctionGraph Settings

Namespaceobs.FunctionGraphConfiguration

Parameter DescriptionField Type Optiona

l orMandatory

Description

id str Optionalwhenused asarequestparameter

Event notification setting ID

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 39

Page 47: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

functionGraph

str Mandatory whenused asarequestparameter

URN of FunctionGraph. When OBS detects aspecific event in the bucket, it sends amessage to FunctionGraph and callsFunctionGraph.

events list ofstr

Mandatory whenused asarequestparameter

Event types that need to be notified

filterRules list ofFilterRule

Optionalwhenused asarequestparameter

List of filtering rules

4.48 Filtering Rule

Namespaceobs.FilterRule

Parameter Description

Field Type Optional orMandatory

Description

name str Optional whenused as arequestparameter

Prefix or suffix of object names forfiltering. Possible values are:● prefix● suffix

value str Optional whenused as arequestparameter

Keyword of object names for filteringobjects by prefix or suffix

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 40

Page 48: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.49 Additional Parameter of an OPTIONS Request

Namespace

obs.Options

Parameter Description

Field Type Optional orMandatory

Description

origin str Mandatory

Origin of the cross-domain requestspecified by the pre-request. Generally, itis a domain name.

accessControlRe-questMethods

list ofstr

Mandatory

HTTP methods in the cross-domainrequest. Possible values are:● GET● PUT● HEAD● POST● DELETE

accessControlRe-questHeaders

list ofstr

Optional

HTTP headers in a cross-domain request

4.50 Response Result of an OPTIONS Request

Namespace

obs.OptionsResponse

Parameter Description

Field Type Description

accessContorlAllo-wOrigin

str If origin in the request meets the CORSrules of the bucket, allowedOrigin in theCORS rules is returned.

accessContorlAllow-Headers

str If accessControlRequestHeaders in therequest meets the CORS rules of thebucket, allowedHeader in the CORS rulesis returned.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 41

Page 49: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

accessContorlAllow-Methods

str allowedMethod in the CORS rules of thebucket

accessContorlExpo-seHeaders

str exposeHeader in the CORS rules of thebucket

accessContorlMax-Age

int maxAgeSecond in the CORS rules of thebucket

4.51 Bucket Tag Set

Namespace

obs.TagInfo

Parameter Description

Field Type Optional or Mandatory Description

tagSet list of Tag Mandatory when usedas a request parameter

Bucket tag set

4.52 Bucket Tag

Namespace

obs.Tag

Parameter Description

Field Type Optional orMandatory

Description

key str Mandatorywhen used asa requestparameter

Tag name, which contains 1 to 36characters and cannot include non-printable ASCII characters (0–31) and thefollowing special characters: *<>\= The tagkeys in one bucket must be unique.

value str Mandatorywhen used asa requestparameter

Tag value, which can contain up to 43characters and cannot include non-printable ASCII characters (0–31) and thefollowing special characters: *<>\=

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 42

Page 50: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.53 Response Result of Initiate Multipart Upload

Namespace

obs.InitiateMultipartUploadResponse

Parameter Description

Field Type Description

bucketName str Name of the bucket involved in themultipart upload

objectKey str Name of the object to be uploaded

uploadId str Multipart upload ID

sseKms str SSE-KMS algorithm

sseKmsKey str Key used in SSE-KMS encryption

sseC str SSE-C algorithm

sseCKeyMd5 str MD5 value of the key used in SSE-Cdecryption

4.54 SSE-C Header

Namespace

obs.SseCHeader

Parameter Description

Field Type OptionalorMandatory

Description

encryption str Mandatory

Algorithm used in SSE-C encryption. Thevalue can be:AES256

key str Mandatory

Key used to encrypt the object in SSE-Cmode, which is calculated by usingAES-256

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 43

Page 51: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.55 SSE-KMS Header

Namespace

obs.SseKmsHeader

Parameter Description

Field Type OptionalorMandatory

Description

encryption str Mandatory

Algorithm used in SSE-KMS encryption.The value can be:kms

key str Optional Master key used in SSE-KMS encryption.The value can be None.

4.56 Response Result of PUT Part

Namespace

obs.UploadPartResponse

Parameter Description

Field Type Description

etag str ETag of the uploaded part

sseKms str SSE-KMS algorithm

sseKmsKey str Key used in SSE-KMS encryption

sseC str SSE-C algorithm

sseCKeyMd5

str MD5 value of the key used in SSE-C encryption

4.57 Response Result of PUT Part - Copy

Namespace

obs.CopyPartResponse

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 44

Page 52: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Description

etag str ETag of the target part

lastModified str Time when the target part was lastmodified

sseKms str SSE-KMS algorithm

sseKmsKey str Key used in SSE-KMS encryption

sseC str SSE-C algorithm

sseCKeyMd5 str MD5 value of the key used in SSE-Cencryption

4.58 Response Result of List Parts

Namespaceobs.ListPartsResponse

Parameter DescriptionField Type Description

bucketName str Bucket name

objectKey str Object name

uploadId str Multipart upload ID

initiator Initiator Initiator of the multipart upload

owner Owner Owner of the multipart upload, which isconsistent with initiator

storageClass str Storage class of the object to be uploaded

partNumberMarker int Part number after which listing partsbegins, which is consistent with that set inthe request

nextPartNumberMarker

int Part number to start with upon the nextrequest for listing parts

maxParts int Maximum number of listed parts, which isconsistent with that set in the request

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 45

Page 53: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

isTruncated bool Whether all objects are returned. If the fieldvalue is True, not all objects are returned. Ifthe field value is False, all objects arereturned.

parts list of Part List of uploaded parts

4.59 Uploaded Part

Namespaceobs.Part

Parameter DescriptionField Type Description

partNumber int Part number

lastModified str Time when the part was last modified

etag str Part ETag

size int Part size

4.60 Request Parameter of Complete Multipart Upload

Namespaceobs.CompleteMultipartUploadRequest

Parameter DescriptionField Type Optional or

MandatoryDescription

parts list ofCompletePart

Mandatory List of parts to be combined

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 46

Page 54: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.61 Part to Be Combined

Namespace

obs.CompletePart

Parameter Description

Field Type OptionalorMandatory

Description

partNum int Mandatory

Part number

etag str Mandatory

Part ETag

4.62 Response Result of Complete Multipart Upload

Namespace

obs.CompleteMultipartUploadResponse

Parameter Description

Field Type Description

etag str ETag calculated based on the ETags of all combinedparts

bucket str Bucket in which parts are combined

key str Object name obtained after part combination

location str URI of the generated object after part combination

versionId str Version ID of the object obtained after partcombination

sseKms str SSE-KMS algorithm

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 47

Page 55: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

sseKmsKey

str Master key used in SSE-KMS encryption

sseC str SSE-C algorithm

sseCKeyMd5

str MD5 value of the key used in SSE-C encryption

objectUrl str Full path to the obtained object after partcombination

4.63 Response Result of Obtain Object Metadata

Namespaceobs.GetObjectMetadataResponse

Parameter Description

Field Type Description

storageClass str Storage class of the object. When thestorage class is OBS Standard, the value isNone.

accessContorlAllo-wOrigin

str If origin in the request meets the CORSrules of the server, allowedOrigin in theCORS rules is returned.

accessContorlAllow-Headers

str If requestHeaders in the request meets theCORS rules of the server, allowedHeader inthe CORS rules is returned.

accessContorlAllow-Methods

str allowedMethod in the CORS rules of theserver

accessContorlExpo-seHeaders

str exposeHeader in the CORS rules of theserver

accessContorlMax-Age

int maxAgeSecond in the CORS rules of theserver

contentLength int Object size in bytes

contentType str MIME type of the object

lastModified str Time when the last modification was madeto the object

etag str Object ETag

versionId str Object version ID

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 48

Page 56: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

restore str Restore status of the object in the OBSArchive storage class. If the object is not inthe OBS Archive storage class, the value isNone.

expiration str Expiration details

sseKms str SSE-KMS algorithm

sseKmsKey str Master key used in SSE-KMS decryption

sseC str SSE-C algorithm

sseCKeyMd5 str MD5 value of the key used in SSE-Cdecryption

websiteRedirectLoca-tion

str Location where the object is redirected to,when the bucket is configured with websitehosting.

isAppendable bool Whether the object is an appendable object

nextPosition int Start position for next appending

4.64 Request Parameter of DELETE Objects

Namespaceobs.DeleteObjectsRequest

Parameter DescriptionField Type Optional

orMandatory

Description

quiet bool Optional Response mode of a batch deletionrequest. If this field is set to False,objects involved in the deletion will bereturned. If this field is set to True, onlyobjects failed to be deleted will bereturned.

objects list of Object Mandatory

List of objects to be deleted

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 49

Page 57: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

4.65 To-Be-Deleted Object

Namespaceobs.Object

Parameter DescriptionField Type Optional or

MandatoryDescription

key str Mandatory Object name

versionId

str Optional Object version ID

4.66 Response Result of DELETE Objects

Namespaceobs.DeleteObjectsResponse

Parameter DescriptionField Type Description

deleted list ofDeleteObjectResult

List of successfully deleted objects

error list ofErrorResult

List of objects failed to be deleted

4.67 Successfully Deleted Object

Namespaceobs.DeleteObjectResult

Parameter DescriptionField Type Description

key str Object name

versionId str Object version ID

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 50

Page 58: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

deleteMarker bool Whether the deleted object is a delete marker

deleteMarkerVersionId

str Version ID of the delete marker

4.68 Object Failed to Be Deleted

Namespace

obs.ErrorResult

Parameter Description

Field Type Description

key str Object name

versionId str Object version ID

code str Error code of the deletion failure

message str Error message of the deletion failure

4.69 Response Result of DELETE Object

Namespace

obs.DeleteObjectResponse

Parameter Description

Field Type Description

deleteMarker bool Whether the deleted object is a deletemarker

versionId str Object version ID

4.70 Additional Headers in PUT Object - Copy

Namespace

obs.CopyObjectHeader

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 51

Page 59: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Optional

orMandatory

Description

acl str Optional Pre-defined access control policy,which can be specified during objectcopy

directive str Optional Whether to copy source objectattributes to the target object.Possible values are:● COPY (Default value; Attributes of

the target object are copied fromthe source object.)

● REPLACE (Attributes of the targetobject are replaced with valuesspecified in the requestparameter.)

if_match str Optional Copies the source object if its ETag isthe same as the one specified by thisparameter; otherwise, an error codeis returned.

if_none_match

str Optional Copies the source object if its ETag isdifferent from the one specified bythis parameter; otherwise, an errorcode is returned.

if_modified_since

strorDateTime

Optional Copies the source object if it ischanged after the time specified bythis parameter; otherwise, an errorcode is returned. If this parametervalue is a character string, it mustconform to the HTTP time formatspecified in http://www.ietf.org/rfc/rfc2616.txt.

if_unmodified_since

strorDateTime

Optional Copies the source object if it ischanged before the time specified bythis parameter; otherwise, an errorcode is returned. If this parametervalue is a character string, it mustconform to the HTTP time formatspecified in http://www.ietf.org/rfc/rfc2616.txt.

location str Optional Location where the object isredirected to, when the bucket isconfigured with website hosting.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 52

Page 60: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

destSseHeader

SseCHeaderorSseKmsHeader

Optional Header for server-side encryption. Itis used to encrypt the target object.

sourceSseHeader

SseCHeader Optional Header for server-side decryption. Itis used to decrypt the source object.

cacheControl

str Optional Rewrites the Cache-Control headerin the response.

contentDisposition

str Optional Rewrites the Content-Dispositionheader in the response.

contentEncoding

str Optional Rewrites the Content-Encodingheader in the response.

contentLanguage

str Optional Rewrites the Content-Languageheader in the response.

contentType

str Optional Rewrites the Content-Type header inthe response.

expires str Optional Rewrites the Expires header in theresponse.

storageClass

str Optional Storage class of the object.

successActionRedirect

str Optional Redirection address after the copy issuccessful

extensionGrants

list ofExtensionGrant

Optional Extended permission list specifiedduring object copy

● If the object copy request includes if_unmodified_since, if_match, if_modified_since,or if_none_match, and the specified condition is not met, the object copy will fail witherror code 412 Precondition Failed returned.

● if_modified_since and if_none_match can be used together. So doif_unmodified_since and if_match.

4.71 Response Result of PUT Object - Copy

Namespaceobs.CopyObjectResponse

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 53

Page 61: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Description

lastModified str Time when the last modification was madeto the target object

etag str ETag of the target object

copySourceVersionId str Version ID of the source object

versionId str Version ID of the target object

sseKms str SSE-KMS algorithm

sseKmsKey str Master key used in SSE-KMS encryption

sseC str SSE-C algorithm

sseCKeyMd5 str MD5 value of the key used in SSE-Cencryption

4.72 Additional Headers in PUT Object

Namespaceobs.PutObjectHeader

Parameter DescriptionField Type Op

tionalorMandatory

Description

md5 str Optional

Base64-encoded MD5 value of theobject data to be uploaded. It isprovided for the OBS server to verifydata integrity.

acl str Optional

Pre-defined access control policyspecified during object upload

location str Optional

Location where the object is redirectedto, when the bucket is configured withwebsite hosting.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 54

Page 62: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

contentType str Optional

MIME type of the object

contentLength int Optional

Object size in bytes

sseHeader SseCHeaderorSseKmsHeader

Optional

Header for server-side encryption

storageClass str Optional

Storage class, which can be specifiedduring the object creation

successActionRe-direct

str Optional

Redirection address after the upload issuccessful

extensionGrants list ofExtensionGrant

Optional

Extended permission list specified forthe to-be-uploaded object

expires int Optional

Indicates the expiration time of anuploaded object, in days.

4.73 Response Result of PUT Object

Namespaceobs.PutContentResponse

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 55

Page 63: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Description

storageClass str Storage class of the object. When thestorage class is OBS Standard, the value isNone.

versionId str Object version ID

etag str Object ETag

sseKms str SSE-KMS algorithm

sseKmsKey str Master key used in SSE-KMS encryption

sseC str SSE-C algorithm

sseCKeyMd5 str MD5 value of the key used in SSE-Cencryption

objectUrl str Full path to the object

4.74 Additional Headers in Resumable Upload

Namespaceobs.UploadFileHeader

Parameter DescriptionField Type Op

tionalorMandatory

Description

acl str Optional

Pre-defined access control policiesspecified during object upload

websiteRedirectLo-cation

str Optional

Location where the object is redirectedto, when the bucket is configured withwebsite hosting.

contentType str Optional

MIME type of the object

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 56

Page 64: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

sseHeader SseCHeaderorSseKmsHeader

Optional

Header for server-side encryption

storageClass str Optional

Storage class, which can be specifiedduring object upload

successActionRe-direct

str Optional

Redirection address after the upload issuccessful

extensionGrants list ofExtensionGrant

Optional

Extended permission list specified forthe to-be-uploaded object

expires int Optional

Expiration time of the object, in days

4.75 Additional Headers in Append Object

Namespaceobs.AppendObjectHeader

Parameter DescriptionField Type Optional

orMandatory

Description

md5 str Optional Base64-encoded MD5 value of thecontent to be appended. It is providedfor the OBS server to verify dataintegrity.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 57

Page 65: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

acl str Optional Pre-defined access control policy,which can be specified during the firstobject appending

location str Optional Location where the appendable objectis redirected to. If the bucket isconfigured with website hosting, youcan set this parameter when creatingthe object.

contentType str Optional MIME type of the appendable object.You can set this parameter whencreating the object.

contentLength

int Optional Length of the content to be appended

sseHeader SseCHeaderorSseKmsHeader

Optional Header for server-side encryption.This parameter can be set when youcreate the appendable object.

storageClass str Optional Storage class, which can be specifiedduring the first object appending

successActionRedirect

str Optional Redirection address after theappendable upload is successful

extensionGrants

list ofExtensionGrant

Optional Extended permission list specifiedduring the appendable object creation

expires int Optional Pre-defined access control policy ofthe appendable object, in days. Thisparameter can be set when youcreate the object.

4.76 Message Body in Append Object

Namespaceobs.AppendObjectContent

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 58

Page 66: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter Description

Field Type Optional orMandatory

Description

content strorreadableobject

Optional Content to be appended

position intorstr

Mandatory Start position for next appending. Thisparameter must be set to 0 when youcreate an appendable object.

offset intorstr

Optional Offset, in bytes. This parameter isrequired if the content for anappendable upload is a local file.

isFile bool Optional Whether content indicates the filepath. The default value is False.

If content is a readable object that contains the read attribute, data can be read fromcontent. Otherwise, the object content is a character string.

4.77 Response Result of Append Object

Namespace

obs.AppendObjectResponse

Parameter Description

Field Type Description

storageClass str Storage class of the object. When thestorage class is OBS Standard, the value isNone.

etag str ETag value of the appended content

nextPosition int Start position for next appending

sseKms str SSE-KMS algorithm

sseKmsKey str Master key used in SSE-KMS decryption

sseC str SSE-C algorithm

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 59

Page 67: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

sseCKeyMd5 str MD5 value of the key used in SSE-Cdecryption

objectUrl str Full path to the object

4.78 Additional Request Parameter of GET Object

Namespaceobs.GetObjectRequest

Parameter DescriptionField Type Optional or

MandatoryDescription

cache_control

str Optional Rewrites the Cache-Control headerwhen obtaining the object.

content_disposition

str Optional Rewrites the Content-Dispositionheader when obtaining the object.

content_encoding

str Optional Rewrites the Content-Encodingheader when obtaining the object.

content_language

str Optional Rewrites the Content-Languageheader when obtaining the object.

content_type str Optional Rewrites the Content-Type headerwhen obtaining the object.

expires str Optional Rewrites the Expires header whenobtaining the object.

versionId str Optional Object version ID

imageProcess str Optional Image processing parameter

4.79 Additional Headers in GET Object

Namespaceobs.GetObjectHeader

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 60

Page 68: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Parameter DescriptionField Type Optional

orMandatory

Description

range str Optional Download range. The value range is[0, object length-1] and is in theformat of x-y. The maximum lengthof range is the length of the objectminus 1. If it exceeds this value, thelength of the object minus 1 is used.

if_match str Optional Returns the source object if its ETag isthe same as the one specified by thisparameter; otherwise, an error code isreturned.

if_none_match

str Optional Returns the source object if its ETag isdifferent from the one specified bythis parameter; otherwise, an errorcode is returned.

if_modified_since

strorDateTime

Optional Returns the object if it is modifiedafter the time specified by thisparameter; otherwise, an error code isreturned. If this parameter value is acharacter string, it must conform tothe HTTP time format specified inhttp://www.ietf.org/rfc/rfc2616.txt.

if_unmodified_since

strorDateTime

Optional Returns the object if it remainsunchanged since the time specified bythis parameter; otherwise, an errorcode is returned. If this parametervalue is a character string, it mustconform to the HTTP time formatspecified in http://www.ietf.org/rfc/rfc2616.txt.

origin str Optional Origin of the cross-domain requestspecified by the pre-request.Generally, it is a domain name.

requestHeaders

str Optional HTTP headers in a cross-domainrequest

sseHeader SseCHeader

Optional Header for server-side decryption

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 61

Page 69: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

● If a request includes if_unmodified_since or if_match and the specified condition is notmet, the object download will fail with error code 412 Precondition Failed.

● If a request includes if_modified_since or if_none_match and the specified condition isnot met, the object download will fail with error code 304 Not Modified returned.

● The maximum length of range is the length of the source object minus 1. If it exceedsthis value, the length of the source object minus 1 is used.

4.80 Response Result of GET Object

Namespace

obs.ObjectStream

Parameter Description

Field Type Description

response object If loadStreamInMemory is set to False anddownloadPath is None in the request, thisfield is returned and indicates a readablestream. You can read object content from it.

buffer object If loadStreamInMemory is set to True inthe request, this field is returned andindicates the data stream in the memory.

size int If loadStreamInMemory is set to True inthe request, this field is returned andindicates the size of the data stream.

url str If loadStreamInMemory is set to False anddownloadPath is not None, this field isreturned and indicates the download path.

deleteMarker bool Whether the deleted object is a deletemarker

storageClass str Storage class of the object

accessContorlAllo-wOrigin

str If origin in the request meets the CORSrules of the bucket, allowedOrigin in theCORS rules is returned.

accessContorlAllow-Headers

str If requestHeaders in the request meets theCORS rules of the bucket, allowedHeaderin the CORS rules is returned.

accessContorlAllow-Methods

str allowedMethod in the CORS rules of thebucket

accessContorlExpo-seHeaders

str exposeHeader in the CORS rules of thebucket

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 62

Page 70: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Description

accessContorlMax-Age

int maxAgeSecond in the CORS rules of thebucket

contentLength int Object size in bytes

cacheControl str Cache-Control header in the response

contentDisposition str Content-Disposition header in theresponse

contentEncoding str Content-Encoding header in the response

contentLanguage str Content-Language header in the response

contentType str MIME type of the object

expires str Expires header in the response

lastModified str Time when the last modification was madeto the object

etag str Object ETag

versionId str Object version ID

restore str Restore status of the object in the OBSArchive storage class. If the object is not inthe OBS Archive storage class, the value isNone.

expiration str Expiration details

sseKms str SSE-KMS algorithm

sseKmsKey str Master key used in SSE-KMS decryption

sseC str SSE-C algorithm

sseCKeyMd5 str MD5 value of the key used in SSE-Cdecryption

websiteRedirectLoca-tion

str Location where the object is redirected to,when the bucket is configured with websitehosting.

NO TICE

If response is not None, you must call its close method to close the connectionafter reading the data.

Object Storage ServicePython SDK API Reference 4 Data Types

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 63

Page 71: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5 Bucket-Related APIs

5.1 PUT Bucket

API DescriptionYou can use this API to create a bucket and name it as you specify. The createdbucket name must be unique in OBS. If a user repeatedly creates buckets with thesame name in one region, status code 200 is returned. In other cases, status code409 is returned. Each user can create a maximum of 100 buckets.

Method DefinitionObsClient.createBucket(bucketName, header, location)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 64

Page 72: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional or

MandatoryDescription

bucketName

str Mandatory Bucket nameA bucket name must comply withthe following rules:● Contains 3 to 63 characters

chosen from lowercase letters,digits, hyphens (-), and periods(.), and starts with a digit or letter.

● Cannot be an IP-like address.● Cannot start or end with a hyphen

(-) or period (.).● Cannot contain two consecutive

periods (.), for example,my..bucket.

● Cannot contain periods (.) andhyphens (-) adjacent to eachother, for example, my-.bucket ormy.-bucket.

header CreateBucketHeader

Optional Additional header in PUT Bucket

location str Mandatoryunless theregion wherethe OBSserviceresides is notthe defaultregion.

Bucket locationThis parameter is not required if theendpoint belongs to the defaultNorth China 1 region (cn-north-1).This parameter is a must if theendpoint belongs to any otherregions. Click here to query currentlyvalid regions. For details about OBSregions and endpoints, see Regionsand Endpoints.

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: from obs import CreateBucketHeader from obs import StorageClass resp = obsClient.createBucket(bucketName='bucketname', header=CreateBucketHeader(aclControl='private', storageClass=StorageClass.WARM))

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 65

Page 73: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.2 GET Buckets

API DescriptionYou can use this API to obtain the bucket list. In the list, bucket names aredisplayed in lexicographical order.

Method DefinitionObsClient.listBuckets(isQueryLocation)

Request ParameterField Type Optional

orMandatory

Description

isQueryLocation

bool Optional Whether to query the bucket location

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

ListBucketsResponse Response result of GET Buckets

Sample Codetry: resp = obsClient.listBuckets(True) if resp.status < 300: print('requestId:', resp.requestId) print('name:', resp.body.owner.owner_id) print('create_date:', resp.body.owner.owner_name) index = 1 for bucket in resp.body.buckets: print('bucket [' + str(index) + ']')

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 66

Page 74: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

print('name:', bucket.name) print('create_date:', bucket.create_date) print('location:', bucket.location) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.3 HEAD Bucket

API DescriptionYou can use this API to check whether a bucket exists. If the returned HTTP statuscode is 200, the bucket exists. If the returned HTTP status code is 404, the bucketdoes not exist.

Method DefinitionObsClient.headBucket(bucketName)

Request ParameterField Type Optiona

l orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.headBucket('bucketname') if resp.status < 300: print('Bucket exists') elif resp.status == 404: print('Bucket does not exist')except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 67

Page 75: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.4 DELETE Bucket

API DescriptionYou can use this API to delete a bucket. The bucket to be deleted must be empty(containing no objects, noncurrent object versions, or part fragments).

Method DefinitionObsClient.deleteBucket(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.deleteBucket('bucketname') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.5 GET Objects

API DescriptionYou can use this API to list objects in a bucket. By default, a maximum of 1000objects are listed.

Method DefinitionObsClient.listObjects(bucketName, prefix, marker, max_keys, delimiter)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 68

Page 76: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

prefix str Optional Name prefix that the objects tobe listed must contain

marker str Optional Object name to start with whenlisting objects in a bucket. Allobjects are listed in thelexicographical order.

max_keys int Optional Maximum number of objectsreturned in the response. Thevalue ranges from 1 to 1000. Ifthe value is not in this range,1000 is returned by default.

delimiter str Optional Character used to group objectnames. If the object namecontains the delimiter parameter,the character string from the firstcharacter to the first delimiter inthe object name is grouped undera single result element,commonPrefix. (If a prefix isspecified in the request, the prefixmust be removed from the objectname.)

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

ListObjectsResponse Response result of GET Objects

Sample Codetry: resp = obsClient.listObjects('bucketname', prefix='prefix',max_keys=100)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 69

Page 77: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

if resp.status < 300: print('requestId:', resp.requestId) print('name:', resp.body.name) print('prefix:', resp.body.prefix) print('max_keys:', resp.body.max_keys) print('is_truncated:', resp.body.is_truncated) index = 1 for content in resp.body.contents: print('object [' + str(index) + ']') print('key:', content.key) print('lastModified:', content.lastModified) print('etag:', content.etag) print('size:', content.size) print('storageClass:', content.storageClass) print('owner_id:', content.owner.owner_id) print('owner_name:', content.owner.owner_name) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.6 GET Object versions

API Description

You can use this API to list versioning objects in a bucket. By default, a maximumof 1000 versioning objects are listed.

Method DefinitionObsClient.listVersions(bucketName, version)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory Bucket name

version Versions Optional Request parameter of GET Objectversions

Returned Result

Type Description

GetResult SDK common result object

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 70

Page 78: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

GetResult.body Type Description

ObjectVersions Response result of GET Object versions

Sample Codetry: from obs import Versions resp = obsClient.listVersions('bucketname', version=Versions(prefix='prefix',max_keys=100)) if resp.status < 300: print('requestId:', resp.requestId) print('name:', resp.body.head.name) print('prefix:', resp.body.head.prefix) print('maxKeys:', resp.body.head.maxKeys) print('isTruncated:', resp.body.head.isTruncated) index = 1 for version in resp.body.versions: print('version [' + str(index) + ']') print('key:', version.key) print('versionId:', version.versionId) print('lastModified:', version.lastModified) print('etag:', version.etag) print('size:', version.size) print('storageClass:', version.storageClass) print('owner_id:', version.owner.owner_id) print('owner_name:', version.owner.owner_name) index += 1 index = 1 for marker in resp.body.markers: print('marker [' + str(index) + ']') print('key:', marker.key) print('versionId:', marker.versionId) print('lastModified:', marker.lastModified) print('owner_id:', marker.owner.owner_id) print('owner_name:', marker.owner.owner_name) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.7 List Multipart uploads

API DescriptionYou can use this API to list the multipart uploads that are initialized but notcombined or aborted in a specified bucket.

Method DefinitionObsClient.listMultipartUploads(bucketName, multipart)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 71

Page 79: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request Parameter

Field Type OptionalorMandatory

Description

bucket str Mandatory

Bucket name

multipart ListMultipartUploadsRequest

Optional Request parameter of ListMultipart uploads

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

ListMultipartUploadsResponse Response result of List Multipart uploads

Sample Codetry: from obs import ListMultipartUploadsRequest multipart = ListMultipartUploadsRequest(prefix='prefix', max_uploads=10) resp = obsClient.listMultipartUploads('bucketname', multipart) if resp.status < 300: print('requestId:', resp.requestId) print('bucket:', resp.body.bucket) print('prefix:', resp.body.prefix) print('maxUploads:', resp.body.maxUploads) print('isTruncated:', resp.body.isTruncated) index = 1 for upload in resp.body.upload: print('upload [' + str(index) + ']') print('key:', upload.key) print('uploadId:', upload.uploadId) print('storageClass:', upload.storageClass) print('initiated:', upload.initiated) print('owner_id:', upload.owner.owner_id) print('owner_name:', upload.owner.owner_name) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 72

Page 80: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.8 Obtain Bucket Metadata

API DescriptionYou can use this API to send a HEAD request to a bucket to obtain the bucketmetadata such as the storage class and CORS rules (if set).

Method DefinitionObsClient.getBucketMetadata(bucketName, origin, requestHeaders)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

origin str Optional Origin of the cross-domainrequest specified by the pre-request. Generally, it is a domainname.

requestHeaders str Optional HTTP headers in a cross-domainrequest

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

GetBucketMetadataRes-ponse

Response result of Obtain Bucket Metadata

Sample Codetry: resp = obsClient.getBucketMetadata('bucketname', 'http://www.a.com', 'x-obs-header') if resp.status < 300: print('requestId:', resp.requestId) print('storageClass:', resp.body.storageClass) print('accessContorlAllowOrigin:', resp.body.accessContorlAllowOrigin)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 73

Page 81: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

print('accessContorlMaxAge:', resp.body.accessContorlMaxAge) print('accessContorlExposeHeaders:', resp.body.accessContorlExposeHeaders) print('accessContorlAllowMethods:', resp.body.accessContorlAllowMethods) print('accessContorlAllowHeaders:', resp.body.accessContorlAllowHeaders) else: print('status:', resp.status)except: import traceback print(traceback.format_exc())

5.9 GET Bucket location

API DescriptionYou can use this API to obtain the bucket location.

Method DefinitionObsClient.getBucketLocation(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

LocationResponse Response result of GET Bucket location

Sample Codetry: resp = obsClient.getBucketLocation('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('location:', resp.body.location) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 74

Page 82: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

except: import traceback print(traceback.format_exc())

5.10 GET Bucket storageinfo

API Description

You can use this API to obtain storage information about a bucket, including thebucket size and number of objects in the bucket.

Method DefinitionObsClient.getBucketStorageInfo(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory Bucket name

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

GetBucketStorageInfoResponse Response result of GET Bucket storageinfo

Sample Codetry: resp = obsClient.getBucketStorageInfo('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('size:', resp.body.size) print('objectNumber:', resp.body.objectNumber) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 75

Page 83: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.11 PUT Bucket quota

API DescriptionYou can use this API to set the bucket quota. A bucket quota must be expressed inbytes and the maximum value is 263-1. Value 0 indicates that no upper limit is setfor the bucket quota.

Method DefinitionObsClient.setBucketQuota(bucketName, quota)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

quota int Mandatory

Bucket quota. The value is a non-negative integer.

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.setBucketQuota('bucketname', 1024 * 1024 * 1024) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 76

Page 84: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.12 GET Bucket quota

API DescriptionYou can use this API to obtain the bucket quota. Value 0 indicates that no upperlimit is set for the bucket quota.

Method DefinitionObsClient.getBucketQuota(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

GetBucketQuotaResponse Response result of GET Bucket quota

Sample Codetry: resp = obsClient.getBucketQuota('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('quota:', resp.body.quota) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 77

Page 85: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.13 PUT Bucket Storage Policy

API Description

You can use this API to set storage classes for buckets. The storage class of anobject defaults to be that of its residing bucket.

Method DefinitionObsClient.setBucketStoragePolicy(bucketName, storageClass)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

storageClass str Mandatory

Storage class of the bucket

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.setBucketStoragePolicy('bucketname', StorageClass.STANDARD) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.14 GET Bucket storagePolicy

API Description

You can use this API to obtain the storage class of a bucket.

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 78

Page 86: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Method DefinitionObsClient.getBucketStoragePolicy(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

GetBucketStoragePolicyRes-ponse

Response result of GET Bucket storagePolicy

Sample Codetry: resp = obsClient.getBucketStoragePolicy('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('storageClass:', resp.body.storageClass) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.15 Set Bucket ACL

API Description

You can use this API to set the ACL for a bucket.

Method DefinitionObsClient.setBucketAcl(bucketName, acl, aclControl)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 79

Page 87: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optio

nal orMandatory

Description

bucketName str Mandatory

Bucket name

acl ACL Optional

Bucket ACL

aclControl str Optional

Pre-defined access control policy

acl is mutually exclusive with aclControl.

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: from obs import ACL from obs import Owner from obs import Grantee from obs import Grant from obs import Group from obs import Permission owner = Owner(owner_id='ownerid') grantee1 = Grantee(grantee_id='userid') grantee2 = Grantee(group=Group.ALL_USERS) grant1 = Grant(grantee=grantee1, permission=Permission.READ) grant2 = Grant(grantee=grantee1, permission=Permission.WRITE) grant3 = Grant(grantee=grantee2, permission=Permission.WRITE) grant4 = Grant(grantee=grantee2, permission=Permission.READ_ACP) acl = ACL(owner=owner, grants=[grant1, grant2, grant3, grant4]) resp = obsClient.setBucketAcl('bucketname', acl) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 80

Page 88: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.16 GET Bucket acl

API DescriptionYou can use this API to obtain a bucket ACL.

Method DefinitionObsClient.getBucketAcl(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

ACL Bucket ACL

Sample Codetry: resp = obsClient.getBucketAcl('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('owner_id:', resp.body.owner.owner_id) print('owner_name:', resp.body.owner.owner_name) index = 1; for grant in resp.body.grants: print('grant [' + str(index) + ']') print('grant_id:', grant.grantee.grantee_id) print('grant_name:', grant.grantee.grantee_name) print('group:', grant.grantee.group) print('permission:', grant.permission) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 81

Page 89: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

except: import traceback print(traceback.format_exc())

5.17 PUT Bucket logging

API DescriptionYou can use this API to set the access logging settings for a bucket.

Method DefinitionObsClient.setBucketLogging(bucketName, logstatus)

Request ParameterField Type Opti

onalorMandatory

Description

bucketName str Mandatory

Bucket name

logstatus Logging

Optional

Log configuration information

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: from obs import Grantee from obs import Grant from obs import Logging from obs import Group from obs import Permission grantee1 = Grantee(grantee_id='userid', group=None) grantee2 = Grantee(group=Group.ALL_USERS) grant1 = Grant(grantee=grantee1, permission=Permission.READ) grant2 = Grant(grantee=grantee2, permission=Permission.READ) grantList = [grant1, grant2] logstatus = Logging(targetBucket='targetbucketname', targetPrefix='prefix', targetGrants=grantList,

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 82

Page 90: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

agency='your agency') resp = obsClient.setBucketLogging('bucketname', logstatus) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.18 GET Bucket logging

API DescriptionYou can use this API to obtain the access logging settings of a bucket.

Method DefinitionObsClient.getBucketLogging(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

Logging Log configuration information

Sample Codetry: resp = obsClient.getBucketLogging('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('targetBucket:', resp.body.targetBucket)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 83

Page 91: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

print('targetPrefix:', resp.body.targetPrefix) index = 1 for grant in resp.body.targetGrants: print('grant [' + str(index) + ']') print('grant_id:', grant.grantee.grantee_id) print('grant_name:', grant.grantee.grantee_name) print('group:', grant.grantee.group) print('permission:', grant.permission) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.19 PUT Bucket policy

API DescriptionYou can use this API to set a bucket policy. If the bucket already has a policy, thepolicy will be overwritten by the one specified in this request.

Method DefinitionObsClient.setBucketPolicy(bucketName, policyJSON)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

policyJSON str Mandatory

Policy information in JSONformat. For details about theformat, see Policy Format.

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.setBucketPolicy('bucketname', 'your policy') if resp.status < 300:

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 84

Page 92: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.20 GET Bucket policy

API Description

You can use this API to obtain the policy of a bucket.

Method DefinitionObsClient.getBucketPolicy(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

Policy Bucket policy

Sample Codetry: resp = obsClient.getBucketPolicy('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('policyJSON:' , resp.body.policyJSON) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except:

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 85

Page 93: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

import traceback print(traceback.format_exc())

5.21 DELETE Bucket policy

API Description

You can use this API to delete the policy of a bucket.

Method DefinitionObsClient.deleteBucketPolicy(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory Bucket name

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.deleteBucketPolicy('bucketname') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.22 PUT Bucket lifecycle

API Description

You can use this API to set lifecycle rules for a bucket, so as to periodically transitstorage classes of objects and delete objects in the bucket.

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 86

Page 94: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Method DefinitionObsClient.setBucketLifecycle(bucketName, lifecycle)

Request Parameter

Field Type Optional orMandatory

Description

bucketName str Mandatory Bucket name

lifecycle Lifecycle Mandatory Bucket lifecyclerules

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: from obs import Expiration, NoncurrentVersionExpiration from obs import DateTime from obs import Rule from obs import Lifecycle rule1 = Rule(id='rule1', prefix='prefix1', status='Enabled', expiration=Expiration(days=60), noncurrentVersionExpiration=NoncurrentVersionExpiration(noncurrentDays=60)) rule2 = Rule(id='rule2', prefix='prefix2', status='Enabled', expiration=Expiration(date=DateTime(2018, 12, 31))) lifecycle = Lifecycle(rule=[rule1, rule2]) resp = obsClient.setBucketLifecycle('bucketname', lifecycle) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.23 GET Bucket lifecycle

API Description

You can use this API to obtain the lifecycle rules of a bucket.

Method DefinitionObsClient.getBucketLifecycle(bucketName)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 87

Page 95: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

LifecycleResponse Response result of GET Bucket lifecycle

Sample Codetry: resp = obsClient.getBucketLifecycle('bucketname') if resp.status < 300: print('requestId:', resp.requestId) index = 1 for rule in resp.body.lifecycleConfig.rule: print('rule [' + str(index) + ']') print('id:', rule.id) print('prefix:', rule.prefix) print('status:', rule.status) if rule.expiration: print('days:' , rule.expiration.days) print('date:' , rule.expiration.date) if rule.noncurrentVersionExpiration: print('noncurrentDays:' , rule.noncurrentVersionExpiration.noncurrentDays) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.24 DELETE Bucket lifecycle

API Description

You can use this API to delete all lifecycle rules of a bucket.

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 88

Page 96: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Method DefinitionObsClient.deleteBucketLifecycle(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.deleteBucketLifecycle('bucketname') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.25 PUT Bucket website

API Description

You can use this API to set website hosting for a bucket.

Method DefinitionObsClient.setBucketWebsite(bucketName, website)

Request Parameter

Field Type Optional orMandatory

Description

bucketName str Mandatory Bucket name

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 89

Page 97: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

website WebsiteConfiguration

Mandatory Website hosting settings of thebucket

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: from obs import WebsiteConfiguration from obs import IndexDocument from obs import ErrorDocument from obs import RoutingRule from obs import Condition from obs import Redirect errorDocument = ErrorDocument(key='error.html') indexDocument = IndexDocument(suffix='index.html') routingRule1 = RoutingRule(condition=Condition(httpErrorCodeReturnedEquals=404), redirect=Redirect(protocol='http', replaceKeyWith='NotFound.html')) routingRule2 = RoutingRule(condition=Condition(httpErrorCodeReturnedEquals=404), redirect=Redirect(protocol='https', replaceKeyWith='test.html')) routingRules = [routingRule1, routingRule2] resp = obsClient.setBucketWebsite('bucketname', WebsiteConfiguration(errorDocument=errorDocument, indexDocument=indexDocument, routingRules=routingRules)) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.26 GET Bucket website

API DescriptionYou can use this API to obtain the website hosting settings of a bucket.

Method DefinitionObsClient.getBucketWebsite(bucketName)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 90

Page 98: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

WebsiteConfiguration Website hosting settings of the bucket

Sample Codetry: resp = obsClient.getBucketWebsite('bucketname') if resp.status < 300: print('requestId:', resp.requestId) if resp.body.redirectAllRequestTo: print('redirectAllRequestTo.hostName:', resp.body.redirectAllRequestTo.hostName, ',redirectAllRequestTo.protocol:', resp.body.redirectAllRequestTo.protocol) if resp.body.indexDocument: print('indexDocument.suffix:', resp.body.indexDocument.suffix) if resp.body.errorDocument: print('errorDocument.key:', resp.body.errorDocument.key) if resp.body.routingRules: index = 1 for rout in resp.body.routingRules: print('routingRule[', index, ']:') index += 1 print('condition.keyPrefixEquals:', rout.condition.keyPrefixEquals, ',condition.httpErrorCodeReturnedEquals:', rout.condition.httpErrorCodeReturnedEquals) print('redirect.protocol:', rout.redirect.protocol, ',redirect.hostName:', rout.redirect.hostName, ',redirect.replaceKeyPrefixWith:', rout.redirect.replaceKeyPrefixWith, ',redirect.replaceKeyWith:', rout.redirect.replaceKeyWith, ',redirect.httpRedirectCode:', rout.redirect.httpRedirectCode) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 91

Page 99: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.27 DELETE Bucket website

API Description

You can use this API to delete the website hosting settings of a bucket.

Method DefinitionObsClient.deleteBucketWebsite(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.deleteBucketWebsite('bucketname') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.28 PUT Bucket versioning

API Description

You can use this API to set the versioning status for a bucket.

Method DefinitionObsClient.setBucketVersioning(bucketName, status)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 92

Page 100: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

status str Mandatory

Versioning status of the bucket.Possible values are:● Enabled● Suspended

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.setBucketVersioning('bucketname', 'Enabled') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.29 GET Bucket versioning

API DescriptionYou can use this API to obtain the versioning status of a bucket.

Method DefinitionObsClient.getBucketVersioning(bucketName)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 93

Page 101: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

str Versioning status of the bucket

Sample Codetry: resp = obsClient.getBucketVersioning('bucketname') if resp.status < 300: print('requestId:', resp.requestId) print('status:', resp.body) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.30 PUT Bucket cors

API DescriptionYou can use this API to set CORS rules for a bucket to allow client browsers tosend cross-domain requests.

Method DefinitionObsClient.setBucketCors(bucketName, corsRuleList)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 94

Page 102: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request Parameter

Field Type OptionalorMandatory

Description

bucketName

str Mandatory Bucket name

corsRuleList

list ofCorsRule

Mandatory CORS rule list of the bucket

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: from obs import CorsRule cors1 = CorsRule(id='rule1', allowedMethod=['PUT', 'POST', 'GET', 'DELETE', 'HEAD'], allowedOrigin=['obs.hostname', 'obs.hostname1'], allowedHeader=['obs-header-1'], maxAgeSecond=60) cors2 = CorsRule(id='rule2', allowedMethod=['PUT', 'POST', 'GET'], allowedOrigin=['obs.hostname', 'obs.hostname1'], allowedHeader=['header-1', 'header-2'], maxAgeSecond=50, exposeHeader=['head1']) corsList = [cors1, cors2] resp = obsClient.setBucketCors('bucketname', corsList) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.31 GET Bucket cors

API Description

You can use this API to obtain the CORS rules of a specified bucket.

Method DefinitionObsClient.getBucketCors(bucketName)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 95

Page 103: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

list of CorsRule CORS rule list of the bucket

Sample Codetry: resp = obsClient.getBucketCors('bucketname') if resp.status < 300: print('requestId:', resp.requestId) index = 1 for rule in resp.body: print('corsRule [' + str(index) + ']') print('id:', rule.id) print('allowedMethod', rule.allowedMethod) print('allowedOrigin', rule.allowedOrigin) print('allowedHeader', rule.allowedHeader) print('maxAgeSecond', rule.maxAgeSecond) print('exposeHeader', rule.exposeHeader) index +=1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.32 DELETE Bucket cors

API DescriptionYou can use this API to delete the CORS rules of a specified bucket.

Method DefinitionObsClient.deleteBucketCors(bucketName)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 96

Page 104: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.deleteBucketCors('bucketname') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.33 PUT Bucket notification

API DescriptionYou can use this API to configure event notification for a bucket. You will benotified of all specified operations performed on the bucket.

Method DefinitionObsClient.setBucketNotification(bucketName, notification)

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 97

Page 105: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

notification Notification

Optional

Bucket event notification settings

Returned Result

Type Description

GetResult SDK common result object

Sample Codetry: from obs import Notification, TopicConfiguration,FilterRule, EventType, FunctionGraphConfiguration fr1 = FilterRule(name='prefix', value='smn') fr2 = FilterRule(name='suffix', value='.jpg') topicConfiguration= TopicConfiguration(id='001',topic='your topic',events=[EventType.OBJECT_CREATED_ALL], filterRules=[fr1,fr2]) fr3 = FilterRule(name='prefix', value='function') fr4 = FilterRule(name='suffix', value='.mp4') functionConfiguration = FunctionGraphConfiguration(id='002', functionGraph='your function', events=[EventType.OBJECT_CREATED_ALL], filterRules=[fr3, fr4]) resp = obsClient.setBucketNotification('bucketname', Notification(topicConfigurations=[topicConfiguration], functionGraphConfigurations=[functionConfiguration]))

if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

5.34 GET Bucket notification

API Description

You can use this API to obtain the event notification configuration of a bucket.

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 98

Page 106: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Method DefinitionObsClient.getBucketNotification(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory Bucket name

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

Notification Bucket event notification settings

Sample Codetry: resp = obsClient.getBucketNotification('bucketname') if resp.status < 300: print('requestId:', resp.requestId) for topicConfiguration in resp.body.topicConfigurations: print('id:', topicConfiguration.id) print('topic:', topicConfiguration.topic) print('events:', topicConfiguration.events) index = 1 for rule in topicConfiguration.filterRules: print('rule [' + str(index) + ']') print('name:', rule.name) print('value:', rule.value)

for functionGraphConfiguration in resp.body.functionGraphConfigurations: print('id:', functionGraphConfiguration.id) print('functionGraph:', functionGraphConfiguration.functionGraph) print('events:', functionGraphConfiguration.events) index = 1 for rule in functionGraphConfiguration.filterRules: print('rule [' + str(index) + ']') print('name:', rule.name) print('value:', rule.value)

else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 99

Page 107: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.35 PUT Bucket tagging

API DescriptionYou can use this API to set bucket tags.

Method DefinitionObsClient.setBucketTagging(bucketName, tagInfo)

Request ParameterField Type Option

al orMandatory

Description

bucketName

str Mandatory

Bucket name

tagInfo TagInfo Mandatory

Bucket tag set

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: from obs import TagInfo tagInfo = TagInfo() tagInfo.addTag('tag1', 'value1').addTag('tag2', 'value2') resp = obsClient.setBucketTagging('bucketname', tagInfo) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 100

Page 108: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.36 GET Bucket tagging

API Description

You can use this API to obtain the tags of a specified bucket.

Method DefinitionObsClient.getBucketTagging(bucketName)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

TagInfo Bucket tag set

Sample Codetry: resp = obsClient.getBucketTagging('bucketname') if resp.status < 300: print('requestId:', resp.requestId) index = 1 for tag in resp.body.tagSet: print('tag [' + str(index) + ']') print('key:', tag.key) print('value:', tag.value) index +=1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 101

Page 109: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

5.37 DELETE Bucket tagging

API DescriptionYou can use this API to delete the tags of a specified bucket.

Method DefinitionObsClient.deleteBucketTagging(bucketName)

Request ParameterField Type Optional

orMandatory

Description

bucketName String Mandatory

Bucket name

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.deleteBucketTagging('bucketname') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 5 Bucket-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 102

Page 110: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

6 Objects-Related APIs

6.1 Uploading an Object

API DescriptionYou can use this API to upload an object to a specified bucket.

Method Definition1. ObsClient.putContent(bucketName, objectKey, content, metadata, headers, autoClose)2. ObsClient.putObject(bucketName, objectKey, content, metadata, headers, autoClose)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

content strorreadableobject

Optional Object content to be uploaded

metadata dict Optional Customized metadata of theobject

headers PutObjectHeader

Optional Additional headers in PUT Object

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 103

Page 111: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

progressCallback callable Optional Callback function for obtainingthe upload progressNOTE

This callback function contains thefollowing parameters in sequence:Number of uploaded bytes, totalbytes, and used time (unit: second).

autoClose bool Optional After the upload is complete, dataflow is automatically closed. Thedefault value is True.

If content is a readable object that contains the read attribute, data can be read fromcontent. Otherwise, the object content is a character string.

Returned ResultType Description

GetResult SDK common result object

GetResult.bodyType

Description

PutContentResponse

Response result of PUT Object

Sample Codetry: from obs import PutObjectHeader headers = PutObjectHeader() headers.contentType = 'text/plain' resp = obsClient.putContent('bucketname', 'objectkey', 'Hello OBS', metadata={'meta1':'value1', 'meta2':'value2'}, headers=headers) if resp.status < 300: print('requestId:', resp.requestId) print('etag:', resp.body.etag) print('versionId:', resp.body.versionId) print('storageClass:', resp.body.storageClass) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 104

Page 112: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

except: import traceback print(traceback.format_exc())

6.2 PUT File

API DescriptionYou can use this API to upload a file or folder to a specified bucket.

Method DefinitionObsClient.putFile(bucketName, objectKey, file_path, metadata, headers)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

file_path str Mandatory

Path to the file or folder to beuploaded

metadata dict Optional Customized metadata of theobject

headers PutObjectHeader

Optional Additional headers of the file

progressCallback callable Optional Callback function for obtainingthe upload progressNOTE

This callback function contains thefollowing parameters in sequence:Number of uploaded bytes, totalbytes, and used time (unit: second).

If file_path is a folder, contentLength, md5, and contentType in headers cannot takeeffect.

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 105

Page 113: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Returned ResultType Description

GetResult SDK common result object

GetResult.bodyType

Description

PutContentResponse

Response result of PUT Object

If file_path is a folder, the returned result is a list of GetResult.

Sample Codetry: from obs import PutObjectHeader headers = PutObjectHeader() headers.contentType = 'text/plain' resp = obsClient.putFile('bucketname', 'objectkey', 'localfile', metadata={'meta1':'value1', 'meta2':'value2'}, headers=headers) if resp.status < 300: print('requestId:', resp.requestId) print('etag:', resp.body.etag) print('versionId:', resp.body.versionId) print('storageClass:', resp.body.storageClass) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.3 Append Object

API DescriptionYou can use this API to upload an object in appendable mode and append data tothe object.

Method DefinitionObsClient.appendObject(bucketName, objectKey, content, metadata, headers, autoClose)

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 106

Page 114: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

content AppendObjectContent

Mandatory

Content to be appended

metadata dict Optional Customized metadata for theappendable upload. Thisparameter is effective only duringthe appendable object creation.

headers AppendObjectHeader

Optional Additional headers in AppendObject. This parameter is effectiveonly during the appendableobject creation.

progressCallback callable Optional Callback function for obtainingthe upload progressNOTE

This callback function contains thefollowing parameters in sequence:Number of uploaded bytes, totalbytes, and used time (unit: second).

autoClose bool Optional After the upload is complete, dataflow is automatically closed. Thedefault value is True.

Returned Result

Type Description

GetResult SDK common result object

GetResult.bodyType

Description

AppendObjectResponse

Response result of Append Object

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 107

Page 115: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Sample Codetry: from obs import AppendObjectContent content = AppendObjectContent() content.content = 'Hello OBS' content.position = 0 resp = obsClient.appendObject('bucketname', 'objectkey', content=content)

if resp.status < 300: print('requestId:', resp.requestId) print('nextPosition:', resp.body.nextPosition) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.4 GET Object

API DescriptionYou can use this API to download an object in a specified bucket.

Method DefinitionObsClient.getObject(bucketName, objectKey, downloadPath, getObjectRequest, headers, loadStreamInMemory)

Request ParameterField Type Option

al orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

downloadPath str Optional

Target path to which the object isdownloaded (containing the filename)

getObjectRequest GetObjectRequest

Optional

Additional request parameter ofGET Object

headers GetObjectHeader

Optional

Additional headers in GET Object

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 108

Page 116: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

loadStreamInMemory

bool Optional

Whether to load the data streamof the object to the memory. Thedefault value is False. If the valueis True, the downloadPathparameter will be ineffective andthe obtained data stream will bedirectly loaded to the memory.

progressCallback callable Optional

Callback function for obtaining thedownload progressNOTE

This callback function contains thefollowing parameters in sequence:Number of downloaded bytes, totalbytes, and used time (unit: second).

Returned ResultType Description

GetResult SDK common result object

GetResult.bodyType

Description

ObjectStream Response result of GET Object

Sample Codetry: from obs import GetObjectHeader headers = GetObjectHeader() headers.range = '0-10' resp = obsClient.getObject('bucketname', 'objectkey', headers=headers, loadStreamInMemory=True) if resp.status < 300: print('requestId:', resp.requestId) print('buffer:', resp.body.buffer) print('size:', resp.body.size) print('contentLength', resp.body.contentLength) print('etag', resp.body.etag) print('lastModified', resp.body.lastModified) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except:

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 109

Page 117: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

import traceback print(traceback.format_exc())

6.5 PUT Object - Copy

API DescriptionYou can use this API to create a copy for an object in a specified bucket.

Method DefinitionObsClient.copyObject(sourceBucketName, sourceObjectKey, destBucketName, destObjectKey, metadata, headers, versionId)

Request ParameterField Type Optional

orMandatory

Description

sourceBucketName

str Mandatory

Source bucket name

sourceObjectKey str Mandatory

Source object name

versionId str Optional Source object version ID

destBucketName str Mandatory

Target bucket name

destObjectKey str Mandatory

Target object name

metadata dict Optional Customized metadata of thetarget object

headers CopyObjectHeader

Optional Additional headers in PUT Object -Copy

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

CopyObjectResponse Response result of PUT Object - Copy

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 110

Page 118: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Sample Codetry: resp = obsClient.copyObject('sourcebucketname', 'sourceobjectkey', 'destbucketname', 'destobjectkey', metadata={'meta1' : 'value1'}) if resp.status < 300: print('requestId:', resp.requestId) print('etag:', resp.body.etag) print('lastModified:', resp.body.lastModified) print('versionId:', resp.body.versionId) print('copySourceVersionId:', resp.body.copySourceVersionId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.6 DELETE Object

API DescriptionYou can use this API to delete an object from a specified bucket.

Method DefinitionObsClient.deleteObject(bucketName, objectKey, versionId)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

versionId str Optional Version ID of the object to bedeleted

Returned ResultType Description

GetResult SDK common result object

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 111

Page 119: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

GetResult.body Type Description

DeleteObjectResponse Response result of DELETE Object

Sample Codetry: resp = obsClient.deleteObject('bucketname', 'objectkey') if resp.status < 300: print('requestId:', resp.requestId) print('deleteMarker:', resp.body.deleteMarker) print('versionId:', resp.body.versionId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.7 DELETE Objects

API Description

You can use this API to delete objects from a specified bucket in a batch.

Method DefinitionObsClient.deleteObjects(bucketName, deleteObjectsRequest)

Request Parameter

Field Type Optional orMandatory

Description

bucketName str Mandatory

Bucket name

deleteObjectsRe-quest

DeleteObjectsRe-quest

Mandatory

Request parameter ofDELETE Objects

Returned Result

Type Description

GetResult SDK common result object

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 112

Page 120: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

GetResult.bodyType

Description

DeleteObjectsRes-ponse

Response result of DELETE Objects

Sample Codetry: from obs import DeleteObjectsRequest, Object object1 = Object(key='objectkey', versionId=None) object2 = Object(key='objectkey2', versionId=None) resp = obsClient.deleteObjects('bucketname', DeleteObjectsRequest(quiet=False, objects=[object1, object2])) if resp.status < 300: print('requestId:', resp.requestId) if resp.body.deleted: index = 1 for delete in resp.body.deleted: print('delete[' + str(index) + ']') print('key:', delete.key, ',deleteMarker:', delete.deleteMarker, ',deleteMarkerVersionId:', delete.deleteMarkerVersionId) print('versionId:', delete.versionId) index += 1 if resp.body.error: index = 1 for err in resp.body.error: print('err[' + str(index) + ']') print('key:', err.key, ',code:', err.code, ',message:', err.message) print('versionId:', err.versionId) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.8 Obtain Object Metadata

API DescriptionYou can use this API to send a HEAD request to the object of a specified bucket toobtain its metadata.

Method DefinitionObsClient.getObjectMetadata(bucketName, objectKey, versionId, sseHeader, origin, requestHeaders)

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 113

Page 121: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

versionId str Optional Object version ID

origin str Optional Origin of the cross-domainrequest specified by the pre-request. Generally, it is a domainname.

requestHeaders str Optional HTTP headers in a cross-domainrequest

sseHeader SseCHeader

Optional Header for server-side decryption

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

GetObjectMetadataResponse Response result of Obtain Object Metadata

Sample Codetry: resp = obsClient.getObjectMetadata('bucketname', 'objectkey') if resp.status < 300: print('requestId:', resp.requestId) print('etag:', resp.body.etag) print('lastModified:', resp.body.lastModified) print('contentType:', resp.body.contentType) print('contentLength:', resp.body.contentLength) else: print('status:', resp.status)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 114

Page 122: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

6.9 PUT Object ACL

API DescriptionYou can use this API to set the ACL for an object in a specified bucket.

Method DefinitionObsClient.setObjectAcl(bucketName, objectKey, acl, versionId, aclControl)

Request ParameterField Type Option

al orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

acl ACL Optional

Object ACL

versionId str Optional

Object version ID

aclControl str Optional

Pre-defined access control policy

acl is mutually exclusive with aclControl.

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: from obs import ACL from obs import Owner from obs import Grant, Permission from obs import Grantee, Group owner = Owner(owner_id='ownerid')

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 115

Page 123: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

grantee = Grantee(grantee_id='userid') grant0 = Grant(grantee=grantee, permission=Permission.READ) grant0 = Grant(grantee=grantee, permission=Permission.WRITE) grant1 = Grant(grantee=Grantee(group=Group.ALL_USERS), permission=Permission.READ) grant2 = Grant(grantee=Grantee(group=Group.ALL_USERS), permission=Permission.WRITE) acl = ACL(owner=owner, grants=[grant0, grant1, grant2]) resp = obsClient.setObjectAcl('bucketname', 'objectkey', acl=acl) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.10 GET Object acl

API DescriptionYou can use this API to obtain the ACL of an object in a specified bucket.

Method DefinitionObsClient.getObjectAcl(bucketName, objectKey, versionId)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

versionId str Optional Object version ID

Returned ResultType Description

GetResult SDK common result object

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 116

Page 124: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

GetResult.body Type Description

ACL Object ACL

Sample Codetry: resp = obsClient.getObjectAcl('bucketname', 'objectkey') if resp.status < 300: print('requestId:', resp.requestId) print('owner_id:', resp.body.owner.owner_id) print('owner_name:', resp.body.owner.owner_name) index = 1 for grant in resp.body.grants: print('grant [' + str(index) + ']') print('grantee_id:', grant.grantee.grantee_id) print('grantee_name:', grant.grantee.grantee_name) print('group:', grant.grantee.group) print('permission:', grant.permission) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.11 Initiate Multipart Upload

API Description

You can use this API to initialize a multipart upload in a specified bucket.

Method DefinitionObsClient.initiateMultipartUpload(bucketName, objectKey, acl, storageClass, metadata, websiteRedirectLocation, contentType, sseHeader, expires, extensionGrants)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

acl str Optional Pre-defined access controlpolicy

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 117

Page 125: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

storageClass str Optional Storage class of the object

metadata dict Optional Customized metadata of theobject

websiteRedirect-Location

str Optional Location where the object isredirected to, when the bucket isconfigured with website hosting.

contentType str Optional MIME type of the object

sseHeader SseCHeaderorSseKmsHeader

Optional Header for server-side encryption

expires int Optional Expiration time of the object, indays

extensionGrants list ofExtensionGrant

Optional Extended permission list of theobject

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

InitiateMultipartUploadRes-ponse

Response result of Initiate Multipart Upload

Sample Codetry: resp = obsClient.initiateMultipartUpload('bucketname', 'objectkey', contentType='text/plain') if resp.status < 300: print('requestId:', resp.requestId) print('bucketName:', resp.body.bucketName) print('objectKey:', resp.body.objectKey) print('uploadId:', resp.body.uploadId) else:

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 118

Page 126: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.12 PUT Part

API Description

After a multipart upload is initialized, you can use this API to upload a part to aspecified bucket by using the multipart upload ID. Except for the part lastuploaded whose size ranges from 0 to 5 GB, sizes of the other parts range from100 KB to 5 GB. The upload part ID ranges from 1 to 10000.

Method DefinitionObsClient.uploadPart(bucketName, objectKey, partNumber, uploadId, object, isFile, partSize, offset, sseHeader, isAttachMd5, md5, autoClose)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

partNumber int Mandatory

Part number, which ranges from 1to 10000

uploadId str Mandatory

Multipart upload ID

object strorreadableobject

Mandatory

Part content to be uploaded

isFile bool Optional Whether object indicates the filepath. The default value is False.

offset int Optional Start offset (in bytes) of a part inthe source file. The default valueis 0.

partSize int Optional Size (in bytes) of a part in thesource file. The default value isthe file size minus offset.

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 119

Page 127: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

sseHeader SseCHeader

Optional Header for server-side encryption

isAttachMd5 bool Optional Whether to automaticallycalculate the MD5 value of thedata to be uploaded. If md5 isconfigured, this field will beignored

md5 str Optional Base64-encoded MD5 value of thepart to be uploaded. It is providedfor the OBS server to verify dataintegrity.

progressCallback callable Optional Callback function for obtainingthe upload progressNOTE

This callback function contains thefollowing parameters in sequence:Number of uploaded bytes, totalbytes, and used time (unit: second).

autoClose bool Optional After the upload is complete, dataflow is automatically closed. Thedefault value is True.

● If isAttachMd5 and md5 are used at the same time, md5 prevails.

● If isFile is True, object indicates the path to the file to be uploaded. If isFile is Falseand object is a readable object that contains the read attribute, data can be read fromthe object, otherwise the object content is a character string.

Returned Result

Type Description

GetResult SDK common result object

GetResult.bodyType

Description

UploadPartResponse

Response result of PUT Part

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 120

Page 128: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Sample Codetry: resp = obsClient.uploadPart('bucketname', 'objectkey', 1, 'uploadid', 'Hello OBS') if resp.status < 300: print('requestId:', resp.requestId) print('etag:', resp.body.etag) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.13 PUT Part - Copy

API DescriptionAfter a multipart upload is initialized, you can use this API to copy a part to aspecified bucket by using the multipart upload ID.

Method DefinitionObsClient.copyPart(bucketName, objectKey, partNumber, uploadId, copySource, copySourceRange, destSseHeader, sourceSseHeader)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

partNumber int Mandatory

Part number, which ranges from 1to 10000

uploadId str Mandatory

Multipart upload ID

copySource str Mandatory

Parameter used to specify thesource bucket, source object, andsource object version ID whichcan be null. It is in the format ofSourceBucketName/SourceObjectName?versionId=SourceObjectVersionId.

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 121

Page 129: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

copySourceRange str Optional Copy range of the source object.The value range is [0, sourceobject length-1] and is in theformat of x-y. If the maximumlength of copySourceRange islarger than the length of thesource object minus 1, the lengthof the source object minus 1 isused.

destSseHeader SseCHeaderorSseKmsHeader

Optional Header for server-side encryption.It is used to encrypt the targetobject.

sourceSseHeader SseCHeader

Optional Header for server-side decryption.It is used to decrypt the sourceobject.

Returned Result

Type Description

GetResult SDK common result object

GetResult.body Type Description

CopyPartResponse Response result of PUT Part - Copy

Sample Codetry: resp = obsClient.copyPart('bucketname', 'objectkey', 1, 'uploadid', 'sourcebucketname/sourceobjectkey', '0-15') if resp.status < 300: print('requestId:', resp.requestId) print('etagValue:', resp.body.etagValue) print('modifiedDate:', resp.body.modifiedDate) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 122

Page 130: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

6.14 List Parts

API DescriptionYou can use this API to list the uploaded parts in a bucket by using the multipartupload ID.

Method DefinitionObsClient.listParts(bucketName, objectKey, uploadId, maxParts, partNumberMarker)

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

uploadId str Mandatory

Multipart upload ID

maxParts int Optional Maximum number of uploadedparts that can be listed per page

partNumberMarker

int Optional Part number after which listinguploaded parts begins. Only partswhose part numbers are largerthan this value will be listed.

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

ListPartsResponse Response result of List Parts

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 123

Page 131: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Sample Codetry: resp = obsClient.listParts('bucketname', 'objectkey', 'uploadid', 10) if resp.status < 300: print('requestId:', resp.requestId) print('bucketName:', resp.body.bucketName) print('objectKey:', resp.body.objectKey) print('uploadId:', resp.body.uploadId) print('storageClass:', resp.body.storageClass) print('isTruncated:', resp.body.isTruncated) print('initiator:', resp.body.initiator) print('owner:', resp.body.owner) index = 1 for part in resp.body.parts: print('part [' + str(index) + ']') print('partNumber:', part.partNumber) print('lastModified:', part.lastModified) print('etag:', part.etag) print('size:', part.size) index += 1 else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.15 Complete Multipart Upload

API DescriptionYou can use this API to combine the uploaded parts in a specified bucket by usingthe multipart upload ID.

Method DefinitionObsClient.completeMultipartUpload(bucketName, objectKey, uploadId, completeMultipartUploadRequest)

Request Parameter

Field Type Optional orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

uploadId str Mandatory

Multipart upload ID

completeMultipartUploadRequest

CompleteMultipartUploadRequest

Mandatory

Request parameter of CompleteMultipart Upload

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 124

Page 132: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Returned ResultType Description

GetResult SDK common result object

GetResult.body Type Description

CompleteMultipartUploadRes-ponse

Response result of Complete MultipartUpload

Sample Codetry: from obs import CompleteMultipartUploadRequest, CompletePart part1 = CompletePart(partNum=1, etag='etag1') part2 = CompletePart(partNum=2, etag='etag2') completeMultipartUploadRequest = CompleteMultipartUploadRequest(parts=[part1, part2]) resp = obsClient.completeMultipartUpload('bucketname', 'objectkey', 'uploadid', completeMultipartUploadRequest) if resp.status < 300: print('requestId:', resp.requestId) print('etag:', resp.body.etag) print('bucket:', resp.body.bucket) print('key:', resp.body.key) print('location:', resp.body.location) print('versionId:', resp.body.versionId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.16 DELETE Multipart upload

API DescriptionYou can use this API to abort a multipart upload in a specified bucket by using themultipart upload ID.

Method DefinitionObsClient.abortMultipartUpload(bucketName, objectKey, uploadId)

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 125

Page 133: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

uploadId str Mandatory

Multipart upload ID

Returned ResultType Description

GetResult SDK common result object

Sample Codetry: resp = obsClient.abortMultipartUpload('bucketname', 'objectkey', 'uploadid') if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

6.17 POST Object restore

API DescriptionYou can use this API to restore an object in the OBS Archive storage class in aspecified bucket.

Method DefinitionObsClient.restoreObject(bucketName, objectKey, days, tier, versionId)

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 126

Page 134: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Request ParameterField Type Optional

orMandatory

Description

bucketName str Mandatory

Bucket name

objectKey str Mandatory

Object name

days int Mandatory

Retention period of the restoredobject, in days. The value rangesfrom 1 to 30.

tier str Optional Restore option

versionId str Optional Version ID of the to-be-restoredobject in the OBS Archive storageclass

Returned ResultType Description

GetResult SDK common result object

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

Sample Codetry: 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())

Object Storage ServicePython SDK API Reference 6 Objects-Related APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 127

Page 135: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

7 Other APIs

7.1 Create Signed URL

API DescriptionYou can use this API to generate a URL whose Query parameter is carried withauthentication information, by specifying the AK and SK, HTTP method, andrequest parameter. You can use a signed URL to perform specific operations onOBS.

Method DefinitionObsClient.createSignedUrl(method, bucketName, objectKey, specialParam, expires, headers, queryParams)

Request ParameterField Type Optional or

MandatoryDescription

method str Mandatory HTTP method. Possible values are:● GET● POST● PUT● DELETE● HEAD

bucketName

str Optional Bucket name

objectKey str Optional Object name

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 128

Page 136: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

specialParam

str Optional Special operator, which indicatesthe sub-resource to be operated.Possible values are:● versions● uploads● location● storageinfo● quota● storagePolicy● acl● append● logging● policy● lifecycle● website● versioning● cors● notification● tagging● delete● restore

expires int Optional Expiration time of the signed URL,in seconds. The default value is300.

headers dict Optional Headers in the request

queryParams

dict Optional Query parameters in the request

Returned ResultField Type Description

signedUrl str URL with authentication information

actualSignedRequestHeaders

dict Actual headers in the request initiated by usingthe signed URL

Sample Codetry: # Generate a signed URL for creating a bucket.

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 129

Page 137: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

res = obsClient.createSignedUrl('PUT', 'bucketname', expires= 3600) print('signedUrl:', res.signedUrl) print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders) # Generate a signed URL for uploading an object. res = obsClient.createSignedUrl('PUT', 'bucketname', 'objectkey', expires= 3600, headers={'Content-Type' : 'text/plain'}) print('signedUrl:', res.signedUrl) print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders) # Generate a signed URL for setting an object ACL. res = obsClient.createSignedUrl('PUT', 'bucketname', 'objectkey', 'acl', expires= 3600, headers={'x-obs-acl' : 'public-read'}) print('signedUrl:', res.signedUrl) print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders) # Generate a signed URL for downloading an object. res = obsClient.createSignedUrl('GET', 'bucketname', 'objectkey', expires= 3600) print('signedUrl:', res.signedUrl) print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders) # Generate a signed URL for deleting an object. res = obsClient.createSignedUrl('DELETE', 'bucketname', 'objectkey', expires= 3600) print('signedUrl:', res.signedUrl) print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders) # Generate a signed URL for deleting a bucket. res = obsClient.createSignedUrl('DELETE', 'bucketname', expires= 3600) print('signedUrl:', res.signedUrl) print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders) except: import traceback print(traceback.format_exc())

7.2 Generating Browser-Based Upload Parameters withAuthentication Information

API Description

You can use this API to generate parameters for authentication. The parameterscan be used to upload data through POST operations based on a browser.

There are two request parameters generated:

● policy, which corresponds to the policy field in the form

● signature: corresponds to the signature field in the form.

Method DefinitionObsClient.createPostSignature(bucketName, objectKey, expires, formParams)

Request Parameter

Field Type OptionalorMandatory

Description

bucketName str Optional Bucket name

objectKey str Optional Object name, which correspondsto the key field in the form.

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 130

Page 138: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type OptionalorMandatory

Description

expires int Optional Validity period of the browser-based upload authentication, inseconds. The default value is 300.

formParams dict Optional Other parameters of the browser-based upload except for key,policy, and signature. Possiblevalues are:● acl● cache-control● content-type● content-disposition● content-encoding● expires

Returned ResultField Type Description

originPolicy str Value of policy that is not encoded bybase64. This parameter can only be usedfor verification.

policy str policy in the form

signature str signature in the form

Sample Codetry: formParams = {'acl': 'public-read', 'content-type': 'text/plain'} resp = obsClient.createPostSignature('bucketname', 'objectkey', 3600, formParams) print('originPolicy:', resp.originPolicy) print('policy:', resp.policy) print('signature:', resp.signature)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 131

Page 139: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

7.3 Upload File (Resumable Upload)

API Description

This API is an encapsulated and enhanced version of multipart upload, and aimsto eliminate large file upload failures caused by poor network conditions andprogram breakdowns.

Method DefinitionObsClient.uploadFile(bucketName, objectKey, uploadFile, partSize, taskNum, enableCheckpoint, checkpointFile, checkSum, metadata, progressCallback, headers)

Request Parameter

Field Type Optional orMandatory

Description

bucketName str Mandatory Bucket name

objectKey str Mandatory Object name

uploadFile str Mandatory Local file to be uploaded

partSize int Optional Part size, in bytes. The valueranges from 100 KB to 5 GB anddefaults to 9 MB.

taskNum int Optional Maximum number of parts thatcan be concurrently uploaded.The default value is 1.

enableCheckpoint

bool Optional Whether to enable the resumableupload mode. The default valueis False, which indicates that thismode is disabled.

checkpointFile

str Optional File used to record the uploadprogress. This parameter iseffective only in the resumableupload mode. If the value of thisparameter is null, the file will bein the same directory as the localfile to be uploaded.

checkSum bool Optional Whether to verify the content ofthe to-be-uploaded file. Thisparameter is valid only in theresumable upload mode. Thedefault value is False, whichindicates that the content of thefile will not be verified.

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 132

Page 140: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

metadata dict Optional Customized metadata of theobject

progressCallback

callable Optional Callback function for obtainingthe upload progressNOTE

This callback function contains thefollowing parameters in sequence:Number of uploaded bytes, totalbytes, and used time (unit: second).

headers UploadFileHeader

Optional Additional headers in PUT Object

Returned ResultType Description

GetResult SDK common result object

GetResult.bodyType

Description

CompleteMultipartUploadResponse

Response result of Complete Multipart Upload

Sample CodeuploadFile = 'localfile'taskNum = 5partSize = 10 * 1024 * 1024enableCheckpoint = Truetry: resp = obsClient.uploadFile('bucketname', 'objectkey', uploadFile, partSize, taskNum, enableCheckpoint) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 133

Page 141: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

7.4 Download File (Resumable Download)

API DescriptionThis API is an encapsulated and enhanced version of partial download, and aimsto eliminate large file download failures caused by poor network conditions andprogram breakdowns.

Method DefinitionObsClient.downloadFile(bucketName, objectKey, downloadFile, partSize, taskNum, enableCheckpoint, checkpointFile, header, versionId)

Request ParameterField Type Optional or

MandatoryDescription

bucketName str Mandatory Bucket name

objectKey str Mandatory Object name

downloadFile str Optional Full path of the local directory towhich the object is downloaded. Ifthe value is None, thedownloaded object is saved in thedirectory where the program isexecuted.

partSize int Optional Part size, in bytes. The valueranges from 100 KB to 5 GB anddefaults to 5 MB.

enableCheckpoint

bool Optional Whether to enable the resumabledownload mode. The defaultvalue is False, which indicatesthat this mode is disabled.

checkpointFile

str Optional File used to record the downloadprogress. This parameter iseffective only in the resumabledownload mode. If the value isNone, the file is in the same localdirectory as the downloadedobject.

header GetObjectHeader

Optional Additional header in GET Object

versionId str Optional Object version ID

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 134

Page 142: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Field Type Optional orMandatory

Description

progressCallback

callable Optional Callback function for obtainingthe download progressNOTE

This callback function contains thefollowing parameters in sequence:Number of downloaded bytes, totalbytes, and used time (unit: second).

Returned ResultType Description

GetResult SDK common result object

GetResult.bodyType

Description

GetObjectMetadataResponse

Response result of Obtain Object Metadata

Sample CodedownloadFile = 'localfile'taskNum = 5partSize = 10 * 1024 * 1024enableCheckpoint = Truetry: resp = obsClient.downloadFile('bucketname', 'objectkey', downloadFile, partSize, taskNum, enableCheckpoint) if resp.status < 300: print('requestId:', resp.requestId) else: print('errorCode:', resp.errorCode) print('errorMessage:', resp.errorMessage)except: import traceback print(traceback.format_exc())

Object Storage ServicePython SDK API Reference 7 Other APIs

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 135

Page 143: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

A Change History

Release Date What's New

2019-09-05 This is the tenth official release.Modified the following sections:4.74 Additional Headers in Resumable Upload2.2 Initializing an Instance of ObsClient

2019-03-05 This is the ninth official release.Added the following section:4.47 FunctionGraph SettingsModified the following sections:Added parameters and description related toFunctionGraph in sections 4.45 Bucket MessageNotification Settings, 5.33 PUT Bucket notification, and5.34 GET Bucket notification.Added the autoClose field and relevant description insections 6.1 Uploading an Object, 6.3 Append Object,and 6.12 PUT Part.

2019-01-17 This is the eighth official release.Resolved some known issues.

2018-10-31 This is the seventh official release.Modified the following content:● Modified sections "PUT Object", "PUT File", "Append

Object", "GET Object", "PUT Part", "Performing aResumable Upload", and "Performing a ResumableDownload", and added the progressCallbackparameter.

2018-08-31 This is the sixth official release.Modified the following content:● Added the is_cname parameter in section "Initializing

an Instance of ObsClient."

Object Storage ServicePython SDK API Reference A Change History

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 136

Page 144: Python SDK API Reference - HUAWEI CLOUD...obs is the global namespace of OBS Python SDK. All data types and API definitions contained in the SDK belong to this namespace. 2.2 Initializing

Release Date What's New

2018-07-18 This is the fifth official release.Modified the following content:● Added description of APIs related to bucket policies.● Added "Append Object."● Added description of support for lifecycle

management.

2018-06-30 This is the fourth official release.Modified the following content:● Resolved some known issues.

2018-01-31 This is the third official release.Modified the following content:● Modified returned result parameters and sample code

related to temporary authentication.

2017-12-31 This is the second official release.Modified the following content:● Added "Object Transition Policy."● Added "Transition Policy of a Noncurrent Object

Version."● Added the imageProcess field in "Additional Request

Parameter of GET Object."● Added the transition and noncurrentVersionTransi-

tion fields in "Lifecycle Rule of a Bucket."

2017-11-30 This is the first official release.

Object Storage ServicePython SDK API Reference A Change History

Issue 10 (2019-09-05) Copyright © Huawei Technologies Co., Ltd. 137