Open zerophpchina opened 1 year ago
import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" "github.com/aliyun/alibaba-cloud-sdk-go/services/cms" "os"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" ) func main() { config := sdk.NewConfig()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set. credential := credentials.NewAccessKeyCredential(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")) / use STS Token credential := credentials.NewStsTokenCredential(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), os.Getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) / client, err := cms.NewClientWithOptions("cn-hangzhou", config, credential) if err != nil { panic(err) }
request := cms.CreateCursorRequest()
request.Scheme = "https"
request.Namespace = "acs_rds_dashboard" request.Metric = "ConnectionUsage" request.Period = requests.NewInteger(60) request.StartTime = "1641627000000" request.EndTime = "1641645000000"
response, err := client.Cursor(request) if err != nil { fmt.Print(err.Error()) } fmt.Printf("response is %#v\n", response) }
import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/sdk" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" "github.com/aliyun/alibaba-cloud-sdk-go/services/cms" "os"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" ) func main() { config := sdk.NewConfig()
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set. credential := credentials.NewAccessKeyCredential(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")) / use STS Token credential := credentials.NewStsTokenCredential(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"), os.Getenv("ALIBABA_CLOUD_SECURITY_TOKEN")) / client, err := cms.NewClientWithOptions("cn-hangzhou", config, credential) if err != nil { panic(err) }
request := cms.CreateCursorRequest()
request.Scheme = "https"
request.Namespace = "acs_rds_dashboard" request.Metric = "ConnectionUsage" request.Period = requests.NewInteger(60) request.StartTime = "1641627000000" request.EndTime = "1641645000000"
response, err := client.Cursor(request) if err != nil { fmt.Print(err.Error()) } fmt.Printf("response is %#v\n", response) }