client.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package scdn
  2. //Licensed under the Apache License, Version 2.0 (the "License");
  3. //you may not use this file except in compliance with the License.
  4. //You may obtain a copy of the License at
  5. //
  6. //http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. //Unless required by applicable law or agreed to in writing, software
  9. //distributed under the License is distributed on an "AS IS" BASIS,
  10. //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. //See the License for the specific language governing permissions and
  12. //limitations under the License.
  13. //
  14. // Code generated by Alibaba Cloud SDK Code Generator.
  15. // Changes may cause incorrect behavior and will be lost if the code is regenerated.
  16. import (
  17. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  18. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
  19. )
  20. // Client is the sdk client struct, each func corresponds to an OpenAPI
  21. type Client struct {
  22. sdk.Client
  23. }
  24. // NewClient creates a sdk client with environment variables
  25. func NewClient() (client *Client, err error) {
  26. client = &Client{}
  27. err = client.Init()
  28. return
  29. }
  30. // NewClientWithOptions creates a sdk client with regionId/sdkConfig/credential
  31. // this is the common api to create a sdk client
  32. func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
  33. client = &Client{}
  34. err = client.InitWithOptions(regionId, config, credential)
  35. return
  36. }
  37. // NewClientWithAccessKey is a shortcut to create sdk client with accesskey
  38. // usage: https://help.aliyun.com/document_detail/66217.html
  39. func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
  40. client = &Client{}
  41. err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
  42. return
  43. }
  44. // NewClientWithStsToken is a shortcut to create sdk client with sts token
  45. // usage: https://help.aliyun.com/document_detail/66222.html
  46. func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
  47. client = &Client{}
  48. err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
  49. return
  50. }
  51. // NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn
  52. // usage: https://help.aliyun.com/document_detail/66222.html
  53. func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
  54. client = &Client{}
  55. err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
  56. return
  57. }
  58. // NewClientWithEcsRamRole is a shortcut to create sdk client with ecs ram role
  59. // usage: https://help.aliyun.com/document_detail/66223.html
  60. func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
  61. client = &Client{}
  62. err = client.InitWithEcsRamRole(regionId, roleName)
  63. return
  64. }
  65. // NewClientWithRsaKeyPair is a shortcut to create sdk client with rsa key pair
  66. // attention: rsa key pair auth is only Japan regions available
  67. func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
  68. client = &Client{}
  69. err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
  70. return
  71. }