全部产品
云市场

点播CDN

更新时间:2019-01-31 17:54:31

初始化客户端

使用前请先初始化客户端,参考 InitVodClient 接口。

预热缓存

接口参数和返回字段请参考 PreloadVodObjectCaches

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. "strings"
  8. )
  9. func MyPreloadVodObjectCaches(client *vod.Client) (response *vod.PreloadVodObjectCachesResponse, err error) {
  10. request := vod.CreatePreloadVodObjectCachesRequest()
  11. objectPath := []string{"http://test.com/fd.mp4", "http://test.com/ld.mp4"}
  12. request.ObjectPath = strings.Join(objectPath, "\n")
  13. request.AcceptFormat = "JSON"
  14. return client.PreloadVodObjectCaches(request)
  15. }
  16. func main() {
  17. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  18. if err != nil {
  19. panic(err)
  20. }
  21. response, err := MyPreloadVodObjectCaches(client)
  22. if err != nil {
  23. panic(err)
  24. }
  25. fmt.Println(response.GetHttpContentString())
  26. fmt.Printf("RequestId: %s\n", response.RequestId)
  27. fmt.Printf("PreloadTaskId: %s\n", response.PreloadTaskId)
  28. }

刷新缓存

接口参数和返回字段请参考 RefreshVodObjectCaches

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. "strings"
  8. )
  9. func MyRefreshVodObjectCaches(client *vod.Client) (response *vod.RefreshVodObjectCachesResponse, err error) {
  10. request := vod.CreateRefreshVodObjectCachesRequest()
  11. objectPath := []string{"http://test.com/fd.mp4", "http://test.com/ld.mp4"}
  12. request.ObjectPath = strings.Join(objectPath, "\n")
  13. request.AcceptFormat = "JSON"
  14. return client.RefreshVodObjectCaches(request)
  15. }
  16. func main() {
  17. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  18. if err != nil {
  19. panic(err)
  20. }
  21. response, err := MyRefreshVodObjectCaches(client)
  22. if err != nil {
  23. panic(err)
  24. }
  25. fmt.Println(response.GetHttpContentString())
  26. fmt.Printf("RequestId: %s\n", response.RequestId)
  27. fmt.Printf("RefreshTaskId: %s\n", response.RefreshTaskId)
  28. }

查询刷新和预热状态

接口参数和返回字段请参考 DescribeVodRefreshTasks

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyDescribeVodRefreshTasks(client *vod.Client) (response *vod.DescribeVodRefreshTasksResponse, err error) {
  9. request := vod.CreateDescribeVodRefreshTasksRequest()
  10. request.DomainName = "test.com"
  11. request.ObjectType = "preload"
  12. request.AcceptFormat = "JSON"
  13. return client.DescribeVodRefreshTasks(request)
  14. }
  15. func main() {
  16. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  17. if err != nil {
  18. panic(err)
  19. }
  20. response, err := MyDescribeVodRefreshTasks(client)
  21. if err != nil {
  22. panic(err)
  23. }
  24. fmt.Println(response.GetHttpContentString())
  25. fmt.Printf("RequestId: %s\n", response.RequestId)
  26. for _, task := range response.Tasks.Task {
  27. fmt.Printf("%s: %s %s\n", task.ObjectPath, task.Status, task.Process)
  28. }
  29. }

查询刷新预热次数限制和余量

接口参数和返回字段请参考 DescribeVodRefreshQuota

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyDescribeVodRefreshQuota(client *vod.Client) (response *vod.DescribeVodRefreshQuotaResponse, err error) {
  9. request := vod.CreateDescribeVodRefreshQuotaRequest()
  10. request.AcceptFormat = "JSON"
  11. return client.DescribeVodRefreshQuota(request)
  12. }
  13. func main() {
  14. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  15. if err != nil {
  16. panic(err)
  17. }
  18. response, err := MyDescribeVodRefreshQuota(client)
  19. if err != nil {
  20. panic(err)
  21. }
  22. fmt.Println(response.GetHttpContentString())
  23. fmt.Printf("RequestId: %s\n", response.RequestId)
  24. fmt.Printf("PreloadQuota %s, PreloadRemain %s\n", response.PreloadQuota, response.PreloadRemain)
  25. fmt.Printf("UrlQuota %s, UrlRemain %s\n", response.UrlQuota, response.UrlRemain)
  26. }

