Skip to content

Commit

Permalink
update 3.23.5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtingwei998 committed Jun 10, 2023
1 parent 4315dc7 commit 80a1ab6
Show file tree
Hide file tree
Showing 20 changed files with 324 additions and 157 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 3.23.5

New Features:

1. The interface adds three types of capacity statistics to be queried: warm, cold, and deepArchiveSize
2. Allowed you to add any custom header field in a request

Resolved Issues:

1. Fix the bug that regular matching fails when ECS obtains credentials through Agencies

-------------------------------------------------------------------------------------------------
Version 3.22.2

New Features:
Expand Down
12 changes: 11 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
Version 3.22.2
Version 3.23.5
新特性:
1. getBucketStorageInfo接口增加查询标准、归档、低频三种类型的容量统计
2. 用户可以在发送请求时添加任意自定义头域

修复问题

1. 修复ECS通过委托获取凭证时正则匹配失败问题。

-------------------------------------------------------------------------------------------------
Version 3.22.2
新特性:
1. 增加虚拟桶相关接口
2. 针对Python3 HTTPS参数的使用做了兼容修改
Expand Down
38 changes: 16 additions & 22 deletions examples/bucket_operations_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


def createBucket():
# resp = obsClient.createBucket(bucketName)

resp = bucketClient.createBucket()
if resp.status < 300:
print('Create bucket:' + bucketName + ' successfully!\n')
Expand All @@ -44,7 +44,7 @@ def createBucket():


def getBucketLocation():
# resp = obsClient.getBucketLocation(bucketName)

resp = bucketClient.getBucketLocation()
if resp.status < 300:
print('Getting bucket location ' + str(resp.body) + ' \n')
Expand All @@ -53,7 +53,7 @@ def getBucketLocation():


def getBucketStorageInfo():
# resp = obsClient.getBucketStorageInfo(bucketName)

resp = bucketClient.getBucketStorageInfo()
if resp.status < 300:
print('Getting bucket storageInfo ' + str(resp.body) + ' \n')
Expand All @@ -63,9 +63,9 @@ def getBucketStorageInfo():

def doBucketQuotaOperation():
# Set bucket quota to 1GB
# obsClient.setBucketQuota(bucketName, 1024 * 1024 * 1024)

bucketClient.setBucketQuota(1024 * 1024 * 1024)
# resp = obsClient.getBucketQuota(bucketName)

resp = bucketClient.getBucketQuota()

print('Getting bucket quota ' + str(resp.body) + ' \n')
Expand All @@ -75,19 +75,19 @@ def doBucketVersioningOperation():
# print('Getting bucket versioning config ' + str(obsClient.getBucketVersioning(bucketName).body) + ' \n')
print('Getting bucket versioning config ' + str(bucketClient.getBucketVersioning().body) + ' \n')
# Enable bucket versioning
# obsClient.setBucketVersioning(bucketName, 'Enabled')

bucketClient.setBucketVersioning('Enabled')
print('Current bucket versioning config ' + str(obsClient.getBucketVersioning(bucketName).body) + ' \n')

# Suspend bucket versioning
# obsClient.setBucketVersioning(bucketName, 'Suspended')

bucketClient.setBucketVersioning('Suspended')
print('Current bucket versioning config ' + str(obsClient.getBucketVersioning(bucketName).body) + ' \n')


def doBucketAclOperation():
print('Setting bucket ACL to public-read \n')
# obsClient.setBucketAcl(bucketName, aclControl='public-read')

bucketClient.setBucketAcl(aclControl='public-read')

# print('Getting bucket ACL ' + str(obsClient.getBucketAcl(bucketName).body) + ' \n')
Expand All @@ -109,7 +109,7 @@ def doBucketCorsOperation():

corsList = [cors1, cors2]

# obsClient.setBucketCors(bucketName, corsList)

bucketClient.setBucketCors(corsList)

# print('Getting bucket CORS ' + str(obsClient.getBucketCors(bucketName).body) + '\n')
Expand All @@ -127,7 +127,7 @@ def optionsBucket():
def getBucketMetadata():
print('Getting bucket metadata\n')

# resp = obsClient.getBucketMetadata(bucketName, origin='http://www.b.com', requestHeaders='Authorization1')

resp = bucketClient.getBucketMetadata(origin='http://www.b.com', requestHeaders='Authorization1')
print('storageClass:', resp.body.storageClass)
print('accessContorlAllowOrigin:', resp.body.accessContorlAllowOrigin)
Expand All @@ -137,7 +137,7 @@ def getBucketMetadata():
print('accessContorlAllowHeaders:', resp.body.accessContorlAllowHeaders)

print('Deleting bucket CORS\n')
# obsClient.deleteBucketCors(bucketName)

resp = bucketClient.deleteBucketCors()
print('status' + str(resp.status))

