Skip to content

Commit

Permalink
Merge pull request #203 from tencentyun/feature_jojoliang_bcf65425
Browse files Browse the repository at this point in the history
Feature jojoliang bcf65425
  • Loading branch information
agin719 authored Aug 14, 2023
2 parents 0ef69db + 097711f commit 113753b
Show file tree
Hide file tree
Showing 11 changed files with 495 additions and 25 deletions.
18 changes: 18 additions & 0 deletions bucket_object_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ObjectGetRetentionOptions struct {
type ObjectGetRetentionResult struct {
XMLName xml.Name `xml:"Retention"`
RetainUntilDate string `xml:"RetainUntilDate,omitempty"`
Mode string `xml:"Mode,omitempty"`
}

func (s *ObjectService) GetRetention(ctx context.Context, key string, opt *ObjectGetRetentionOptions) (*ObjectGetRetentionResult, *Response, error) {
Expand All @@ -62,3 +63,20 @@ func (s *ObjectService) GetRetention(ctx context.Context, key string, opt *Objec
resp, err := s.client.doRetry(ctx, &sendOpt)
return &res, resp, err
}

type ObjectPutRetentionOptions struct {
XMLName xml.Name `xml:"Retention"`
RetainUntilDate string `xml:"RetainUntilDate,omitempty"`
Mode string `xml:"Mode,omitempty"`
}

func (s *ObjectService) PutRetention(ctx context.Context, key string, opt *ObjectPutRetentionOptions) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.BucketURL,
uri: "/" + encodeURIComponent(key) + "?retention",
method: http.MethodPut,
body: opt,
}
resp, err := s.client.doRetry(ctx, &sendOpt)
return resp, err
}
31 changes: 31 additions & 0 deletions bucket_object_lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,34 @@ func TestBucketService_GetRetention(t *testing.T) {
t.Errorf("Object.GetRetention returned %+v, want %+v", res, want)
}
}

func TestBucketService_PutRetention(t *testing.T) {
setup()
defer teardown()

opt := &ObjectPutRetentionOptions{
RetainUntilDate: "2022-12-10T08:34:48.000Z",
Mode: "COMPLIANCE",
}

key := "example"
mux.HandleFunc("/example", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
vs := values{
"retention": "",
}
testFormValues(t, r, vs)
body := new(ObjectPutRetentionOptions)
xml.NewDecoder(r.Body).Decode(body)
want := opt
want.XMLName = xml.Name{Local: "Retention"}
if !reflect.DeepEqual(body, want) {
t.Errorf("Object.PutRetention request\n body: %+v\nwant %+v\n", body, want)
}
})

_, err := client.Object.PutRetention(context.Background(), key, opt)
if err != nil {
t.Fatalf("Object.GetRetention returned error: %v", err)
}
}
214 changes: 211 additions & 3 deletions ci_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type JobOutput struct {
Object string `xml:"Object,omitempty"`
SpriteObject string `xml:"SpriteObject,omitempty"`
AuObject string `xml:"AuObject,omitempty"`
BassObject string `xml:"BassObject,omitempty"`
DrumObject string `xml:"DrumObject,omitempty"`
StreamExtract []StreamExtract `xml:"StreamExtract,omitempty"`
}

