-
Notifications
You must be signed in to change notification settings - Fork 231
/
describe_regions.go
45 lines (39 loc) · 1.29 KB
/
describe_regions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package sample
import (
"fmt"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
//DescribeRegionsSample shows how to get or list describe regions
func DescribeRegionsSample() {
// Create archive bucket
client, err := oss.New(endpoint, accessID, accessKey)
if err != nil {
HandleError(err)
}
// Get describe regions
regionEndpoint := "oss-cn-hangzhou"
list, err := client.DescribeRegions(oss.AddParam("regions", regionEndpoint))
if err != nil {
HandleError(err)
}
for _, region := range list.Regions {
fmt.Printf("Region:%s\n", region.Region)
fmt.Printf("Region Internet Endpoint:%s\n", region.InternetEndpoint)
fmt.Printf("Region Internal Endpoint:%s\n", region.InternalEndpoint)
fmt.Printf("Region Accelerate Endpoint:%s\n", region.AccelerateEndpoint)
}
fmt.Println("Get Describe Regions Success")
// List describe regions
list, err = client.DescribeRegions()
if err != nil {
HandleError(err)
}
for _, region := range list.Regions {
fmt.Printf("Region:%s\n", region.Region)
fmt.Printf("Region Internet Endpoint:%s\n", region.InternetEndpoint)
fmt.Printf("Region Internal Endpoint:%s\n", region.InternalEndpoint)
fmt.Printf("Region Accelerate Endpoint:%s\n", region.AccelerateEndpoint)
}
fmt.Println("List Describe Regions Success")
fmt.Println("DescribeRegionsSample completed")
}