Expand All @@ -152,24 +152,24 @@ def doBucketLifycleOperation():
noncurrentVersionExpiration=NoncurrentVersionExpiration(noncurrentDays=10))

Llifecycle = Lifecycle(rule=[rule1, rule2, rule3])
# obsClient.setBucketLifecycle(bucketName, Llifecycle)

bucketClient.setBucketLifecycle(Llifecycle)

print('Getting bucket lifecycle:')
# resp = obsClient.getBucketLifecycle(bucketName)

resp = bucketClient.getBucketLifecycle()
print('\t' + str(resp.body) + '\n')

print('Deleting bucket lifecyle\n')
# obsClient.deleteBucketLifecycle(bucketName)

bucketClient.deleteBucketLifecycle()


def doBucketLoggingOperation():
print('Setting bucket logging\n')

# obsClient.setBucketLogging(bucketName, Logging(targetBucket=bucketName,
# targetPrefix='log-', agency='your agency'))


bucketClient.setBucketLogging(Logging(targetBucket=bucketName, targetPrefix='log-', agency='your agency'))

print('Getting bucket logging:')
Expand All @@ -187,41 +187,35 @@ def doBucketWebsiteOperation():
print('Setting bucket website\n')
Lwebsite = WebsiteConfiguration(indexDocument=IndexDocument(suffix='index.html'),
errorDocument=ErrorDocument(key='error.html'))
# obsClient.setBucketWebsite(bucketName, Lwebsite)
bucketClient.setBucketWebsite(Lwebsite)

print('Getting bucket website:')
# print('\t' + str(obsClient.getBucketWebsite(bucketName).body) + '\n')
print('\t' + str(bucketClient.getBucketWebsite().body) + '\n')
print('Deleting bucket website\n')
# obsClient.deleteBucketWebsite(bucketName)
bucketClient.deleteBucketWebsite()


def doBucketTaggingOperation():
print('Setting bucket tagging\n')
tagInfo = TagInfo()
tagInfo.addTag('key1', 'value1').addTag('key2', 'value2')
# resp = obsClient.setBucketTagging(bucketName, tagInfo)
resp = bucketClient.setBucketTagging(tagInfo)

if resp.status < 300:
print('Getting bucket tagging\n')
# resp = obsClient.getBucketTagging(bucketName)
resp = bucketClient.getBucketTagging()
for item in resp.body.tagSet:
print('\t' + item.key + ':' + item.value + '\n')

print('Deleting bucket tagging\n')
# obsClient.deleteBucketTagging(bucketName)
bucketClient.deleteBucketTagging()
else:
print('common msg:status:', resp.status, ',errorCode:', resp.errorCode, ',errorMessage:', resp.errorMessage)


def deleteBucket():
print('Deleting bucket ' + bucketName + '\n')
# resp = obsClient.deleteBucket(bucketName)
resp = bucketClient.deleteBucket()
print('common msg:status:', resp.status, ',errorCode:', resp.errorCode, ',errorMessage:', resp.errorMessage)

Expand Down
11 changes: 0 additions & 11 deletions examples/object_operations_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,26 @@

# Create bucket
print('Create a new bucket for demo\n')
# obsClient.createBucket(bucketName)
bucketClient.createBucket()

# Create object
# resp = obsClient.putContent(bucketName, objectKey, 'Hello OBS')
resp = bucketClient.putContent(objectKey, 'Hello OBS')
if resp.status < 300:
print('Create object ' + objectKey + ' successfully!\n')

# Get object metadata
print('Getting object metadata')
# resp = obsClient.getObjectMetadata(bucketName, objectKey, 'Hello OBS')
resp = bucketClient.getObjectMetadata(objectKey, 'Hello OBS')
print('\t' + str(resp.header))

# Get object
print('Getting object content')
# resp = obsClient.getObject(bucketName, objectKey, loadStreamInMemory=True)
resp = bucketClient.getObject(objectKey, loadStreamInMemory=True)
print('\tobject content:%s' % resp.body.buffer)

# Copy object
print('Copying object\n')
destObjectKey = objectKey + '-back'
# resp = obsClient.copyObject(sourceBucketName=bucketName, sourceObjectKey=objectKey,
# destBucketName=bucketName, destObjectKey=destObjectKey)
resp = bucketClient.copyObject(sourceBucketName=bucketName, sourceObjectKey=objectKey, destObjectKey=destObjectKey)
if resp.status < 300:
print('Copy object ' + destObjectKey + ' successfully!\n')
Expand All @@ -69,18 +63,15 @@
allowedOrigin=['http://www.a.com', 'http://www.b.com'], allowedHeader=['Authorization1'],
maxAgeSecond=100, exposeHeader=['x-obs-test1'])
corsList = [cors1]
# obsClient.setBucketCors(bucketName, corsList)
bucketClient.setBucketCors(corsList)

