-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ssl, use go mod and improve http client (#36)
FEATURES: - Add `UpdateSSLBinding`as public api - Add `BindSSL`as public api - Add `CreateSSL`as public api - Add `DeleteSSL`as public api - Add `DescribeSSL`as public api - Add `UnbindSSL`as public api - Add `UpdateSSLBinding`as public api - Add `UpdateSSLBinding`as public api - Add `CheckURedisAllowance` as private api ENHANCEMENTS: - Use `go mod` instead of `dep` - Move query string into http body
- Loading branch information
1 parent
1acb6fc
commit f18d177
Showing
21 changed files
with
1,232 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module github.com/ucloud/ucloud-sdk-go | ||
|
||
require ( | ||
github.com/Sirupsen/logrus v0.8.7 | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/pkg/errors v0.8.0 | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/testify v1.2.2 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
github.com/Sirupsen/logrus v0.8.7 h1:hGa+d4KZNNNDmzAj6vlkeOQsgjrh8zg4EXB81mWoTm4= | ||
github.com/Sirupsen/logrus v0.8.7/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= | ||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ulb | ||
|
||
import ( | ||
"github.com/ucloud/ucloud-sdk-go/ucloud" | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/auth" | ||
) | ||
|
||
// ULBClient is the client of ULB | ||
type ULBClient struct { | ||
client *ucloud.Client | ||
} | ||
|
||
// NewClient will return a instance of ULBClient | ||
func NewClient(config *ucloud.Config, credential *auth.Credential) *ULBClient { | ||
client := ucloud.NewClient(config, credential) | ||
return &ULBClient{ | ||
client: client, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Package ulb include resources of ucloud ulb product | ||
See also | ||
- API: https://docs.ucloud.cn/api/ulb-api/index | ||
- Product: https://www.ucloud.cn/site/product/ulb.html | ||
for detail. | ||
*/ | ||
package ulb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. | ||
//go:generate ucloud-gen-go-api ULB UpdateSSLBinding | ||
|
||
package ulb | ||
|
||
import ( | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/request" | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/response" | ||
) | ||
|
||
// UpdateSSLBindingRequest is request schema for UpdateSSLBinding action | ||
type UpdateSSLBindingRequest struct { | ||
request.CommonBase | ||
|
||
// 所操作ULB实例ID | ||
ULBId *string `required:"true"` | ||
|
||
// 所操作VServer实例ID | ||
VServerId *string `required:"true"` | ||
|
||
// VServer实例绑定的旧的证书 | ||
OldSSLId *string `required:"true"` | ||
|
||
// VServer实例需要绑定的新的证书 | ||
NewSSLId *string `required:"true"` | ||
} | ||
|
||
// UpdateSSLBindingResponse is response schema for UpdateSSLBinding action | ||
type UpdateSSLBindingResponse struct { | ||
response.CommonBase | ||
|
||
// 返回码 | ||
RetCode int | ||
|
||
// 响应名称 | ||
Action string | ||
} | ||
|
||
// NewUpdateSSLBindingRequest will create request of UpdateSSLBinding action. | ||
func (c *ULBClient) NewUpdateSSLBindingRequest() *UpdateSSLBindingRequest { | ||
req := &UpdateSSLBindingRequest{} | ||
|
||
// setup request with client config | ||
c.client.SetupRequest(req) | ||
|
||
// setup retryable with default retry policy (retry for non-create action and common error) | ||
req.SetRetryable(true) | ||
return req | ||
} | ||
|
||
// UpdateSSLBinding - 将VServer绑定的证书更换为另一个证书 | ||
func (c *ULBClient) UpdateSSLBinding(req *UpdateSSLBindingRequest) (*UpdateSSLBindingResponse, error) { | ||
var err error | ||
var res UpdateSSLBindingResponse | ||
|
||
err = c.client.InvokeAction("UpdateSSLBinding", req, &res) | ||
if err != nil { | ||
return &res, err | ||
} | ||
|
||
return &res, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. | ||
//go:generate ucloud-gen-go-api UMem CheckURedisAllowance | ||
|
||
package umem | ||
|
||
import ( | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/request" | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/response" | ||
) | ||
|
||
// CheckURedisAllowanceRequest is request schema for CheckURedisAllowance action | ||
type CheckURedisAllowanceRequest struct { | ||
request.CommonBase | ||
|
||
// 可用区。参见 [可用区列表](../summary/regionlist.html) | ||
Zone *string `required:"true"` | ||
|
||
// 创建实例的容量大小, 单位:GB 目前仅支持1/2/4/8/16/32六种规格 | ||
Size *string `required:"true"` | ||
|
||
// 创建实例的数量,[1-10] | ||
Count *int `required:"true"` | ||
|
||
// | ||
Protocol *string `required:"false"` | ||
|
||
// 是否是跨机房URedis(默认false) | ||
RegionFlag *bool `required:"false"` | ||
|
||
// | ||
SlaveZone *string `required:"false"` | ||
} | ||
|
||
// CheckURedisAllowanceResponse is response schema for CheckURedisAllowance action | ||
type CheckURedisAllowanceResponse struct { | ||
response.CommonBase | ||
|
||
// 可创建的数量 | ||
Count int | ||
} | ||
|
||
// NewCheckURedisAllowanceRequest will create request of CheckURedisAllowance action. | ||
func (c *UMemClient) NewCheckURedisAllowanceRequest() *CheckURedisAllowanceRequest { | ||
req := &CheckURedisAllowanceRequest{} | ||
|
||
// setup request with client config | ||
c.client.SetupRequest(req) | ||
|
||
// setup retryable with default retry policy (retry for non-create action and common error) | ||
req.SetRetryable(true) | ||
return req | ||
} | ||
|
||
// CheckURedisAllowance - 检查主备Redis的资源是否足够创建新实例 | ||
func (c *UMemClient) CheckURedisAllowance(req *CheckURedisAllowanceRequest) (*CheckURedisAllowanceResponse, error) { | ||
var err error | ||
var res CheckURedisAllowanceResponse | ||
|
||
err = c.client.InvokeAction("CheckURedisAllowance", req, &res) | ||
if err != nil { | ||
return &res, err | ||
} | ||
|
||
return &res, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ if [[ -n ${gofmt_files} ]]; then | |
fi | ||
|
||
exit 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors. | ||
//go:generate ucloud-gen-go-api ULB BindSSL | ||
|
||
package ulb | ||
|
||
import ( | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/request" | ||
"github.com/ucloud/ucloud-sdk-go/ucloud/response" | ||
) | ||
|
||
// BindSSLRequest is request schema for BindSSL action | ||
type BindSSLRequest struct { | ||
request.CommonBase | ||
|
||
// 所绑定ULB实例ID | ||
ULBId *string `required:"true"` | ||
|
||
// 所绑定VServer实例ID | ||
VServerId *string `required:"true"` | ||
|
||
// SSL证书的Id | ||
SSLId *string `required:"true"` | ||
} | ||
|
||
// BindSSLResponse is response schema for BindSSL action | ||
type BindSSLResponse struct { | ||
response.CommonBase | ||
} | ||
|
||
// NewBindSSLRequest will create request of BindSSL action. | ||
func (c *ULBClient) NewBindSSLRequest() *BindSSLRequest { | ||
req := &BindSSLRequest{} | ||
|
||
// setup request with client config | ||
c.client.SetupRequest(req) | ||
|
||
// setup retryable with default retry policy (retry for non-create action and common error) | ||
req.SetRetryable(true) | ||
return req | ||
} | ||
|
||
// BindSSL - 将SSL证书绑定到VServer | ||
func (c *ULBClient) BindSSL(req *BindSSLRequest) (*BindSSLResponse, error) { | ||
var err error | ||
var res BindSSLResponse | ||
|
||
err = c.client.InvokeAction("BindSSL", req, &res) | ||
if err != nil { | ||
return &res, err | ||
} | ||
|
||
return &res, nil | ||
} |
Oops, something went wrong.