Skip to content

Commit 88b49e7

Browse files
committed
update 3.25.3
1 parent 2092dc5 commit 88b49e7

14 files changed

Lines changed: 303 additions & 25 deletions

README.MD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Version 3.25.3
2+
3+
新特性:
4+
1. Added BPA feature.
5+
2. Added intelligent tiering feature.
6+
7+
Documentation & Demo:
8+
1. Added descriptions about BPA APIs.
9+
10+
Resolved Issues:
11+
12+
-----------------------------------------------------------------------------------
13+
114
Version 3.24.9
215

316
New Features:

README_CN.MD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Version 3.25.3
2+
3+
新特性:
4+
1. 新增BPA相关接口。
5+
2. 支持智能分级特性。
6+
7+
资料 & demo:
8+
1. 补充BPA相关接口描述。
9+
10+
修复问题:
11+
12+
-----------------------------------------------------------------------------------
13+
114
Version 3.24.9
215

316
新特性:

main/obs_go_sample.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ import (
2525
)
2626

2727
const (
28-
endpoint = "https://your-endpoint"
29-
ak = "*** Provide your Access Key ***"
30-
sk = "*** Provide your Secret Key ***"
31-
bucketName = "bucket-test"
32-
objectKey = "object-test"
33-
location = "yourbucketlocation"
28+
endpoint = "https://your-endpoint"
29+
ak = "*** Provide your Access Key ***"
30+
sk = "*** Provide your Secret Key ***"
31+
bucketName = "bucket-test"
32+
posixBucketName = "posix-bucket-name"
33+
posixFileKey = "posix-file-key"
34+
objectKey = "object-test"
35+
location = "yourbucketlocation"
3436
)
3537

3638
var obsClient *obs.ObsClient

obs/client_bucket.go

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (obsClient ObsClient) SetBucketCustomDomain(input *SetBucketCustomDomainInp
3737
}
3838

3939
output = &BaseModel{}
40-
err = obsClient.doActionWithBucket("SetBucketCustomDomain", HTTP_PUT, input.Bucket, newSubResourceSerialV2(SubResourceCustomDomain, input.CustomDomain), output, extensions)
40+
err = obsClient.doActionWithBucket("SetBucketCustomDomain", HTTP_PUT, input.Bucket, input, output, extensions)
4141
if err != nil {
4242
output = nil
4343
}
@@ -804,3 +804,66 @@ func (obsClient ObsClient) GetBucketFetchJob(input *GetBucketFetchJobInput, exte
804804
}
805805
return
806806
}
807+
808+
// PutBucketPublicAccessBlock sets the bucket Block Public Access.
809+
//
810+
// You can use this API to set a bucket Block Public Access.
811+
func (obsClient ObsClient) PutBucketPublicAccessBlock(input *PutBucketPublicAccessBlockInput, extensions ...extensionOptions) (output *BaseModel, err error) {
812+
if input == nil {
813+
return nil, errors.New("PutBucketPublicAccessBlockInput is nil")
814+
}
815+
output = &BaseModel{}
816+
err = obsClient.doActionWithBucket("PutBucketPublicAccessBlock", HTTP_PUT, input.Bucket, input, output, extensions)
817+
if err != nil {
818+
output = nil
819+
}
820+
return
821+
}
822+
823+
// GetBucketPublicAccessBlock gets the bucket Block Public Access.
824+
//
825+
// You can use this API to get a bucket Block Public Access.
826+
func (obsClient ObsClient) GetBucketPublicAccessBlock(bucketName string, extensions ...extensionOptions) (output *GetBucketPublicAccessBlockOutput, err error) {
827+
output = &GetBucketPublicAccessBlockOutput{}
828+
err = obsClient.doActionWithBucket("GetBucketPublicAccessBlock", HTTP_GET, bucketName, newSubResourceSerial(SubResourcePublicAccessBlock), output, extensions)
829+
if err != nil {
830+
output = nil
831+
}
832+
return
833+
}
834+
835+
// DeleteBucketPublicAccessBlock deletes the bucket Block Public Access.
836+
//
837+
// You can use this API to delete the Block Public Access of a bucket.
838+
func (obsClient ObsClient) DeleteBucketPublicAccessBlock(bucketName string, extensions ...extensionOptions) (output *BaseModel, err error) {
839+
output = &BaseModel{}
840+
err = obsClient.doActionWithBucket("DeleteBucketPublicAccessBlock", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourcePublicAccessBlock), output, extensions)
841+
if err != nil {
842+
output = nil
843+
}
844+
return
845+
}
846+
847+
// GetBucketPolicyPublicStatus get the bucket Policy status.
848+
//
849+
// You can use this API to get a bucket Policy status.
850+
func (obsClient ObsClient) GetBucketPolicyPublicStatus(bucketName string, extensions ...extensionOptions) (output *GetBucketPolicyPublicStatusOutput, err error) {
851+
output = &GetBucketPolicyPublicStatusOutput{}
852+
err = obsClient.doActionWithBucket("GetBucketPolicyPublicStatus", HTTP_GET, bucketName, newSubResourceSerial(SubResourceBucketPolicyPublicStatus), output, extensions)
853+
if err != nil {
854+
output = nil
855+
}
856+
return
857+
}
858+
859+
// GetBucketPublicStatus get the bucket public status.
860+
//
861+
// You can use this API to get a bucket public status.
862+
func (obsClient ObsClient) GetBucketPublicStatus(bucketName string, extensions ...extensionOptions) (output *GetBucketPublicStatusOutput, err error) {
863+
output = &GetBucketPublicStatusOutput{}
864+
err = obsClient.doActionWithBucket("GetBucketPublicStatus", HTTP_GET, bucketName, newSubResourceSerial(SubResourceBucketPublicStatus), output, extensions)
865+
if err != nil {
866+
output = nil
867+
}
868+
return
869+
}

obs/const.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
package obs
1414

1515
const (
16-
OBS_SDK_VERSION = "3.24.6"
16+
OBS_SDK_VERSION = "3.25.3"
1717
USER_AGENT = "obs-sdk-go/" + OBS_SDK_VERSION
1818
HEADER_PREFIX = "x-amz-"
1919
HEADER_PREFIX_META = "x-amz-meta-"
@@ -201,10 +201,17 @@ const (
201201
DEFAULT_PART_SIZE = 9 * 1024 * 1024
202202
MAX_PART_NUM = 10000
203203

204-
GET_OBJECT = "GetObject"
205-
PUT_OBJECT = "PutObject"
206-
PUT_FILE = "PutFile"
207-
APPEND_OBJECT = "AppendObject"
204+
GET_OBJECT = "GetObject"
205+
PUT_OBJECT = "PutObject"
206+
PUT_FILE = "PutFile"
207+
APPEND_OBJECT = "AppendObject"
208+
MAX_CERT_XML_BODY_SIZE = 40 * 1024
209+
CERT_ID_SIZE = 16
210+
MAX_CERTIFICATE_NAME_LENGTH = 63
211+
MIN_CERTIFICATE_NAME_LENGTH = 3
212+
CERTIFICATE_FIELD_NAME = "CERTIFICATE ID SIZE"
213+
NAME_LENGTH = "Name Length"
214+
XML_SIZE = "XML SIZE"
208215
)
209216

210217
var (
@@ -305,12 +312,16 @@ var (
305312
"directcoldaccess": true,
306313
"attname": true,
307314
"cdnnotifyconfiguration": true,
315+
"publicaccessblock": true,
316+
"bucketstatus": true,
317+
"policystatus": true,
308318
}
309319

310320
obsStorageClasses = []string{
311321
string(StorageClassStandard),
312322
string(StorageClassWarm),
313323
string(StorageClassCold),
314324
string(StorageClassDeepArchive),
325+
string(StorageClassIntelligentTiering),
315326
}
316327
)

obs/convert.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ func ParseStringToStorageClassType(value string) (ret StorageClassType) {
8282
ret = StorageClassCold
8383
case string(StorageClassDeepArchive):
8484
ret = StorageClassDeepArchive
85+
case string(StorageClassIntelligentTiering):
86+
ret = StorageClassIntelligentTiering
8587
default:
8688
ret = ""
8789
}

obs/extension.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
package obs
1414

1515
import (
16+
"bytes"
17+
"crypto/sha256"
18+
"encoding/base64"
19+
"encoding/hex"
20+
"encoding/json"
1621
"fmt"
1722
"strconv"
1823
"strings"
@@ -60,3 +65,39 @@ func WithCustomHeader(key string, value string) extensionHeaders {
6065
return nil
6166
}
6267
}
68+
69+
func PreprocessCallbackInputToSHA256(callbackInput *CallbackInput) (output string, err error) {
70+
71+
if callbackInput == nil {
72+
return "", fmt.Errorf("the parameter can not be nil")
73+
}
74+
75+
if callbackInput.CallbackUrl == "" {
76+
return "", fmt.Errorf("the parameter [CallbackUrl] can not be empty")
77+
}
78+
79+
if callbackInput.CallbackBody == "" {
80+
return "", fmt.Errorf("the parameter [CallbackBody] can not be empty")
81+
}
82+
83+
callbackBuffer := bytes.NewBuffer([]byte{})
84+
callbackEncoder := json.NewEncoder(callbackBuffer)
85+
// 避免HTML字符转义
86+
callbackEncoder.SetEscapeHTML(false)
87+
err = callbackEncoder.Encode(callbackInput)
88+
if err != nil {
89+
return "", err
90+
}
91+
callbackVal := base64.StdEncoding.EncodeToString(removeEndNewlineCharacter(callbackBuffer))
92+
// 计算SHA256哈希
93+
hash := sha256.Sum256([]byte(callbackVal))
94+
95+
// 将哈希转换为十六进制字符串
96+
return hex.EncodeToString(hash[:]), nil
97+
98+
}
99+
100+
// Encode函数会默认在json结尾增加换行符,导致base64转码结果与其他方式不一致,需要去掉末尾的换行符
101+
func removeEndNewlineCharacter(callbackBuffer *bytes.Buffer) []byte {
102+
return callbackBuffer.Bytes()[:callbackBuffer.Len()-1]
103+
}

obs/model_base.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,36 +239,36 @@ type BucketLoggingStatus struct {
239239

240240
// Transition defines transition property in LifecycleRule
241241
type Transition struct {
242-
XMLName xml.Name `xml:"Transition"`
242+
XMLName xml.Name `xml:"Transition" json:"-"`
243243
Date time.Time `xml:"Date,omitempty"`
244244
Days int `xml:"Days,omitempty"`
245245
StorageClass StorageClassType `xml:"StorageClass"`
246246
}
247247

248248
// Expiration defines expiration property in LifecycleRule
249249
type Expiration struct {
250-
XMLName xml.Name `xml:"Expiration"`
250+
XMLName xml.Name `xml:"Expiration" json:"-"`
251251
Date time.Time `xml:"Date,omitempty"`
252252
Days int `xml:"Days,omitempty"`
253253
ExpiredObjectDeleteMarker string `xml:"ExpiredObjectDeleteMarker,omitempty"`
254254
}
255255

256256
// NoncurrentVersionTransition defines noncurrentVersion transition property in LifecycleRule
257257
type NoncurrentVersionTransition struct {
258-
XMLName xml.Name `xml:"NoncurrentVersionTransition"`
258+
XMLName xml.Name `xml:"NoncurrentVersionTransition" json:"-"`
259259
NoncurrentDays int `xml:"NoncurrentDays"`
260260
StorageClass StorageClassType `xml:"StorageClass"`
261261
}
262262

263263
// NoncurrentVersionExpiration defines noncurrentVersion expiration property in LifecycleRule
264264
type NoncurrentVersionExpiration struct {
265-
XMLName xml.Name `xml:"NoncurrentVersionExpiration"`
265+
XMLName xml.Name `xml:"NoncurrentVersionExpiration" json:"-"`
266266
NoncurrentDays int `xml:"NoncurrentDays"`
267267
}
268268

269269
// AbortIncompleteMultipartUpload defines abortIncomplete expiration property in LifecycleRule
270270
type AbortIncompleteMultipartUpload struct {
271-
XMLName xml.Name `xml:"AbortIncompleteMultipartUpload"`
271+
XMLName xml.Name `xml:"AbortIncompleteMultipartUpload" json:"-"`
272272
DaysAfterInitiation int `xml:"DaysAfterInitiation"`
273273
}
274274

@@ -286,7 +286,7 @@ type LifecycleRule struct {
286286
}
287287

288288
type LifecycleFilter struct {
289-
XMLName xml.Name `xml:"Filter"`
289+
XMLName xml.Name `xml:"Filter" json:"-"`
290290
Prefix string `xml:"And>Prefix,omitempty"`
291291
Tags []Tag `xml:"And>Tag,omitempty"`
292292
}
@@ -378,6 +378,24 @@ type BucketPayer struct {
378378
Payer PayerType `xml:"Payer"`
379379
}
380380

381+
type PublicAccessBlockConfiguration struct {
382+
XMLName xml.Name `xml:"PublicAccessBlockConfiguration"`
383+
BlockPublicAcls bool `xml:"BlockPublicAcls"`
384+
IgnorePublicAcls bool `xml:"IgnorePublicAcls"`
385+
BlockPublicPolicy bool `xml:"BlockPublicPolicy"`
386+
RestrictPublicBuckets bool `xml:"RestrictPublicBuckets"`
387+
}
388+
389+
type PolicyPublicStatus struct {
390+
XMLName xml.Name `xml:"PolicyStatus"`
391+
IsPublic bool `xml:"IsPublic"`
392+
}
393+
394+
type BucketPublicStatus struct {
395+
XMLName xml.Name `xml:"BucketStatus"`
396+
IsPublic bool `xml:"IsPublic"`
397+
}
398+
381399
// HttpHeader defines the standard metadata
382400
type HttpHeader struct {
383401
CacheControl string

obs/model_bucket.go

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,18 @@ type GetBucketCustomDomainOutput struct {
2828
Domains []Domain `xml:"Domains"`
2929
}
3030

31-
// SetBucketCustomDomainInput is the input parameter of SetBucketCustomDomain function
31+
type CustomDomainConfiguration struct {
32+
Name string `xml:"Name"`
33+
CertificateId string `xml:"CertificateId,omitempty"`
34+
Certificate string `xml:"Certificate"`
35+
CertificateChain string `xml:"CertificateChain,omitempty"`
36+
PrivateKey string `xml:"PrivateKey"`
37+
}
38+
3239
type SetBucketCustomDomainInput struct {
33-
Bucket string
34-
CustomDomain string
40+
Bucket string
41+
CustomDomain string
42+
CustomDomainConfiguration *CustomDomainConfiguration `json:"customDomainConfiguration"` //optional
3543
}
3644

3745
// GetBucketMirrorBackToSourceOutput is the result of GetBucketMirrorBackToSource function
@@ -47,8 +55,9 @@ type SetBucketMirrorBackToSourceInput struct {
4755

4856
// Content defines the object content properties
4957
type Domain struct {
50-
DomainName string `xml:"DomainName"`
51-
CreateTime string `xml:"CreateTime"`
58+
DomainName string `xml:"DomainName"`
59+
CreateTime string `xml:"CreateTime"`
60+
CertificateId string `xml:"CertificateId"`
5261
}
5362

5463
// ListBucketsInput is the input parameter of ListBuckets function
@@ -254,7 +263,7 @@ type GetBucketLoggingConfigurationOutput struct {
254263

255264
// BucketLifecycleConfiguration defines the bucket lifecycle configuration
256265
type BucketLifecycleConfiguration struct {
257-
XMLName xml.Name `xml:"LifecycleConfiguration"`
266+
XMLName xml.Name `xml:"LifecycleConfiguration" json:"-"`
258267
LifecycleRules []LifecycleRule `xml:"Rule"`
259268
}
260269

@@ -405,3 +414,24 @@ type BaseDirAccesslabelInput struct {
405414
Key string
406415
Accesslabel []string
407416
}
417+
418+
// PutBucketPublicAccessBlockInput is the input parameter of PutBucketPublicAccessBlock function
419+
type PutBucketPublicAccessBlockInput struct {
420+
Bucket string `xml:"-"`
421+
PublicAccessBlockConfiguration
422+
}
423+
424+
type GetBucketPublicAccessBlockOutput struct {
425+
BaseModel
426+
PublicAccessBlockConfiguration
427+
}
428+
429+
type GetBucketPublicStatusOutput struct {
430+
BaseModel
431+
BucketPublicStatus
432+
}
433+
434+
type GetBucketPolicyPublicStatusOutput struct {
435+
BaseModel
436+
PolicyPublicStatus
437+
}

obs/model_object.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,10 @@ type SetObjectMetadataOutput struct {
423423
StorageClass StorageClassType
424424
Metadata map[string]string
425425
}
426+
427+
type CallbackInput struct {
428+
CallbackUrl string `json:"callbackUrl"`
429+
CallbackHost string `json:"callbackHost,omitempty"`
430+
CallbackBody string `json:"callbackBody"`
431+
CallbackBodyType string `json:"callbackBodyType,omitempty"`
432+
}

0 commit comments

Comments
 (0)