| 1 |
package pvtz |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
|
| 6 |
"github.com/denverdino/aliyungo/common" |
| 7 |
) |
| 8 |
|
| 9 |
|
| 10 |
const DefaultWaitForInterval = 5 |
| 11 |
|
| 12 |
|
| 13 |
const DefaultTimeout = 60 |
| 14 |
|
| 15 |
type Client struct { |
| 16 |
common.Client |
| 17 |
} |
| 18 |
|
| 19 |
const ( |
| 20 |
|
| 21 |
PVTZDefaultEndpoint = "https://pvtz.aliyuncs.com" |
| 22 |
PVTZServiceCode = "pvtz" |
| 23 |
PVTZAPIVersion = "2018-01-01" |
| 24 |
) |
| 25 |
|
| 26 |
|
| 27 |
func NewClient(accessKeyId, accessKeySecret string) *Client { |
| 28 |
endpoint := os.Getenv("PVTZ_ENDPOINT") |
| 29 |
if endpoint == "" { |
| 30 |
endpoint = PVTZDefaultEndpoint |
| 31 |
} |
| 32 |
return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret) |
| 33 |
} |
| 34 |
|
| 35 |
func NewClientWithRegion(endpoint string, accessKeyId string, accessKeySecret string, regionID common.Region) *Client { |
| 36 |
client := &Client{} |
| 37 |
client.NewInit(endpoint, PVTZAPIVersion, accessKeyId, accessKeySecret, PVTZServiceCode, regionID) |
| 38 |
return client |
| 39 |
} |
| 40 |
|
| 41 |
func NewClientWithEndpoint(endpoint string, accessKeyId string, accessKeySecret string) *Client { |
| 42 |
client := &Client{} |
| 43 |
client.Init(endpoint, PVTZAPIVersion, accessKeyId, accessKeySecret) |
| 44 |
return client |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
func NewPVTZClient(accessKeyId, accessKeySecret string, regionID common.Region) *Client { |
| 51 |
return NewPVTZClientWithSecurityToken(accessKeyId, accessKeySecret, "", regionID) |
| 52 |
} |
| 53 |
|
| 54 |
func NewPVTZClientWithSecurityToken(accessKeyId string, accessKeySecret string, securityToken string, regionID common.Region) *Client { |
| 55 |
endpoint := os.Getenv("PVTZ_ENDPOINT") |
| 56 |
if endpoint == "" { |
| 57 |
endpoint = PVTZDefaultEndpoint |
| 58 |
} |
| 59 |
|
| 60 |
return NewPVTZClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, securityToken, regionID) |
| 61 |
} |
| 62 |
|
| 63 |
func NewPVTZClientWithEndpoint(endpoint string, accessKeyId string, accessKeySecret string, regionID common.Region) *Client { |
| 64 |
return NewPVTZClientWithEndpointAndSecurityToken(endpoint, accessKeyId, accessKeySecret, "", regionID) |
| 65 |
} |
| 66 |
|
| 67 |
func NewPVTZClientWithEndpointAndSecurityToken(endpoint string, accessKeyId string, accessKeySecret string, securityToken string, regionID common.Region) *Client { |
| 68 |
client := &Client{} |
| 69 |
client.WithEndpoint(endpoint). |
| 70 |
WithVersion(PVTZAPIVersion). |
| 71 |
WithAccessKeyId(accessKeyId). |
| 72 |
WithAccessKeySecret(accessKeySecret). |
| 73 |
WithSecurityToken(securityToken). |
| 74 |
WithServiceCode(PVTZServiceCode). |
| 75 |
WithRegionID(regionID). |
| 76 |
InitClient() |
| 77 |
return client |
| 78 |
} |