print('Options object:')
options = Options(origin='http://www.a.com', accessControlRequestMethods=['PUT'])
# resp = obsClient.optionsObject(bucketName, objectKey, options)
resp = bucketClient.optionsObject(objectKey, options)
print(resp.body)

# Put/Get object acl operations
print('Setting object ACL to public-read \n')
# obsClient.setObjectAcl(bucketName, objectKey, aclControl='public-read')
bucketClient.setObjectAcl(objectKey, aclControl='public-read')

# print('Getting object ACL ' + str(obsClient.getObjectAcl(bucketName, objectKey).body) + '\n')
Expand All @@ -91,7 +82,5 @@

# Delete object
print('Deleting objects\n')
# obsClient.deleteObject(bucketName, objectKey)
# obsClient.deleteObject(bucketName, destObjectKey)
bucketClient.deleteObject(objectKey)
bucketClient.deleteObject(destObjectKey)
58 changes: 1 addition & 57 deletions examples/obs_python_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

# init log
def initLog():
obsClient.initLog(LogConf('../log.conf'), 'obsclient')
obsClient.initLog(LogConf('../src/log.conf'), 'obsclient')


# create bucket
Expand Down Expand Up @@ -141,7 +141,6 @@ def SetBucketAcl():
Lacl = ACL(owner=Lowner, grants=Lgrants)

resp = bucketClient.setBucketAcl(acl=Lacl)
# resp = obsClient.setBucketAcl(bucketName=bucketName, aclControl='public-read-write')
print('common msg:status:', resp.status, ',errorCode:', resp.errorCode, ',errorMessage:', resp.errorMessage)


Expand Down Expand Up @@ -747,65 +746,10 @@ def GetObject():


if __name__ == '__main__':
# initLog()
# =========================================================
# bucket operations
# =========================================================
# CreateBucket()
# DeleteBucket()
# ListBuckets()
# HeadBucket()
# GetBucketMetadata()
# SetBucketQuota()
# GetBucketQuota()
# SetBucketStoragePolicy()
# GetBucketStoragePolicy()
# GetBucketStorageInfo()
# SetBucketAcl()
# GetBucketAcl()
# SetBucketPolicy()
# GetBucketPolicy()
# DeleteBucketPolicy()
# SetBucketVersioning()
# GetBucketVersioning()
# ListVersions()
# ListObjects()
# ListMultipartUploads()
# SetBucketLifecycle()
# GetBucketLifecycle()
# DeleteBucketLifecycle()
# SetBucketWebsite()
# GetBucketWebsite()
# DeleteBucketWebsite()
# SetBucketLogging()
# GetBucketLogging()
# GetBucketLocation()
# SetBucketTagging()
# GetBucketTagging()
# DeleteBucketTagging()
# SetBucketCors()
# GetBucketCors()
# DeleteBucketCors()
# SetBucketNotification()
# GetBucketNotification()
# =========================================================
# object operations
# =========================================================
# PutContent()
# AppendObject()
# CopyObject()
# PutFile()
# GetObject()
# GetObjectMetadata()
# SetObjectAcl()
# GetObjectAcl()
# DeleteObject()
# DeleteObjects()
# RestoreObject()
# AbortMultipartUpload()
# InitiateMultipartUpload()
# UploadPart()
# CompleteMultipartUpload()
# CopyPart()
# ListParts()
pass
Binary file added release/sdk-obs-python-3.23.5.tar.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion src/obs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from obs.client import ObsClient
from obs.model import CompletePart, Permission, StorageClass, EventType, RestoreTier, Group, Grantee, Grant
from obs.model import ExtensionGrant, Owner, ACL, Condition, DateTime, SseCHeader, SseKmsHeader, CopyObjectHeader
from obs.model import SetObjectMetadataHeader, CorsRule, CreateBucketHeader, ErrorDocument, IndexDocument, Expiration
from obs.model import SetObjectMetadataHeader,RenameFileHeader, CorsRule, CreateBucketHeader, ErrorDocument, IndexDocument, Expiration
from obs.model import NoncurrentVersionExpiration, GetObjectHeader, HeadPermission, Lifecycle, Notification
from obs.model import TopicConfiguration, FunctionGraphConfiguration, FilterRule, Replication, ReplicationRule
from obs.model import Options, PutObjectHeader, AppendObjectHeader, AppendObjectContent, RedirectAllRequestTo
Expand Down Expand Up @@ -49,6 +49,7 @@
'SseKmsHeader',
'CopyObjectHeader',
'SetObjectMetadataHeader',
'RenameFileHeader',
'CorsRule',
'CreateBucketHeader',
'ErrorDocument',
Expand Down
Loading

0 comments on commit 80a1ab6

Please sign in to comment.