Expand Down Expand Up @@ -339,9 +341,12 @@ type HlsEncrypt struct {

// Segment TODO
type Segment struct {
Format string `xml:"Format,omitempty"`
Duration string `xml:"Duration,omitempty"`
HlsEncrypt *HlsEncrypt `xml:"HlsEncrypt,omitempty"`
Format string `xml:"Format,omitempty"`
Duration string `xml:"Duration,omitempty"`
TranscodeIndex string `xml:"TranscodeIndex,omitempty"`
HlsEncrypt *HlsEncrypt `xml:"HlsEncrypt,omitempty"`
StartTime string `xml:"StartTime,omitempty"`
EndTime string `xml:"EndTime,omitempty"`
}

// VideoMontageVideo TODO
Expand Down Expand Up @@ -731,6 +736,12 @@ type MediaProcessJobOperation struct {
SoundHoundResult *SoundHoundResult `xml:"SoundHoundResult,omitempty"`
FillConcat *FillConcat `xml:"FillConcat,omitempty"`
VideoSynthesis *VideoSynthesis `xml:"VideoSynthesis,omitempty"`
DnaConfig *DnaConfig `xml:"DnaConfig,omitempty"`
DnaResult *DnaResult `xml:"DnaResult,omitempty"`
VocalScore *VocalScore `xml:"VocalScore,omitempty"`
VocalScoreResult *VocalScoreResult `xml:"VocalScoreResult,omitempty"`
ImageInspect *ImageInspect `xml:"ImageInspect,omitempty"`
ImageInspectResult *ImageInspectResult `xml:"ImageInspectResult,omitempty"`
}

// CreatePicJobsOptions TODO
Expand Down Expand Up @@ -1639,6 +1650,10 @@ type SegmentVideoBody struct {
BackgroundRed string `xml:"BackgroundRed,omitempty"`
BackgroundGreen string `xml:"BackgroundGreen,omitempty"`
BackgroundLogoUrl string `xml:"BackgroundLogoUrl,omitempty"`
BinaryThreshold string `xml:"BinaryThreshold,omitempty"`
RemoveRed string `xml:"RemoveRed,omitempty"`
RemoveGreen string `xml:"RemoveGreen,omitempty"`
RemoveBlue string `xml:"RemoveBlue,omitempty"`
}

// NodeSmartCover TODO
Expand Down Expand Up @@ -1680,6 +1695,7 @@ type NodeOperation struct {
StreamPackInfo *NodeHlsPackInfo `xml:"StreamPackInfo,omitempty" json:"StreamPackInfo,omitempty"`
Condition *WorkflowNodeCondition `xml:"Condition,omitempty" json:"Condition,omitempty"`
SegmentVideoBody *SegmentVideoBody `xml:"SegmentVideoBody,omitempty" json:"SegmentVideoBody,omitempty"`
ImageInspect *ImageInspect `xml:"ImageInspect,omitempty" json:"ImageInspect,omitempty"`
}

// Node TODO
Expand Down Expand Up @@ -3053,6 +3069,12 @@ type InventoryTriggerJobOperationJobParam struct {
WordsGeneralize *WordsGeneralize `xml:"WordsGeneralize,omitempty"`
WordsGeneralizeResult *WordsGeneralizeResult `xml:"WordsGeneralizeResult,omitempty"`
NoiseReduction *NoiseReduction `xml:"NoiseReduction,omitempty"`
DnaConfig *DnaConfig `xml:"DnaConfig,omitempty"`
DnaResult *DnaResult `xml:"DnaResult,omitempty"`
VocalScore *VocalScore `xml:"VocalScore,omitempty"`
VocalScoreResult *VocalScoreResult `xml:"VocalScoreResult,omitempty"`
ImageInspect *ImageInspect `xml:"ImageInspect,omitempty"`
ImageInspectResult *ImageInspectResult `xml:"ImageInspectResult,omitempty"`
}

// InventoryTriggerJob TODO
Expand Down Expand Up @@ -3429,3 +3451,189 @@ type VideoSynthesisSpliceInfo struct {
Width string `xml:"Width,omitempty"`
Height string `xml:"Height,omitempty"`
}

// DnaConfig DNA任务配置
type DnaConfig struct {
RuleType string `xml:"RuleType,omitempty"`
DnaDbId string `xml:"DnaDbId,omitempty"`
VideoId string `xml:"VideoId,omitempty"`
}

// DnaResult DNA任务结果
type DnaResult struct {
VideoId string `xml:"VideoId,omitempty"`
Duration int `xml:"Duration,omitempty"`
Detection *DnaResultDetection `xml:"Detection,omitempty"`
}

// DnaResultDetection DNA任务结果
type DnaResultDetection struct {
VideoId string `xml:"VideoId,omitempty"`
Similar int `xml:"Similar,omitempty"`
SimilarDuration int `xml:"SimilarDuration,omitempty"`
Duration int `xml:"Duration,omitempty"`
MatchDetail []DnaResultMatchDetail `xml:"MatchDetail,omitempty"`
Audio DnaResultAudio `xml:"Audio,omitempty"`
}

// DnaResultDetection DNA任务结果
type DnaResultMatchDetail struct {
MatchStartTime int `xml:"MatchStartTime,omitempty"`
MatchEndTime int `xml:"MatchEndTime,omitempty"`
SrcStartTime int `xml:"SrcStartTime,omitempty"`
SrcEndTime int `xml:"SrcEndTime,omitempty"`
}

// DnaResultAudio DNA任务结果
type DnaResultAudio struct {
Similar int `xml:"Similar,omitempty"`
}

// GetDnaDbOptions 查询 DNA 库列表参数
type GetDnaDbOptions struct {
Ids string `url:"ids,omitempty"`
PageNumber string `url:"pageNumber,omitempty"`
PageSize string `url:"pageSize,omitempty"`
}

// GetDnaDbResult 查询 DNA 库列表结果
type GetDnaDbResult struct {
XMLName xml.Name `xml:"Response"`
RequestId string `xml:"RequestId,omitempty"`
TotalCount int `xml:"TotalCount,omitempty"`
PageNumber int `xml:"PageNumber,omitempty"`
PageSize int `xml:"PageSize,omitempty"`
DNADbConfig []DNADbConfig `xml:"DNADbConfig,omitempty"`
NonExistIDs []string `xml:"NonExistIDs,omitempty"`
}

// DNADbConfig DNA 库详情
type DNADbConfig struct {
BucketId string `xml:"BucketId,omitempty"`
Region string `xml:"Region,omitempty"`
DNADbId string `xml:"DNADbId,omitempty"`
DNADbName string `xml:"DNADbName,omitempty"`
Capacity int `xml:"Capacity,omitempty"`
Description string `xml:"Description,omitempty"`
UpdateTime string `xml:"UpdateTime,omitempty"`
CreateTime string `xml:"CreateTime,omitempty"`
}

// GetDnaDb 查询 DNA 库列表
func (s *CIService) GetDnaDb(ctx context.Context, opt *GetDnaDbOptions) (*GetDnaDbResult, *Response, error) {
var res GetDnaDbResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/dnadb",
optQuery: opt,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}

// GetDnaDbFilesOptions 获取 DNA 库中文件列表参数
type GetDnaDbFilesOptions struct {
object string `url:"object,omitempty"`
DnaDbId string `url:"dnaDbId,omitempty"`
PageNumber string `url:"pageNumber,omitempty"`
PageSize string `url:"pageSize,omitempty"`
}

// GetDnaDbFilesResult 查询 DNA 库列表结果
type GetDnaDbFilesResult struct {
XMLName xml.Name `xml:"Response"`
RequestId string `xml:"RequestId,omitempty"`
TotalCount int `xml:"TotalCount,omitempty"`
PageNumber int `xml:"PageNumber,omitempty"`
PageSize int `xml:"PageSize,omitempty"`
DNADbFiles []DNADbFiles `xml:"DNADbFiles,omitempty"`
}

// DNADbFiles DNA 文件详情
type DNADbFiles struct {
BucketId string `xml:"BucketId,omitempty"`
Region string `xml:"Region,omitempty"`
DNADbId string `xml:"DNADbId,omitempty"`
VideoId string `xml:"VideoId,omitempty"`
Object int `xml:"Object,omitempty"`
ETag string `xml:"ETag,omitempty"`
UpdateTime string `xml:"UpdateTime,omitempty"`
CreateTime string `xml:"CreateTime,omitempty"`
}

// GetDnaDb 查询 DNA 库列表
func (s *CIService) GetDnaDbFiles(ctx context.Context, opt *GetDnaDbFilesOptions) (*GetDnaDbFilesResult, *Response, error) {
var res GetDnaDbFilesResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/dnadb_files",
optQuery: opt,
method: http.MethodGet,
result: &res,
}
resp, err := s.client.send(ctx, &sendOpt)
return &res, resp, err
}