查询流量数据

接口参数和返回字段请参考 DescribeVodDomainTrafficData

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyDescribeVodDomainTrafficData(client *vod.Client) (response *vod.DescribeVodDomainTrafficDataResponse, err error) {
  9. request := vod.CreateDescribeVodDomainTrafficDataRequest()
  10. request.DomainName = "test.com"
  11. request.StartTime = "2019-01-15T15:59:59Z"
  12. request.EndTime = "2019-01-20T15:59:58Z"
  13. request.AcceptFormat = "JSON"
  14. return client.DescribeVodDomainTrafficData(request)
  15. }
  16. func main() {
  17. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  18. if err != nil {
  19. panic(err)
  20. }
  21. response, err := MyDescribeVodDomainTrafficData(client)
  22. if err != nil {
  23. panic(err)
  24. }
  25. fmt.Println(response.GetHttpContentString())
  26. fmt.Printf("RequestId: %s\n", response.RequestId)
  27. for _, item := range response.TrafficDataPerInterval.DataModule {
  28. fmt.Printf("%s: DomesticValue %s bytes, OverseasValue %s bytes\n",
  29. item.TimeStamp, item.DomesticValue, item.OverseasValue)
  30. }
  31. }

查询网络带宽

接口参数和返回字段请参考 DescribeVodDomainBpsData

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyDescribeVodDomainBpsData(client *vod.Client) (response *vod.DescribeVodDomainBpsDataResponse, err error) {
  9. request := vod.CreateDescribeVodDomainBpsDataRequest()
  10. request.DomainName = "test.com"
  11. request.StartTime = "2019-01-15T15:59:59Z"
  12. request.EndTime = "2019-01-20T15:59:58Z"
  13. request.AcceptFormat = "JSON"
  14. return client.DescribeVodDomainBpsData(request)
  15. }
  16. func main() {
  17. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  18. if err != nil {
  19. panic(err)
  20. }
  21. response, err := MyDescribeVodDomainBpsData(client)
  22. if err != nil {
  23. panic(err)
  24. }
  25. fmt.Println(response.GetHttpContentString())
  26. fmt.Printf("RequestId: %s\n", response.RequestId)
  27. for _, item := range response.BpsDataPerInterval.DataModule {
  28. fmt.Printf("%s: Value %s bps, OverseasValue %s bps\n",
  29. item.TimeStamp, item.Value, item.OverseasValue)
  30. }
  31. }

下载域名日志

接口参数和返回字段请参考 DescribeVodDomainLog

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyDescribeVodDomainLog(client *vod.Client) (response *vod.DescribeVodDomainLogResponse, err error) {
  9. request := vod.CreateDescribeVodDomainLogRequest()
  10. request.DomainName = "vod-test1.cn-shanghai.aliyuncs.com"
  11. request.StartTime = "2019-01-15T15:59:59Z"
  12. request.EndTime = "2019-01-20T15:59:58Z"
  13. request.PageNumber = "1"
  14. request.PageSize = "300"
  15. request.AcceptFormat = "JSON"
  16. return client.DescribeVodDomainLog(request)
  17. }
  18. func main() {
  19. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  20. if err != nil {
  21. panic(err)
  22. }
  23. response, err := MyDescribeVodDomainLog(client)
  24. if err != nil {
  25. panic(err)
  26. }
  27. fmt.Println(response.GetHttpContentString())
  28. fmt.Printf("RequestId: %s\n", response.RequestId)
  29. logDetail := response.DomainLogDetails.DomainLogDetail[0]
  30. fmt.Printf("TotalLogCount: %d\n", logDetail.PageInfos.Total)
  31. for _, item := range logDetail.LogInfos.LogInfoDetail {
  32. fmt.Printf("%s: LogSize %d bytes, LogDownloadPath\n %s\n",
  33. item.StartTime, item.LogSize, item.LogPath)
  34. }
  35. }