Skip to content

Commit f71fa88

Browse files
authored
Merge pull request #208 from tencentyun/feature_jojoliang_3259afb9
Feature jojoliang 3259afb9
2 parents ceda434 + 462b1e2 commit f71fa88

File tree

11 files changed

+595
-43
lines changed

11 files changed

+595
-43
lines changed

ci.go

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type AuditingMaskLiveInfo struct {
144144
Output string `xml:"Output,omitempty"`
145145
}
146146

147-
//UserListResults 命中账号黑白名单信息
147+
// UserListResults 命中账号黑白名单信息
148148
type UserListResults struct {
149149
ListType *int `xml:",omitempty"`
150150
ListName string `xml:",omitempty"`
@@ -1774,6 +1774,95 @@ func (s *CIService) FaceEffect(ctx context.Context, obj string, opt *FaceEffectO
17741774
return &res, resp, err
17751775
}
17761776

1777+
type PetEffectResult struct {
1778+
XMLName xml.Name `xml:"Response"`
1779+
ResultInfo []struct {
1780+
Score int `xml:"Score,omitempty"`
1781+
Name string `xml:"Name,omitempty"`
1782+
Location struct {
1783+
X int `xml:"X,omitempty"`
1784+
Y int `xml:"Y,omitempty"`
1785+
Height int `xml:"Height,omitempty"`
1786+
Width int `xml:"Width,omitempty"`
1787+
} `xml:"Location,omitempty"`
1788+
} `xml:"ResultInfo,omitempty"`
1789+
}
1790+
1791+
func (s *CIService) EffectPet(ctx context.Context, obj string) (*PetEffectResult, *Response, error) {
1792+
var res PetEffectResult
1793+
sendOpt := &sendOptions{
1794+
baseURL: s.client.BaseURL.BucketURL,
1795+
method: http.MethodGet,
1796+
uri: "/" + encodeURIComponent(obj) + "?ci-process=detect-pet",
1797+
result: &res,
1798+
}
1799+
resp, err := s.client.send(ctx, sendOpt)
1800+
return &res, resp, err
1801+
}
1802+
1803+
type AILicenseRecOptions struct {
1804+
DetectUrl string `url:"detect-url,omitempty"`
1805+
CardType string `url:"CardType,omitempty"`
1806+
}
1807+
1808+
type AILicenseRecResult struct {
1809+
XMLName xml.Name `xml:"Response"`
1810+
Status int `xml:"Status,omitempty"`
1811+
IdInfo []struct {
1812+
Name string `xml:"Name,omitempty"`
1813+
DetectedText string `xml:"DetectedText,omitempty"`
1814+
Score int `xml:"Score,omitempty"`
1815+
Location struct {
1816+
Point []string `xml:"Point,omitempty"`
1817+
} `xml:"Location,omitempty"`
1818+
} `xml:"IdInfo,omitempty"`
1819+
}
1820+
1821+
func (s *CIService) AILicenseRec(ctx context.Context, obj string, opt *AILicenseRecOptions) (*AILicenseRecResult, *Response, error) {
1822+
var res AILicenseRecResult
1823+
sendOpt := &sendOptions{
1824+
baseURL: s.client.BaseURL.BucketURL,
1825+
method: http.MethodGet,
1826+
uri: "/" + encodeURIComponent(obj) + "?ci-process=AILicenseRec",
1827+
optQuery: opt,
1828+
result: &res,
1829+
}
1830+
resp, err := s.client.send(ctx, sendOpt)
1831+
return &res, resp, err
1832+
}
1833+
1834+
type AIObjectDetectOptions struct {
1835+
DetectUrl string `url:"detect-url,omitempty"`
1836+
}
1837+
1838+
type AIObjectDetectResult struct {
1839+
XMLName xml.Name `xml:"RecognitionResult"`
1840+
Status int `xml:"Status,omitempty"`
1841+
DetectMultiObj []struct {
1842+
Name string `xml:"Name,omitempty"`
1843+
Confidence int `xml:"Confidence,omitempty"`
1844+
Location struct {
1845+
X int `xml:"X,omitempty"`
1846+
Y int `xml:"Y,omitempty"`
1847+
Width int `xml:"Width,omitempty"`
1848+
Height int `xml:"Height,omitempty"`
1849+
} `xml:"Location,omitempty"`
1850+
} `xml:"DetectMultiObj,omitempty"`
1851+
}
1852+
1853+
func (s *CIService) AIObjectDetect(ctx context.Context, obj string, opt *AIObjectDetectOptions) (*AIObjectDetectResult, *Response, error) {
1854+
var res AIObjectDetectResult
1855+
sendOpt := &sendOptions{
1856+
baseURL: s.client.BaseURL.BucketURL,
1857+
method: http.MethodGet,
1858+
uri: "/" + encodeURIComponent(obj) + "?ci-process=AIObjectDetect",
1859+
optQuery: opt,
1860+
result: &res,
1861+
}
1862+
resp, err := s.client.send(ctx, sendOpt)
1863+
return &res, resp, err
1864+
}
1865+
17771866
type IdCardOCROptions struct {
17781867
CardSide string `url:"CardSide,omitempty"`
17791868
Config *IdCardOCROptionsConfig `url:"Config,omitempty"`

ci_fileprocess.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ type FileHashCodeResult struct {
2121
}
2222

2323
type FileUncompressConfig struct {
24-
Prefix string `xml:",omitempty"`
25-
PrefixReplaced string `xml:",omitempty"`
26-
UnCompressKey string `xml:",omitempty"`
24+
Prefix string `xml:",omitempty"`
25+
PrefixReplaced string `xml:",omitempty"`
26+
UnCompressKey string `xml:",omitempty"`
27+
Mode string `xml:",omitempty"`
28+
DownloadConfig *FileUncompressDownloadConfig `xml:",omitempty"`
29+
}
30+
31+
type FileUncompressDownloadConfig struct {
32+
Prefix string `xml:",omitempty"`
33+
Key []string `xml:",omitempty"`
2734
}
2835

2936
type FileUncompressResult struct {
@@ -40,12 +47,15 @@ type FileCompressConfig struct {
4047
Key []string `xml:",omitempty"`
4148
Type string `xml:",omitempty"`
4249
CompressKey string `xml:",omitempty"`
50+
IgnoreError string `xml:",omitempty"`
4351
}
4452

4553
type FileCompressResult struct {
46-
Region string `xml:",omitempty"`
47-
Bucket string `xml:",omitempty"`
48-
Object string `xml:",omitempty"`
54+
Region string `xml:",omitempty"`
55+
Bucket string `xml:",omitempty"`
56+
Object string `xml:",omitempty"`
57+
CompressFileCount int `xml:",omitempty"`
58+
ErrorCount int `xml:",omitempty"`
4959
}
5060

5161
type FileProcessInput FileCompressResult
@@ -154,9 +164,10 @@ func (s *CIService) GetFileHash(ctx context.Context, name string, opt *GetFileHa
154164

155165
// ZipPreviewResult 压缩包预览结果
156166
type ZipPreviewResult struct {
157-
XMLName xml.Name `xml:"Response"`
158-
FileNumber int `xml:"FileNumber,omitempty"`
159-
Contents []*struct {
167+
XMLName xml.Name `xml:"Response"`
168+
FileNumber int `xml:"FileNumber,omitempty"`
169+
IsTruncated bool `xml:"IsTruncated,omitempty"`
170+
Contents []*struct {
160171
Key string `xml:"Key,omitempty"`
161172
LastModified string `xml:"LastModified,omitempty"`
162173
UncompressedSize int `xml:"UncompressedSize,omitempty"`

ci_media.go

Lines changed: 97 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cos
22

33
import (
44
"context"
5+
"encoding/json"
56
"encoding/xml"
67
"errors"
78
"fmt"
@@ -57,30 +58,38 @@ type Container struct {
5758

5859
// Video TODO
5960
type Video struct {
60-
Codec string `xml:"Codec"`
61-
Width string `xml:"Width,omitempty"`
62-
Height string `xml:"Height,omitempty"`
63-
Fps string `xml:"Fps,omitempty"`
64-
Remove string `xml:"Remove,omitempty"`
65-
Profile string `xml:"Profile,omitempty"`
66-
Bitrate string `xml:"Bitrate,omitempty"`
67-
Crf string `xml:"Crf,omitempty"`
68-
Gop string `xml:"Gop,omitempty"`
69-
Preset string `xml:"Preset,omitempty"`
70-
Bufsize string `xml:"Bufsize,omitempty"`
71-
Maxrate string `xml:"Maxrate,omitempty"`
72-
HlsTsTime string `xml:"HlsTsTime,omitempty"`
73-
DashSegment string `xml:"DashSegment,omitempty"`
74-
Pixfmt string `xml:"Pixfmt,omitempty"`
75-
LongShortMode string `xml:"LongShortMode,omitempty"`
76-
Rotate string `xml:"Rotate,omitempty"`
77-
AnimateOnlyKeepKeyFrame string `xml:"AnimateOnlyKeepKeyFrame,omitempty"`
78-
AnimateTimeIntervalOfFrame string `xml:"AnimateTimeIntervalOfFrame,omitempty"`
79-
AnimateFramesPerSecond string `xml:"AnimateFramesPerSecond,omitempty"`
80-
Quality string `xml:"Quality,omitempty"`
81-
Roi string `xml:"Roi,omitempty"`
82-
Crop string `xml:"Crop,omitempty"`
83-
Interlaced string `xml:"Interlaced,omitempty"`
61+
Codec string `xml:"Codec"`
62+
Width string `xml:"Width,omitempty"`
63+
Height string `xml:"Height,omitempty"`
64+
Fps string `xml:"Fps,omitempty"`
65+
Remove string `xml:"Remove,omitempty"`
66+
Profile string `xml:"Profile,omitempty"`
67+
Bitrate string `xml:"Bitrate,omitempty"`
68+
Crf string `xml:"Crf,omitempty"`
69+
Gop string `xml:"Gop,omitempty"`
70+
Preset string `xml:"Preset,omitempty"`
71+
Bufsize string `xml:"Bufsize,omitempty"`
72+
Maxrate string `xml:"Maxrate,omitempty"`
73+
HlsTsTime string `xml:"HlsTsTime,omitempty"`
74+
DashSegment string `xml:"DashSegment,omitempty"`
75+
Pixfmt string `xml:"Pixfmt,omitempty"`
76+
LongShortMode string `xml:"LongShortMode,omitempty"`
77+
Rotate string `xml:"Rotate,omitempty"`
78+
AnimateOnlyKeepKeyFrame string `xml:"AnimateOnlyKeepKeyFrame,omitempty"`
79+
AnimateTimeIntervalOfFrame string `xml:"AnimateTimeIntervalOfFrame,omitempty"`
80+
AnimateFramesPerSecond string `xml:"AnimateFramesPerSecond,omitempty"`
81+
Quality string `xml:"Quality,omitempty"`
82+
Roi string `xml:"Roi,omitempty"`
83+
Crop string `xml:"Crop,omitempty"`
84+
Interlaced string `xml:"Interlaced,omitempty"`
85+
ColorParam *VideoColorParam `xml:"ColorParam,omitempty"`
86+
}
87+
88+
type VideoColorParam struct {
89+
ColorRange string `xml:"ColorRange,omitempty"`
90+
ColorSpace string `xml:"ColorSpace,omitempty"`
91+
ColorTrc string `xml:"ColorTrc,omitempty"`
92+
ColorPrimaries string `xml:"ColorPrimaries,omitempty"`
8493
}
8594

8695
// TranscodeProVideo TODO
@@ -265,6 +274,7 @@ type ConcatFragment struct {
265274
StartTime string `xml:"StartTime,omitempty"`
266275
EndTime string `xml:"EndTime,omitempty"`
267276
FragmentIndex string `xml:"FragmentIndex,omitempty"`
277+
Duration string `xml:"Duration,omitempty"`
268278
}
269279

270280
// ConcatTemplate TODO
@@ -1173,6 +1183,23 @@ func (s *CIService) DescribeASRProcessQueues(ctx context.Context, opt *DescribeM
11731183
return &res, resp, err
11741184
}
11751185

1186+
type DescribeFielProcessQueuesOptions DescribeMediaProcessQueuesOptions
1187+
type DescribeFileProcessQueuesResult DescribeMediaProcessQueuesResult
1188+
1189+
// DescribeFileProcessQueues TODO
1190+
func (s *CIService) DescribeFileProcessQueues(ctx context.Context, opt *DescribeFielProcessQueuesOptions) (*DescribeFileProcessQueuesResult, *Response, error) {
1191+
var res DescribeFileProcessQueuesResult
1192+
sendOpt := sendOptions{
1193+
baseURL: s.client.BaseURL.CIURL,
1194+
uri: "/file_queue",
1195+
optQuery: opt,
1196+
method: http.MethodGet,
1197+
result: &res,
1198+
}
1199+
resp, err := s.client.send(ctx, &sendOpt)
1200+
return &res, resp, err
1201+
}
1202+
11761203
// UpdateMediaProcessQueueOptions TODO
11771204
type UpdateMediaProcessQueueOptions struct {
11781205
XMLName xml.Name `xml:"Request"`
@@ -1582,11 +1609,15 @@ type NotifyConfig struct {
15821609

15831610
// ExtFilter TODO
15841611
type ExtFilter struct {
1585-
State string `xml:"State,omitempty"`
1586-
Audio string `xml:"Audio,omitempty"`
1587-
Custom string `xml:"Custom,omitempty"`
1588-
CustomExts string `xml:"CustomExts,omitempty"`
1589-
AllFile string `xml:"AllFile,omitempty"`
1612+
State string `xml:"State,omitempty"`
1613+
Video string `xml:"Video,omitempty"`
1614+
Audio string `xml:"Audio,omitempty"`
1615+
Image string `xml:"Image,omitempty"`
1616+
ContentType string `xml:"ContentType,omitempty"`
1617+
Custom string `xml:"Custom,omitempty"`
1618+
CustomExts string `xml:"CustomExts,omitempty"`
1619+
AllFile string `xml:"AllFile,omitempty"`
1620+
AutoContentType []string `xml:"AutoContentType,omitempty"`
15901621
}
15911622

15921623
// NodeInput TODO
@@ -3641,3 +3672,40 @@ type ImageInspectAutoProcessResult struct {
36413672
Code string `xml:"Code,omitempty"`
36423673
Message string `xml:"Message,omitempty"`
36433674
}
3675+
3676+
type CosImageInspectOptions struct {
3677+
}
3678+
3679+
// CosImageInspectProcessResult 黑产检测同步接口结果
3680+
type CosImageInspectProcessResult struct {
3681+
PicSize int `json:"picSize,omitempty"`
3682+
PicType string `json:"picType,omitempty"`
3683+
Suspicious bool `json:"suspicious,omitempty"`
3684+
SuspiciousBeginByte int `json:"suspiciousBeginByte,omitempty"`
3685+
SuspiciousEndByte int `json:"suspiciousEndByte,omitempty"`
3686+
SuspiciousSize int `json:"suspiciousSize,omitempty"`
3687+
SuspiciousType string `json:"suspiciousType,omitempty"`
3688+
}
3689+
3690+
// Write 回包是json格式序列化
3691+
func (w *CosImageInspectProcessResult) Write(p []byte) (n int, err error) {
3692+
err = json.Unmarshal(p, w)
3693+
if err != nil {
3694+
return 0, err
3695+
}
3696+
return len(p), nil
3697+
}
3698+
3699+
// ImageInspect 黑产检查同步接口
3700+
func (s *CIService) CosImageInspect(ctx context.Context, name string, opt *CosImageInspectOptions) (*CosImageInspectProcessResult, *Response, error) {
3701+
var res CosImageInspectProcessResult
3702+
sendOpt := sendOptions{
3703+
baseURL: s.client.BaseURL.BucketURL,
3704+
uri: "/" + encodeURIComponent(name) + "?ci-process=ImageInspect",
3705+
optQuery: opt,
3706+
method: http.MethodGet,
3707+
result: &res,
3708+
}
3709+
resp, err := s.client.send(ctx, &sendOpt)
3710+
return &res, resp, err
3711+
}

ci_media_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,29 @@ func TestCIService_DescribeASRProcessQueues(t *testing.T) {
383383
}
384384
}
385385

386+
func TestCIService_DescribeFileProcessQueues(t *testing.T) {
387+
setup()
388+
defer teardown()
389+
390+
queueIds := "A,B,C"
391+
mux.HandleFunc("/file_queue", func(w http.ResponseWriter, r *http.Request) {
392+
testMethod(t, r, http.MethodGet)
393+
v := values{
394+
"queueIds": queueIds,
395+
}
396+
testFormValues(t, r, v)
397+
})
398+
399+
opt := &DescribeFielProcessQueuesOptions{
400+
QueueIds: queueIds,
401+
}
402+
403+
_, _, err := client.CI.DescribeFileProcessQueues(context.Background(), opt)
404+
if err != nil {
405+
t.Fatalf("CI.DescribeFileProcessQueues returned error: %v", err)
406+
}
407+
}
408+
386409
func TestCIService_UpdateMediaProcessQueue(t *testing.T) {
387410
setup()
388411
defer teardown()
@@ -3366,3 +3389,23 @@ func TestCIService_GetDnaDbFiles(t *testing.T) {
33663389
t.Fatalf("CI.GetDnaDbFiles returned error: %v", err)
33673390
}
33683391
}
3392+
3393+
func TestCIService_CosImageInspect(t *testing.T) {
3394+
setup()
3395+
defer teardown()
3396+
3397+
name := "/test.jpg"
3398+
mux.HandleFunc(name, func(w http.ResponseWriter, r *http.Request) {
3399+
testMethod(t, r, http.MethodGet)
3400+
v := values{
3401+
"ci-process": "ImageInspect",
3402+
}
3403+
testFormValues(t, r, v)
3404+
})
3405+
opt := &CosImageInspectOptions{}
3406+
3407+
_, _, err := client.CI.CosImageInspect(context.Background(), name, opt)
3408+
if err != nil {
3409+
t.Fatalf("CI.CosImageInspect returned error: %v", err)
3410+
}
3411+
}

0 commit comments

Comments
 (0)