// VocalScore 音乐评分
type VocalScore struct {
StandardObject string `xml:"StandardObject,omitempty"`
}

// VocalScore 音乐评分结果
type VocalScoreResult struct {
PitchScore *VocalScoreResultPitchScore `xml:"PitchScore,omitempty"`
RhythemScore *VocalScoreResultRhythemScore `xml:"RhythemScore,omitempty"`
}

type VocalScoreResultPitchScore struct {
TotalScore float64 `xml:"TotalScore,omitempty"`
SentenceScores []VocalScoreResultSentenceScores `xml:"SentenceScores,omitempty"`
}

type VocalScoreResultSentenceScores struct {
StartTime float64 `xml:"StartTime,omitempty"`
EndTime float64 `xml:"EndTime,omitempty"`
Score float64 `xml:"Score,omitempty"`
}

type VocalScoreResultRhythemScore struct {
TotalScore float64 `xml:"TotalScore,omitempty"`
SentenceScores []VocalScoreResultSentenceScores `xml:"SentenceScores,omitempty"`
}

// ImageInspect 黑产检测
type ImageInspect struct {
AutoProcess string `xml:"AutoProcess,omitempty"`
ProcessType string `xml:"ProcessType,omitempty"`
}

// ImageInspectResult 黑产检测结果
type ImageInspectResult struct {
State string `xml:"State,omitempty"`
Code string `xml:"Code,omitempty"`
Message string `xml:"Message,omitempty"`
InputObjectName string `xml:"InputObjectName,omitempty"`
InputObjectUrl string `xml:"InputObjectUrl,omitempty"`
ProcessResult *ImageInspectProcessResult `xml:"ProcessResult,omitempty"`
}

