本文为您提供了服务端 Go SDK 的点播 CDN 模块的接口调用示例。
接口请求参数和返回参数详见 OpenAPI:创建域名。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_CreateDomain(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodCreateDomainV2Request{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", SourceStationType: 0, SourceStationAddressType: 0, Origins: "your Origins", Area: "your Area", BucketName: "your BucketName", } resp, status, err := instance.CreateDomain(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:启用域名。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_StartDomain(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodStartDomainRequest{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", SourceStationType: 0, } resp, status, err := instance.StartDomain(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:停用域名。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_StopDomain(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodStopDomainRequest{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", SourceStationType: 0, } resp, status, err := instance.StopDomain(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:删除域名。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_DeleteDomain(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodDeleteDomainRequest{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", } resp, status, err := instance.DeleteDomain(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:获取空间域名列表。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_ListDomain(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodListDomainRequest{ SpaceName: "your SpaceName", DomainType: "your DomainType", SourceStationType: 0, Offset: 0, Limit: 0, } resp, status, err := instance.ListDomain(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:将域名添加至点播调度。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_AddDomainToScheduler(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodAddDomainToSchedulerRequest{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", SourceStationType: 0, } resp, status, err := instance.AddDomainToScheduler(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:将域名移除点播调度。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_RemoveDomainFromScheduler(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodRemoveDomainFromSchedulerRequest{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", SourceStationType: 0, } resp, status, err := instance.RemoveDomainFromScheduler(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:设置域名分发规则。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_UpdateDomainPlayRule(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodUpdateDomainPlayRuleRequest{ SpaceName: "your SpaceName", DefaultDomain: "your DefaultDomain", PlayRule: "your PlayRule", } resp, status, err := instance.UpdateDomainPlayRule(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:修改域名时间戳防盗链。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_UpdateDomainExpire(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodUpdateDomainExpireV2Request{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", Expire: 0, } resp, status, err := instance.UpdateDomainExpire(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:修改域名 URL 鉴权配置。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_UpdateDomainUrlAuthConfig(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodUpdateDomainUrlAuthConfigV2Request{ SpaceName: "your SpaceName", DomainType: "your DomainType", Domain: "your Domain", MainKey: "your MainKey", BackupKey: "your BackupKey", Status: "your Status", } resp, status, err := instance.UpdateDomainUrlAuthConfig(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:刷新缓存。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_CreateCdnRefreshTask(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodCreateCdnRefreshTaskRequest{ SpaceName: "your SpaceName", Urls: "your Urls", Type: "your Type", } resp, status, err := instance.CreateCdnRefreshTask(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:预热缓存。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_CreateCdnPreloadTask(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodCreateCdnPreloadTaskRequest{ SpaceName: "your SpaceName", Urls: "your Urls", } resp, status, err := instance.CreateCdnPreloadTask(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:获取刷新预热任务列表。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_ListCdnTasks(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodListCdnTasksRequest{ SpaceName: "your SpaceName", TaskId: "your TaskId", DomainName: "your DomainName", TaskType: "your TaskType", Status: "your Status", StartTimestamp: 0, EndTimestamp: 0, PageNum: 0, PageSize: 0, } resp, status, err := instance.ListCdnTasks(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
接口请求参数和返回参数详见 OpenAPI:获取日志文件下载地址。
import ( "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_ListCdnAccessLog(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // instance.SetCredential(base.Credentials{ // AccessKeyID: "your ak", // SecretAccessKey: "your sk", //}) query := &request.VodListCdnAccessLogRequest{ Domains: "your Domains", StartTimestamp: 0, EndTimestamp: 0, SpaceName: "your SpaceName", } resp, status, err := instance.ListCdnAccessLog(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }