Skip to content

Commit

Permalink
Add features in mcp and ddc
Browse files Browse the repository at this point in the history
  • Loading branch information
liegu committed Jan 10, 2025
1 parent 35bc54d commit 97dfdc7
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 21 deletions.
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
发行说明:记录每次SDK更新的说明,最新版本的SDK包含以前所有版本的更新内容。
---------------------------------------------------------------------
【版本:v0.9.213】
涉及产品:MCP
font补充color参数
涉及产品:DDC
实例变配新增参数BufferPoolStepSize,设置步幅大小

【版本:v0.9.212】
涉及产品:BLB
Expand Down
2 changes: 1 addition & 1 deletion bce/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

// Constants and default values for the package bce
const (
SDK_VERSION = "0.9.212"
SDK_VERSION = "0.9.213"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"
Expand Down
2 changes: 2 additions & 0 deletions doc/DDCv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,8 @@ args := &ddcrds.ResizeRdsArgs{
//IsResizeNow: true,
// 变配时间窗口控制。0:立即变配;1:维护时间内变配;2:用户控制执行时机
WaitSwitch: 0,
// 非必填参数。步幅大小,取值范围限制在2~8,单位GB,只有在本地变配时生效
BufferPoolStepSize: 2,
}
orderIdResponse, err = client.ResizeRds(instanceId, args)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion services/cdn/abroad/api/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ func ListDomainInfos(cli bce.Client, marker string) ([]DomainInfo, string, error
// RETURNS:
// - *DomainCreatedInfo: the details about created a ABROAD-CDN domain
// - error: nil if success otherwise the specific error
func CreateDomain(cli bce.Client, domain string, originConfig []OriginPeer, tags []model.TagModel) (*DomainCreatedInfo, error) {
func CreateDomain(cli bce.Client, domain string, originConfig []OriginPeer, tags []model.TagModel, form string) (*DomainCreatedInfo, error) {
urlPath := fmt.Sprintf("/v2/abroad/domain/%s", domain)
respObj := &DomainCreatedInfo{}

type Request struct {
OriginConfig []OriginPeer `json:"originConfig"`
Tags []model.TagModel `json:"tags,omitempty"`
Form string `json:"form,omitempty"`
}

requestObject := &Request{
OriginConfig: originConfig,
Tags: tags,
Form: form,
}
err := httpRequest(cli, "POST", urlPath, nil, requestObject, respObj)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions services/cdn/abroad/api/domain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const (
HTTPSOrigin = "https"
)

const (
DynamicDomainForm = "dynamic"
)

// DomainConfig defined a struct for total configurations.
type DomainConfig struct {
Domain string `json:"domain"`
Expand Down
19 changes: 10 additions & 9 deletions services/cdn/abroad/api/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ import (
// SendCustomRequest - send a HTTP request, and response data or error, it use the default times for retrying
//
// PARAMS:
// - cli: the client agent which can perform sending request
// - method: the HTTP requested method, e.g. "GET", "POST", "PUT" ...
// - urlPath: a path component, consisting of a sequence of path segments separated by a slash ( / ).
// - params: the query params, which will be append to the query path, and separate by "&"
// e.g. http://www.baidu.com?query_param1=value1&query_param2=value2
// - reqHeaders: the request http headers
// - bodyObj: the HTTP requested body content transferred to a goland object
// - respObj: the HTTP response content transferred to a goland object
// - cli: the client agent which can perform sending request
// - method: the HTTP requested method, e.g. "GET", "POST", "PUT" ...
// - urlPath: a path component, consisting of a sequence of path segments separated by a slash ( / ).
// - params: the query params, which will be append to the query path, and separate by "&"
// e.g. http://www.baidu.com?query_param1=value1&query_param2=value2
// - reqHeaders: the request http headers
// - bodyObj: the HTTP requested body content transferred to a goland object
// - respObj: the HTTP response content transferred to a goland object
//
// RETURNS:
// - error: nil if success otherwise the specific error
// - error: nil if success otherwise the specific error
func SendCustomRequest(cli bce.Client, method string, urlPath string, params, reqHeaders map[string]string, bodyObj interface{}, respObj interface{}) error {
if method != "GET" && method != "POST" && method != "PUT" && method != "DELETE" {
return errors.New("invalid http method")
Expand Down
14 changes: 12 additions & 2 deletions services/cdn/abroad/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,18 @@ func CreateDomainWithTags(tags []model.TagModel) CreateDomainOption {
}
}

func CreateDomainWithForm(form string) CreateDomainOption {
return func(o interface{}) {
cfg, ok := o.(*createDomainOption)
if ok {
cfg.form = form
}
}
}

type createDomainOption struct {
tags []model.TagModel
form string
}

// CreateDomain - create a BCE ABROAD-CDN domain
Expand All @@ -122,7 +132,7 @@ type createDomainOption struct {
// - *DomainCreatedInfo: the details about created a ABROAD-CDN domain
// - error: nil if success otherwise the specific error
func (cli *Client) CreateDomain(domain string, originConfig []api.OriginPeer) (*api.DomainCreatedInfo, error) {
return api.CreateDomain(cli, domain, originConfig, nil)
return api.CreateDomain(cli, domain, originConfig, nil, "")
}

// CreateDomainWithOptions - create a BCE ABROAD-CDN domain with optional configurations.
Expand All @@ -141,7 +151,7 @@ func (cli *Client) CreateDomainWithOptions(domain string, origins []api.OriginPe
for _, opt := range opts {
opt(&cfg)
}
return api.CreateDomain(cli, domain, origins, cfg.tags)
return api.CreateDomain(cli, domain, origins, cfg.tags, cfg.form)
}

// EnableDomain - enable a specified domain
Expand Down
15 changes: 15 additions & 0 deletions services/cdn/abroad/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,21 @@ func TestClient_CreateDomainWithOptions(t *testing.T) {
t.Logf("CreateDomainWithOptions for %s success: %+v", testDomain, info)
}

func TestClient_CreateDomainForDynamic(t *testing.T) {
info, err := testCli.CreateDomainWithOptions(testDomain, []api.OriginPeer{
{
Type: "IP",
Backup: false,
Addr: "1.6.7.8",
},
}, CreateDomainWithForm(api.DynamicDomainForm))
if err != nil {
t.Fatalf("CreateDomainForDynamic for %s failed: %s", testDomain, err)
}

t.Logf("CreateDomainForDynamic for %s success: %+v", testDomain, info)
}

func TestClient_EnableDomain(t *testing.T) {
err := testCli.EnableDomain(testDomain)
if err != nil {
Expand Down
17 changes: 9 additions & 8 deletions services/ddc/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,14 +840,15 @@ type CreateRdsProxyArgs struct {
}

type ResizeRdsArgs struct {
ClientToken string `json:"-"`
CpuCount int `json:"cpuCount"`
MemoryCapacity float64 `json:"memoryCapacity"`
VolumeCapacity int `json:"volumeCapacity"`
NodeAmount int `json:"nodeAmount,omitempty"`
IsDirectPay bool `json:"isDirectPay,omitempty"`
IsResizeNow bool `json:"isResizeNow,omitempty"`
WaitSwitch int `json:"waitSwitch,omitempty"`
ClientToken string `json:"-"`
CpuCount int `json:"cpuCount"`
MemoryCapacity float64 `json:"memoryCapacity"`
VolumeCapacity int `json:"volumeCapacity"`
NodeAmount int `json:"nodeAmount,omitempty"`
IsDirectPay bool `json:"isDirectPay,omitempty"`
IsResizeNow bool `json:"isResizeNow,omitempty"`
WaitSwitch int `json:"waitSwitch,omitempty"`
BufferPoolStepSize int `json:"bufferPoolStepSize,omitempty"`
}

type OrderIdResponse struct {
Expand Down
1 change: 1 addition & 0 deletions services/media/api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type Insert struct {
type Font struct {
Family string `json:"family,omitempty"`
SizeInPoint int `json:"sizeInPoint,omitempty"`
Color string `json:"color,omitempty"`
}

type Timeline struct {
Expand Down
28 changes: 28 additions & 0 deletions services/media/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,34 @@ func TestCreateJobCustomize(t *testing.T) {
t.Logf("%+v", jobResponse)
}

func TestCreateJobCustomizeFont(t *testing.T) {
args := &api.CreateJobArgs{}
args.PipelineName = "go_sdk_test"
source := &api.Source{Clips: &[]api.SourceClip{{
SourceKey: "01.mp4",
EnableDelogo: false,
DurationInMillisecond: 6656,
StartTimeInSecond: 2}}}
args.Source = source
target := &api.Target{}
targetKey := "clips_playback_watermark_delogo_crop2.mp4"
target.TargetKey = targetKey
presetName := "go_test_customize_audio_video"
target.PresetName = presetName

font := &api.Font{Color: "#FFFFFF"}
text := "hello world"
insert := &api.Insert{
Text: &text,
Font: font}
target.Inserts = &[]api.Insert{*insert}
args.Target = target

jobResponse, err := MEDIA_CLIENT.CreateJobCustomize(args)
ExpectEqual(t.Errorf, err, nil)
t.Logf("%+v", jobResponse)
}

func TestCreateJobCustomizeDelogoCrop(t *testing.T) {
args := &api.CreateJobArgs{}
args.PipelineName = "go_sdk_test"
Expand Down

0 comments on commit 97dfdc7

Please sign in to comment.