// ImageInspectProcessResult 黑产检测结果
type ImageInspectProcessResult struct {
PicSize int `xml:"PicSize,omitempty"`
PicType string `xml:"PicType,omitempty"`
Suspicious string `xml:"Suspicious,omitempty"`
SuspiciousBeginByte int `xml:"SuspiciousBeginByte,omitempty"`
SuspiciousEndByte int `xml:"SuspiciousEndByte,omitempty"`
SuspiciousSize int `xml:"SuspiciousSize,omitempty"`
SuspiciousType string `xml:"SuspiciousType,omitempty"`
AutoProcessResult *ImageInspectAutoProcessResult `xml:"AutoProcessResult,omitempty"`
}

// ImageInspectResult 黑产检测结果
type ImageInspectAutoProcessResult struct {
Code string `xml:"Code,omitempty"`
Message string `xml:"Message,omitempty"`
}
46 changes: 46 additions & 0 deletions ci_media_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3320,3 +3320,49 @@ func TestCIService_DeleteTemplate(t *testing.T) {
t.Fatalf("CI.DeleteTemplate returned error: %v", err)
}
}

func TestCIService_GetDnaDb(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/dnadb", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
v := values{
"pageNumber": "2",
"pageSize": "10",
}
testFormValues(t, r, v)
})
opt := &GetDnaDbOptions{
PageNumber: "2",
PageSize: "10",
}

_, _, err := client.CI.GetDnaDb(context.Background(), opt)
if err != nil {
t.Fatalf("CI.GetDnaDb returned error: %v", err)
}
}

func TestCIService_GetDnaDbFiles(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/dnadb_files", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
v := values{
"pageNumber": "2",
"pageSize": "10",
}
testFormValues(t, r, v)
})
opt := &GetDnaDbFilesOptions{
PageNumber: "2",
PageSize: "10",
}

_, _, err := client.CI.GetDnaDbFiles(context.Background(), opt)
if err != nil {
t.Fatalf("CI.GetDnaDbFiles returned error: %v", err)
}
}
2 changes: 1 addition & 1 deletion cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

const (
// Version current go sdk version
Version = "0.7.42"
Version = "0.7.43"
UserAgent = "cos-go-sdk-v5/" + Version
contentTypeXML = "application/xml"
defaultServiceBaseURL = "http://service.cos.myqcloud.com"
Expand Down
Loading

0 comments on commit 113753b

Please sign in to comment.