阅读本文,您可以获取 Go SDK 用量统计的接口调用示例,实现快速开发。
调用接口前,请先完成 Go SDK 的安装及初始化操作。
本节为您介绍用量统计相关接口的功能和调用示例。
您可以调用 DescribeImageXSummary 接口获取用户的本月资源用量概览。详细的参数说明可参见 DescribeImageXSummary 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXSummary(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXSummaryQuery{} resp, err := instance.DescribeImageXSummary(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXDomainTrafficData 接口获取指定时间段内加速域名网络流量用量。详细的参数说明可参见 DescribeImageXDomainTrafficData 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXDomainTrafficData(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXDomainTrafficDataQuery{} resp, err := instance.DescribeImageXDomainTrafficData(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXDomainBandwidthData 接口获取指定时间段内加速域名网络带宽用量。详细的参数说明可参见 DescribeImageXDomainBandwidthData 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXDomainBandwidthData(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXDomainBandwidthDataQuery{} resp, err := instance.DescribeImageXDomainBandwidthData(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXRequestCntUsage 接口获取指定时间段的请求次数。详细的参数说明可参见 DescribeImageXRequestCntUsage 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXBaseOpUsage(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXBaseOpUsageQuery{} resp, err := instance.DescribeImageXBaseOpUsage(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXBaseOpUsage 接口获取指定时间维度的图像基础处理量。详细的参数说明可参见 DescribeImageXBaseOpUsage 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXBaseOpUsage(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXBaseOpUsageQuery{} resp, err := instance.DescribeImageXBaseOpUsage(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXBucketUsage 接口获取指定时间段的资源占用量。详细的参数说明可参见 DescribeImageXBucketUsage 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXBucketUsage(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXBucketUsageQuery{} resp, err := instance.DescribeImageXBucketUsage(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXCompressUsage 接口获取指定时间段内的图像高效压缩量。详细的参数说明可参见 DescribeImageXCompressUsage 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXCompressUsage(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXCompressUsageQuery{} resp, err := instance.DescribeImageXCompressUsage(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXMultiCompressUsage 接口获取指定时间段内的多文件压缩用量。详细的参数说明可参见 DescribeImageXMultiCompressUsage 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXMultiCompressUsage(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXMultiCompressUsageQuery{} resp, err := instance.DescribeImageXMultiCompressUsage(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }
您可以调用 DescribeImageXBillingRequestCntUsage 接口获取指定时间段内的附加组件通用请求次数
。详细的参数说明可参见 DescribeImageXBillingRequestCntUsage 接口文档。
接口调用示例如下所示。
package imagex_test import ( "context" "encoding/json" "fmt" "testing" "github.com/volcengine/volc-sdk-golang/base" imagex "github.com/volcengine/volc-sdk-golang/service/imagex/v2" ) func Test_DescribeImageXBillingRequestCntUsage(t *testing.T) { instance := imagex.NewInstance() instance.SetCredential(base.Credentials{ AccessKeyID: "ak", SecretAccessKey: "sk", }) param := &imagex.DescribeImageXBillingRequestCntUsageQuery{} resp, err := instance.DescribeImageXBillingRequestCntUsage(context.Background(), param) if err != nil { fmt.Printf("error %v", err) } else { t, _ := json.Marshal(resp) fmt.Printf("success %v", string(t)) } }