client.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package nlp_automl
  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. "reflect"
  18. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  19. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth"
  20. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/provider"
  21. )
  22. // Client is the sdk client struct, each func corresponds to an OpenAPI
  23. type Client struct {
  24. sdk.Client
  25. }
  26. // SetClientProperty Set Property by Reflect
  27. func SetClientProperty(client *Client, propertyName string, propertyValue interface{}) {
  28. v := reflect.ValueOf(client).Elem()
  29. if v.FieldByName(propertyName).IsValid() && v.FieldByName(propertyName).CanSet() {
  30. v.FieldByName(propertyName).Set(reflect.ValueOf(propertyValue))
  31. }
  32. }
  33. // SetEndpointDataToClient Set EndpointMap and ENdpointType
  34. func SetEndpointDataToClient(client *Client) {
  35. SetClientProperty(client, "EndpointMap", GetEndpointMap())
  36. SetClientProperty(client, "EndpointType", GetEndpointType())
  37. }
  38. // NewClient creates a sdk client with environment variables
  39. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  40. func NewClient() (client *Client, err error) {
  41. client = &Client{}
  42. err = client.Init()
  43. SetEndpointDataToClient(client)
  44. return
  45. }
  46. // NewClientWithProvider creates a sdk client with providers
  47. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  48. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  49. func NewClientWithProvider(regionId string, providers ...provider.Provider) (client *Client, err error) {
  50. client = &Client{}
  51. var pc provider.Provider
  52. if len(providers) == 0 {
  53. pc = provider.DefaultChain
  54. } else {
  55. pc = provider.NewProviderChain(providers)
  56. }
  57. err = client.InitWithProviderChain(regionId, pc)
  58. SetEndpointDataToClient(client)
  59. return
  60. }
  61. // NewClientWithOptions creates a sdk client with regionId/sdkConfig/credential
  62. // this is the common api to create a sdk client
  63. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  64. func NewClientWithOptions(regionId string, config *sdk.Config, credential auth.Credential) (client *Client, err error) {
  65. client = &Client{}
  66. err = client.InitWithOptions(regionId, config, credential)
  67. SetEndpointDataToClient(client)
  68. return
  69. }
  70. // NewClientWithAccessKey is a shortcut to create sdk client with accesskey
  71. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  72. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  73. func NewClientWithAccessKey(regionId, accessKeyId, accessKeySecret string) (client *Client, err error) {
  74. client = &Client{}
  75. err = client.InitWithAccessKey(regionId, accessKeyId, accessKeySecret)
  76. SetEndpointDataToClient(client)
  77. return
  78. }
  79. // NewClientWithStsToken is a shortcut to create sdk client with sts token
  80. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  81. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  82. func NewClientWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken string) (client *Client, err error) {
  83. client = &Client{}
  84. err = client.InitWithStsToken(regionId, stsAccessKeyId, stsAccessKeySecret, stsToken)
  85. SetEndpointDataToClient(client)
  86. return
  87. }
  88. // NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn
  89. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  90. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  91. func NewClientWithRamRoleArn(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName string) (client *Client, err error) {
  92. client = &Client{}
  93. err = client.InitWithRamRoleArn(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName)
  94. SetEndpointDataToClient(client)
  95. return
  96. }
  97. // NewClientWithRamRoleArn is a shortcut to create sdk client with ram roleArn and policy
  98. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  99. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  100. func NewClientWithRamRoleArnAndPolicy(regionId string, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy string) (client *Client, err error) {
  101. client = &Client{}
  102. err = client.InitWithRamRoleArnAndPolicy(regionId, accessKeyId, accessKeySecret, roleArn, roleSessionName, policy)
  103. SetEndpointDataToClient(client)
  104. return
  105. }
  106. // NewClientWithEcsRamRole is a shortcut to create sdk client with ecs ram role
  107. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  108. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  109. func NewClientWithEcsRamRole(regionId string, roleName string) (client *Client, err error) {
  110. client = &Client{}
  111. err = client.InitWithEcsRamRole(regionId, roleName)
  112. SetEndpointDataToClient(client)
  113. return
  114. }
  115. // NewClientWithRsaKeyPair is a shortcut to create sdk client with rsa key pair
  116. // usage: https://github.com/aliyun/alibaba-cloud-sdk-go/blob/master/docs/2-Client-EN.md
  117. // Deprecated: Please use github.com/aliyun/alibaba-cloud-sdk-go/services/nlp-automl instead
  118. func NewClientWithRsaKeyPair(regionId string, publicKeyId, privateKey string, sessionExpiration int) (client *Client, err error) {
  119. client = &Client{}
  120. err = client.InitWithRsaKeyPair(regionId, publicKeyId, privateKey, sessionExpiration)
  121. SetEndpointDataToClient(client)
  122. return
  123. }