3535
3636
3737def createBucket ():
38- # resp = obsClient.createBucket(bucketName)
38+
3939 resp = bucketClient .createBucket ()
4040 if resp .status < 300 :
4141 print ('Create bucket:' + bucketName + ' successfully!\n ' )
@@ -44,7 +44,7 @@ def createBucket():
4444
4545
4646def getBucketLocation ():
47- # resp = obsClient.getBucketLocation(bucketName)
47+
4848 resp = bucketClient .getBucketLocation ()
4949 if resp .status < 300 :
5050 print ('Getting bucket location ' + str (resp .body ) + ' \n ' )
@@ -53,7 +53,7 @@ def getBucketLocation():
5353
5454
5555def getBucketStorageInfo ():
56- # resp = obsClient.getBucketStorageInfo(bucketName)
56+
5757 resp = bucketClient .getBucketStorageInfo ()
5858 if resp .status < 300 :
5959 print ('Getting bucket storageInfo ' + str (resp .body ) + ' \n ' )
@@ -63,9 +63,9 @@ def getBucketStorageInfo():
6363
6464def doBucketQuotaOperation ():
6565 # Set bucket quota to 1GB
66- # obsClient.setBucketQuota(bucketName, 1024 * 1024 * 1024)
66+
6767 bucketClient .setBucketQuota (1024 * 1024 * 1024 )
68- # resp = obsClient.getBucketQuota(bucketName)
68+
6969 resp = bucketClient .getBucketQuota ()
7070
7171 print ('Getting bucket quota ' + str (resp .body ) + ' \n ' )
@@ -75,19 +75,19 @@ def doBucketVersioningOperation():
7575 # print('Getting bucket versioning config ' + str(obsClient.getBucketVersioning(bucketName).body) + ' \n')
7676 print ('Getting bucket versioning config ' + str (bucketClient .getBucketVersioning ().body ) + ' \n ' )
7777 # Enable bucket versioning
78- # obsClient.setBucketVersioning(bucketName, 'Enabled')
78+
7979 bucketClient .setBucketVersioning ('Enabled' )
8080 print ('Current bucket versioning config ' + str (obsClient .getBucketVersioning (bucketName ).body ) + ' \n ' )
8181
8282 # Suspend bucket versioning
83- # obsClient.setBucketVersioning(bucketName, 'Suspended')
83+
8484 bucketClient .setBucketVersioning ('Suspended' )
8585 print ('Current bucket versioning config ' + str (obsClient .getBucketVersioning (bucketName ).body ) + ' \n ' )
8686
8787
8888def doBucketAclOperation ():
8989 print ('Setting bucket ACL to public-read \n ' )
90- # obsClient.setBucketAcl(bucketName, aclControl='public-read')
90+
9191 bucketClient .setBucketAcl (aclControl = 'public-read' )
9292
9393 # print('Getting bucket ACL ' + str(obsClient.getBucketAcl(bucketName).body) + ' \n')
@@ -109,7 +109,7 @@ def doBucketCorsOperation():
109109
110110 corsList = [cors1 , cors2 ]
111111
112- # obsClient.setBucketCors(bucketName, corsList)
112+
113113 bucketClient .setBucketCors (corsList )
114114
115115 # print('Getting bucket CORS ' + str(obsClient.getBucketCors(bucketName).body) + '\n')
@@ -127,7 +127,7 @@ def optionsBucket():
127127def getBucketMetadata ():
128128 print ('Getting bucket metadata\n ' )
129129
130- # resp = obsClient.getBucketMetadata(bucketName, origin='http://www.b.com', requestHeaders='Authorization1')
130+
131131 resp = bucketClient .getBucketMetadata (origin = 'http://www.b.com' , requestHeaders = 'Authorization1' )
132132 print ('storageClass:' , resp .body .storageClass )
133133 print ('accessContorlAllowOrigin:' , resp .body .accessContorlAllowOrigin )
@@ -137,7 +137,7 @@ def getBucketMetadata():
137137 print ('accessContorlAllowHeaders:' , resp .body .accessContorlAllowHeaders )
138138
139139 print ('Deleting bucket CORS\n ' )
140- # obsClient.deleteBucketCors(bucketName)
140+
141141 resp = bucketClient .deleteBucketCors ()
142142 print ('status' + str (resp .status ))
143143
@@ -152,24 +152,24 @@ def doBucketLifycleOperation():
152152 noncurrentVersionExpiration = NoncurrentVersionExpiration (noncurrentDays = 10 ))
153153
154154 Llifecycle = Lifecycle (rule = [rule1 , rule2 , rule3 ])
155- # obsClient.setBucketLifecycle(bucketName, Llifecycle)
155+
156156 bucketClient .setBucketLifecycle (Llifecycle )
157157
158158 print ('Getting bucket lifecycle:' )
159- # resp = obsClient.getBucketLifecycle(bucketName)
159+
160160 resp = bucketClient .getBucketLifecycle ()
161161 print ('\t ' + str (resp .body ) + '\n ' )
162162
163163 print ('Deleting bucket lifecyle\n ' )
164- # obsClient.deleteBucketLifecycle(bucketName)
164+
165165 bucketClient .deleteBucketLifecycle ()
166166
167167
168168def doBucketLoggingOperation ():
169169 print ('Setting bucket logging\n ' )
170170
171- # obsClient.setBucketLogging(bucketName, Logging(targetBucket=bucketName,
172- # targetPrefix='log-', agency='your agency'))
171+
172+
173173 bucketClient .setBucketLogging (Logging (targetBucket = bucketName , targetPrefix = 'log-' , agency = 'your agency' ))
174174
175175 print ('Getting bucket logging:' )
@@ -187,41 +187,35 @@ def doBucketWebsiteOperation():
187187 print ('Setting bucket website\n ' )
188188 Lwebsite = WebsiteConfiguration (indexDocument = IndexDocument (suffix = 'index.html' ),
189189 errorDocument = ErrorDocument (key = 'error.html' ))
190- # obsClient.setBucketWebsite(bucketName, Lwebsite)
191190 bucketClient .setBucketWebsite (Lwebsite )
192191
193192 print ('Getting bucket website:' )
194193 # print('\t' + str(obsClient.getBucketWebsite(bucketName).body) + '\n')
195194 print ('\t ' + str (bucketClient .getBucketWebsite ().body ) + '\n ' )
196195 print ('Deleting bucket website\n ' )
197- # obsClient.deleteBucketWebsite(bucketName)
198196 bucketClient .deleteBucketWebsite ()
199197
200198
201199def doBucketTaggingOperation ():
202200 print ('Setting bucket tagging\n ' )
203201 tagInfo = TagInfo ()
204202 tagInfo .addTag ('key1' , 'value1' ).addTag ('key2' , 'value2' )
205- # resp = obsClient.setBucketTagging(bucketName, tagInfo)
206203 resp = bucketClient .setBucketTagging (tagInfo )
207204
208205 if resp .status < 300 :
209206 print ('Getting bucket tagging\n ' )
210- # resp = obsClient.getBucketTagging(bucketName)
211207 resp = bucketClient .getBucketTagging ()
212208 for item in resp .body .tagSet :
213209 print ('\t ' + item .key + ':' + item .value + '\n ' )
214210
215211 print ('Deleting bucket tagging\n ' )
216- # obsClient.deleteBucketTagging(bucketName)
217212 bucketClient .deleteBucketTagging ()
218213 else :
219214 print ('common msg:status:' , resp .status , ',errorCode:' , resp .errorCode , ',errorMessage:' , resp .errorMessage )
220215
221216
222217def deleteBucket ():
223218 print ('Deleting bucket ' + bucketName + '\n ' )
224- # resp = obsClient.deleteBucket(bucketName)
225219 resp = bucketClient .deleteBucket ()
226220 print ('common msg:status:' , resp .status , ',errorCode:' , resp .errorCode , ',errorMessage:' , resp .errorMessage )
227221
0 commit comments