Skip to content

Commit

Permalink
add allowance and vpc action (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeiminds authored Jan 7, 2019
1 parent cdae33a commit 1acb6fc
Show file tree
Hide file tree
Showing 15 changed files with 505 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func loadConfig() (*ucloud.Config, *auth.Credential) {
}

func main() {
cfg, credentail := loadConfig()
cfg, credential := loadConfig()
uhostClient := uhost.NewClient(cfg, credential)
}
```
Expand Down
6 changes: 3 additions & 3 deletions internal/services/udb/check_udbinstance_allowance.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ type CheckUDBInstanceAllowanceRequest struct {
// 资源申请个数,默认为一个
Count *int `required:"true"`

// UDB实例的部署模式:可选值为:Normal: 普通单点实例,HA: 高可用部署实例
InstanceMode *string `required:"true"`

// SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则需要指定SSD类型
SSDType *string `required:"false"`

// UDB实例的部署模式:可选值为:Normal: 普通单点实例,HA: 高可用部署实例
InstanceMode *string `required:"false"`

// 如果是从库创建核查,需要指定SrcId
SrcId *string `required:"false"`

Expand Down
83 changes: 83 additions & 0 deletions private/services/udb/check_udbinstance_allowance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UDB CheckUDBInstanceAllowance

package udb

import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

// CheckUDBInstanceAllowanceRequest is request schema for CheckUDBInstanceAllowance action
type CheckUDBInstanceAllowanceRequest struct {
request.CommonBase

// 可用区。参见 [可用区列表](../summary/regionlist.html)
Zone *string `required:"true"`

// DB种类,分为SQL和NOSQL,取值分别为sql、nosql、postgresql
ClassType *string `required:"true"`

// 申请资源的内存限制
MemoryLimit *int `required:"true"`

// 申请资源的磁盘空间
DiskSpace *int `required:"true"`

// 是否使用SSD资源,true代表使用,false代表不使用
UseSSD *bool `required:"true"`

// 资源申请个数,默认为一个
Count *int `required:"true"`

// UDB实例的部署模式:可选值为:Normal: 普通单点实例,HA: 高可用部署实例
InstanceMode *string `required:"true"`

// SSD类型,可选值为"SATA"、"PCI-E",如果UseSSD为true ,则需要指定SSD类型
SSDType *string `required:"false"`

// 如果是从库创建核查,需要指定SrcId
SrcId *string `required:"false"`

// 跨可用区备库所在可用区, 参见 [可用区列表](../summary/regionlist.html)
BackupZone *string `required:"false"`

// 专区ID
UDBCId *string `required:"false"`

// 专区里面DB升降级需要原来DB的信息
DBId *string `required:"false"`
}

// CheckUDBInstanceAllowanceResponse is response schema for CheckUDBInstanceAllowance action
type CheckUDBInstanceAllowanceResponse struct {
response.CommonBase

// 资源核查部分成功情况下,成功个数
Count int
}

// NewCheckUDBInstanceAllowanceRequest will create request of CheckUDBInstanceAllowance action.
func (c *UDBClient) NewCheckUDBInstanceAllowanceRequest() *CheckUDBInstanceAllowanceRequest {
req := &CheckUDBInstanceAllowanceRequest{}

// 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
}

// CheckUDBInstanceAllowance - 核查UDB资源余量
func (c *UDBClient) CheckUDBInstanceAllowance(req *CheckUDBInstanceAllowanceRequest) (*CheckUDBInstanceAllowanceResponse, error) {
var err error
var res CheckUDBInstanceAllowanceResponse

err = c.client.InvokeAction("CheckUDBInstanceAllowance", req, &res)
if err != nil {
return &res, err
}

return &res, nil
}
56 changes: 56 additions & 0 deletions private/services/udisk/check_udisk_allowance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UDisk CheckUDiskAllowance

package udisk

import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

// CheckUDiskAllowanceRequest is request schema for CheckUDiskAllowance action
type CheckUDiskAllowanceRequest struct {
request.CommonBase

// 可用区。参见 [可用区列表](../summary/regionlist.html)
Zone *string `required:"true"`

// 购买UDisk大小,单位:GB,范围[1~2000], 权限位控制可达8T,若需要请申请开通相关权限。
Size *int `required:"true"`

// 资源申请个数,默认为一个
Count *int `required:"false"`
}

// CheckUDiskAllowanceResponse is response schema for CheckUDiskAllowance action
type CheckUDiskAllowanceResponse struct {
response.CommonBase

// 资源核查部分成功情况下,成功个数
Count int
}

// NewCheckUDiskAllowanceRequest will create request of CheckUDiskAllowance action.
func (c *UDiskClient) NewCheckUDiskAllowanceRequest() *CheckUDiskAllowanceRequest {
req := &CheckUDiskAllowanceRequest{}

// 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
}

// CheckUDiskAllowance - 检查UDisk资源余量
func (c *UDiskClient) CheckUDiskAllowance(req *CheckUDiskAllowanceRequest) (*CheckUDiskAllowanceResponse, error) {
var err error
var res CheckUDiskAllowanceResponse

err = c.client.InvokeAction("CheckUDiskAllowance", req, &res)
if err != nil {
return &res, err
}

return &res, nil
}
59 changes: 59 additions & 0 deletions private/services/umem/check_umem_space_allowance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//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 CheckUMemSpaceAllowance

package umem

import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

// CheckUMemSpaceAllowanceRequest is request schema for CheckUMemSpaceAllowance action
type CheckUMemSpaceAllowanceRequest struct {
request.CommonBase

// 可用区。参见 [可用区列表](../summary/regionlist.html)
Zone *string `required:"true"`

// 创建实例的容量大小;分布式memcache最低8G, 分布式redis最低16G,两者最高都是1000G
Size *int `required:"true"`

// 创建实例的数量,[1-10]
Count *int `required:"true"`

// redis memcache
Protocol *string `required:"false"`
}

// CheckUMemSpaceAllowanceResponse is response schema for CheckUMemSpaceAllowance action
type CheckUMemSpaceAllowanceResponse struct {
response.CommonBase

// 可创建的数量
Count int
}

// NewCheckUMemSpaceAllowanceRequest will create request of CheckUMemSpaceAllowance action.
func (c *UMemClient) NewCheckUMemSpaceAllowanceRequest() *CheckUMemSpaceAllowanceRequest {
req := &CheckUMemSpaceAllowanceRequest{}

// 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
}

// CheckUMemSpaceAllowance - 检查分布式UMem剩余资源,包括分布式redis,分布式memcache
func (c *UMemClient) CheckUMemSpaceAllowance(req *CheckUMemSpaceAllowanceRequest) (*CheckUMemSpaceAllowanceResponse, error) {
var err error
var res CheckUMemSpaceAllowanceResponse

err = c.client.InvokeAction("CheckUMemSpaceAllowance", req, &res)
if err != nil {
return &res, err
}

return &res, nil
}
56 changes: 56 additions & 0 deletions private/services/umem/check_umemcache_allowance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//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 CheckUMemcacheAllowance

package umem

import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

// CheckUMemcacheAllowanceRequest is request schema for CheckUMemcacheAllowance action
type CheckUMemcacheAllowanceRequest struct {
request.CommonBase

// 可用区。参见 [可用区列表](../summary/regionlist.html)
Zone *string `required:"true"`

// 创建实例的容量大小, 单位:GB 目前仅支持1/2/4/8/16五种规格
Size *int `required:"true"`

// 创建实例的数量,[1-10]
Count *int `required:"true"`
}

// CheckUMemcacheAllowanceResponse is response schema for CheckUMemcacheAllowance action
type CheckUMemcacheAllowanceResponse struct {
response.CommonBase

// 可创建的数量
Count int
}

// NewCheckUMemcacheAllowanceRequest will create request of CheckUMemcacheAllowance action.
func (c *UMemClient) NewCheckUMemcacheAllowanceRequest() *CheckUMemcacheAllowanceRequest {
req := &CheckUMemcacheAllowanceRequest{}

// 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
}

// CheckUMemcacheAllowance - 检查UMemcache剩余资源
func (c *UMemClient) CheckUMemcacheAllowance(req *CheckUMemcacheAllowanceRequest) (*CheckUMemcacheAllowanceResponse, error) {
var err error
var res CheckUMemcacheAllowanceResponse

err = c.client.InvokeAction("CheckUMemcacheAllowance", req, &res)
if err != nil {
return &res, err
}

return &res, nil
}
19 changes: 19 additions & 0 deletions private/services/umon/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package umon

import (
"github.com/ucloud/ucloud-sdk-go/ucloud"
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
)

// UMonClient is the client of UMon
type UMonClient struct {
client *ucloud.Client
}

// NewClient will return a instance of UMonClient
func NewClient(config *ucloud.Config, credential *auth.Credential) *UMonClient {
client := ucloud.NewClient(config, credential)
return &UMonClient{
client: client,
}
}
50 changes: 50 additions & 0 deletions private/services/umon/describe_resource_metric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//Code is generated by ucloud code generator, don't modify it by hand, it will cause undefined behaviors.
//go:generate ucloud-gen-go-api UMon DescribeResourceMetric

package umon

import (
"github.com/ucloud/ucloud-sdk-go/ucloud/request"
"github.com/ucloud/ucloud-sdk-go/ucloud/response"
)

// DescribeResourceMetricRequest is request schema for DescribeResourceMetric action
type DescribeResourceMetricRequest struct {
request.CommonBase

// 资源类型
ResourceType *string `required:"true"`
}

// DescribeResourceMetricResponse is response schema for DescribeResourceMetric action
type DescribeResourceMetricResponse struct {
response.CommonBase

// 指标信息集合
DataSet []MetricInfo
}

// NewDescribeResourceMetricRequest will create request of DescribeResourceMetric action.
func (c *UMonClient) NewDescribeResourceMetricRequest() *DescribeResourceMetricRequest {
req := &DescribeResourceMetricRequest{}

// 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
}

// DescribeResourceMetric - 获取资源支持监控指标信息
func (c *UMonClient) DescribeResourceMetric(req *DescribeResourceMetricRequest) (*DescribeResourceMetricResponse, error) {
var err error
var res DescribeResourceMetricResponse

err = c.client.InvokeAction("DescribeResourceMetric", req, &res)
if err != nil {
return &res, err
}

return &res, nil
}
Loading

0 comments on commit 1acb6fc

Please sign in to comment.