feat: migrate all remaining modules from rainyun-go-sdk
- domain(24), product(8), rbm(10), rca(21), rgs(38), ros(19), ssl(5), user(10), workorder(11), public remaining 5 - split nested response structs into reusable named types - rgs reuses rcs request/response types - fix source bugs: malformed paths, resp vs &resp, missing bodies - register all 11 services in sdk.New
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
package rca
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 云应用创建App模板请求
|
||||
type RcaCreateAppTemplateRequest struct {
|
||||
CrossVersionUpdate bool `json:"cross_version_update"` // 是否支持跨版本更新
|
||||
Description string `json:"description"` // 描述
|
||||
DisableUpdate bool `json:"disable_update"` // 是否禁用版本更新功能,禁用后已安装应用无法检测到更新
|
||||
Logo string `json:"logo"` // logo(base64),最大50KB,可以不传
|
||||
Name string `json:"name"` // 应用名称(英文标识)
|
||||
ProjectLink string `json:"project_link"` // 应用项目链接
|
||||
Readme string `json:"readme"` // 介绍(markdown)
|
||||
Tags []string `json:"tags"` // 标签,多选,目前支持的tag可以参考现有应用
|
||||
Title string `json:"title"` // 应用标题
|
||||
Website string `json:"website"` // 应用官方网站链接
|
||||
}
|
||||
|
||||
// App模板
|
||||
type AppTemplate struct {
|
||||
ID int `json:"id"` // 模板id
|
||||
UID int `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Logo string `json:"logo"`
|
||||
Type string `json:"type"`
|
||||
Tags []string `json:"tags"`
|
||||
Website string `json:"website"`
|
||||
Github string `json:"github"`
|
||||
CreateDate int `json:"create_date"`
|
||||
Readme string `json:"readme"`
|
||||
Provider string `json:"provider"`
|
||||
CrossVersionUpdate bool `json:"cross_version_update"`
|
||||
Downloads int `json:"downloads"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
ReviewStatus string `json:"review_status"`
|
||||
ReviewComment string `json:"review_comment"`
|
||||
StopReason string `json:"stop_reason"`
|
||||
DisableUpdate bool `json:"disable_update"`
|
||||
}
|
||||
|
||||
type RcaCreateAppTemplateResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data AppTemplate `json:"data"`
|
||||
}
|
||||
|
||||
// App模板版本
|
||||
type AppTemplateVersion struct {
|
||||
ID int `json:"id"`
|
||||
Version string `json:"version"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
}
|
||||
|
||||
type AppTemplateVersionData struct {
|
||||
Data AppTemplate `json:"data"`
|
||||
Versions []AppTemplateVersion `json:"versions"`
|
||||
}
|
||||
|
||||
type CreateAppTemplateVersionResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data AppTemplateVersionData `json:"data"`
|
||||
}
|
||||
|
||||
// 配置文件
|
||||
type AppTemplateConfigMap struct {
|
||||
ContainerPath string `json:"container_path"` // 配置文件存放在容器里面的目录
|
||||
Content string `json:"content"` // 文件内容,最大1MB
|
||||
FileName string `json:"file_name"` // 文件名
|
||||
}
|
||||
|
||||
// 环境变量
|
||||
type AppTemplateEnv struct {
|
||||
Key string `json:"key"` // 键
|
||||
Value string `json:"value"` // 值,允许空白
|
||||
}
|
||||
|
||||
// 安装选项
|
||||
type AppTemplateOption struct {
|
||||
Default string `json:"default"` // 默认值
|
||||
Disabled bool `json:"disabled"` // 是否不允许编辑
|
||||
EnvKey string `json:"env_key"` // 绑定到环境变量的Key
|
||||
Label string `json:"label"` // 标签,告知用户这个选项是干什么用的,例如root用户密码
|
||||
Random bool `json:"random"` // 是否进行随机化生成
|
||||
Required bool `json:"required"` // 是否必选
|
||||
Rule string `json:"rule"` // 规则,可用项目按照前端已实现支持的规则来
|
||||
Type string `json:"type"` // 类型,如:password number等
|
||||
Value string `json:"value"` // 填入值
|
||||
Values []AppTemplateOptionValue `json:"values"` // 选项,type为select时提供给客户选择
|
||||
}
|
||||
|
||||
// 选项可选值
|
||||
type AppTemplateOptionValue struct {
|
||||
Label string `json:"label"` // 提示显示
|
||||
Value string `json:"value"` // 对应值
|
||||
}
|
||||
|
||||
// 资源需求
|
||||
type AppTemplateResourceRequest struct {
|
||||
MinCPU int `json:"min_cpu"` // 如1000,单位是m
|
||||
MinMemory int `json:"min_memory"` // 如4096,单位是Mi
|
||||
}
|
||||
|
||||
// 脚本钩子
|
||||
type AppTemplateScripts struct {
|
||||
Install string `json:"install"` // install(安装应用的时候执行,可以用于下载特定的持久化文件,可以指定运行环境,在底层这个是用initContainer来实现
|
||||
InstallImage string `json:"install_image"` // 执行安装脚本所使用的容器镜像,其他阶段会使用运行时镜像
|
||||
PostStart string `json:"post_start"` // poststart(容器创建后立即执行)
|
||||
PreStop string `json:"pre_stop"` // prestop(终止前运行)
|
||||
}
|
||||
|
||||
// 服务
|
||||
type AppTemplateService struct {
|
||||
ExternalPort string `json:"external_port"` // 外部端口,之所以是string,因为支持以变量形式传入
|
||||
InternalPort string `json:"internal_port"` // 内部端口,对应AppPort,之所以是string,因为支持以变量形式传入
|
||||
Label string `json:"label"` // 标签,可以是中文
|
||||
Name string `json:"name"` // 服务名称
|
||||
Protocol string `json:"protocol"` // 协议
|
||||
Type string `json:"type"` // 类型,可以是internal或external,对应clusterIP或者lb
|
||||
}
|
||||
|
||||
// 文件目录挂载
|
||||
type AppTemplateVolumeMount struct {
|
||||
MountContentType string `json:"mount_content_type"` // 挂载类型,文件file或目录dir
|
||||
MountPath string `json:"mount_path"` // 容器内路径
|
||||
Name string `json:"name"` // 挂载描述
|
||||
PreContent string `json:"pre_content"` // file类型专用,以base64存储的预先准备二进制数据,这个是用于一些小型二进制文件例如.db或者如/etc/localtime等的预先准备,模拟在docker中如"./data/cloudreve.db:/cloudreve/cloudreve.db"或/etc/timezone:/etc/timezone:ro
|
||||
SubPath string `json:"sub_path"` // Project卷内路径,不能以.或者/开头
|
||||
}
|
||||
|
||||
// 创建App模板版本请求
|
||||
//
|
||||
// 我尝试创建了一个函数用于将docker compose文件转换成这种格式,但在编写了近1000行代码后,我成功的放弃了这个想法
|
||||
// :(
|
||||
type CreateAppTemplateVersionRequest struct {
|
||||
Args []string `json:"args"` // 运行参数
|
||||
Command []string `json:"command"` // 运行命令
|
||||
ConfigMaps []AppTemplateConfigMap `json:"config_maps"`
|
||||
Env []AppTemplateEnv `json:"env"` // 环境变量
|
||||
Image string `json:"image"` // 容器镜像,如nginx:1.21.0
|
||||
Options []AppTemplateOption `json:"options"`
|
||||
ReleaseID int `json:"release_id"` // 更新用release ID
|
||||
ResourceRequest AppTemplateResourceRequest `json:"resource_request"` // 资源需求
|
||||
Scripts AppTemplateScripts `json:"scripts"` // 脚本钩子
|
||||
Services []AppTemplateService `json:"services"`
|
||||
Version string `json:"version"` // 版本号,如1.21.0
|
||||
VolumeMounts []AppTemplateVolumeMount `json:"volume_mounts"` // 文件目录,如data:/var/lib/mysql
|
||||
}
|
||||
|
||||
// 云应用创建App模板
|
||||
func (s *RcaService) CreateRcaAppTemplate(req *RcaCreateAppTemplateRequest) (*RcaCreateAppTemplateResponse, error) {
|
||||
path := "/product/rca/appstore/"
|
||||
|
||||
var resp RcaCreateAppTemplateResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 创建App模板版本
|
||||
//
|
||||
// id: APP模板ID
|
||||
func (s *RcaService) CreateRcaAppTemplateVersion(id int, req *CreateAppTemplateVersionRequest) (*CreateAppTemplateVersionResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/appstore/%d/release", id)
|
||||
|
||||
var resp CreateAppTemplateVersionResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package rca
|
||||
|
||||
import "github.com/XingfenD/rainyun_api_go_sdk/apis"
|
||||
|
||||
type RcaService struct {
|
||||
client *apis.RyClient
|
||||
}
|
||||
|
||||
func NewRcaService(c *apis.RyClient) *RcaService {
|
||||
return &RcaService{client: c}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
package rca
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 云应用区域信息
|
||||
type PriceInfo struct {
|
||||
Cpu float64 `json:"cpu"`
|
||||
Memory float64 `json:"memory"`
|
||||
Ipv4 float64 `json:"ipv4"`
|
||||
Traffic float64 `json:"traffic"`
|
||||
Disk float64 `json:"disk"`
|
||||
}
|
||||
|
||||
type RcaRegion struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ChineseName string `json:"chinese_name"`
|
||||
WebsiteServiceDomain string `json:"website_service_domain"`
|
||||
SftpServiceDomain string `json:"sftp_service_domain"`
|
||||
PublicServiceDomain string `json:"public_service_domain"`
|
||||
PriceInfo PriceInfo `json:"price_info"`
|
||||
}
|
||||
|
||||
type GetRcaRegionInfoResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data []RcaRegion `json:"data"`
|
||||
}
|
||||
|
||||
// 开通云应用产品请求
|
||||
type ActivateRcaRequest struct {
|
||||
RegionID int `json:"region_id"`
|
||||
}
|
||||
|
||||
// 创建云应用项目请求
|
||||
type CreateRcaProjectRequest struct {
|
||||
ChargeType string `json:"charge_type"` // 计费类型: 动态计费: elastic
|
||||
CPULimit int `json:"cpu_limit"` // (仅限package模式)CPU限制(毫核),1核心=1000,0.1核=100
|
||||
DiskSize int `json:"disk_size"` // 磁盘大小(GiB)
|
||||
Ipv4Count int `json:"ipv4_count"` // 要添加的IPv4地址数量
|
||||
Ipv6Count int `json:"ipv6_count"` // 要添加的IPv6地址数量
|
||||
MemoryLimit int `json:"memory_limit"` // (仅限package模式)内存限制(MiB)
|
||||
Name string `json:"name"` // 名称
|
||||
RegionID int `json:"region_id"` // 部署区域
|
||||
}
|
||||
|
||||
// 云应用节点信息
|
||||
type RcaNode struct {
|
||||
UUID string `json:"UUID"`
|
||||
AuthKey string `json:"AuthKey"`
|
||||
Region string `json:"Region"`
|
||||
IPRegion string `json:"IpRegion"`
|
||||
Machine string `json:"Machine"`
|
||||
Product string `json:"Product"`
|
||||
Subtype string `json:"Subtype"`
|
||||
ChineseName string `json:"ChineseName"`
|
||||
PhysicalNode string `json:"PhysicalNode"`
|
||||
Config string `json:"Config"`
|
||||
Stock any `json:"Stock"`
|
||||
StatusData string `json:"StatusData"`
|
||||
ShowMonitorData string `json:"ShowMonitorData"`
|
||||
UpdateTime string `json:"UpdateTime"`
|
||||
GitRepositoryName string `json:"GitRepositoryName"`
|
||||
CertifyRequired bool `json:"CertifyRequired"`
|
||||
IsDisableBackup bool `json:"IsDisableBackup"`
|
||||
IsHidden bool `json:"IsHidden"`
|
||||
NodeName string `json:"NodeName"`
|
||||
}
|
||||
|
||||
type RcaResourceLimits struct {
|
||||
MaxCPU int `json:"max_cpu"`
|
||||
MaxMemory int `json:"max_memory"`
|
||||
}
|
||||
|
||||
// 云应用项目资源使用情况
|
||||
type RcaProjectUsageData struct {
|
||||
CPU int `json:"cpu"`
|
||||
Memory int `json:"memory"`
|
||||
NetOut int `json:"net_out"`
|
||||
NetIn int `json:"net_in"`
|
||||
DiskUsage int `json:"disk_usage"`
|
||||
TrafficToday int `json:"traffic_today"`
|
||||
Status string `json:"status"`
|
||||
StatusReason string `json:"status_reason"`
|
||||
AllocatedCPU int `json:"allocated_cpu"`
|
||||
AllocatedMemory int `json:"allocated_memory"`
|
||||
AppCount int `json:"app_count"`
|
||||
WebsiteCount int `json:"website_count"`
|
||||
DatabaseCount int `json:"database_count"`
|
||||
Ipv4Count int `json:"ipv4_count"`
|
||||
HealthyPods int `json:"healthy_pods"`
|
||||
UnhealthyPods int `json:"unhealthy_pods"`
|
||||
}
|
||||
|
||||
// 备份目标
|
||||
type RcaBackupTarget struct {
|
||||
Type string `json:"type"` // 目标类型,支持项目本地备份或者远程S3存储(local/s3)
|
||||
S3Endpoint string `json:"s3_endpoint"` // S3的端点(仅支持Virtual Host,不支持Path-Style模式)
|
||||
S3Bucket string `json:"s3_bucket"` // S3存储桶名
|
||||
S3AccessKey string `json:"s3_access_key"` // S3的AK
|
||||
S3SecretKey string `json:"s3_secret_key"` // S3的SK
|
||||
S3BackupDirectory string `json:"s3_backup_directory"` // s3备份存储的目录
|
||||
}
|
||||
|
||||
// 云应用项目
|
||||
type RcaProject struct {
|
||||
ID int `json:"ID"`
|
||||
UID int `json:"UID"`
|
||||
PlanID int `json:"PlanID"`
|
||||
CreateDate int `json:"CreateDate"` // 创建时间
|
||||
NodeUUID string `json:"NodeUUID"`
|
||||
Node RcaNode `json:"Node"`
|
||||
Status string `json:"Status"`
|
||||
StopReason string `json:"StopReason"`
|
||||
RewardPointsToBeCollect int `json:"RewardPointsToBeCollect"`
|
||||
Tag string `json:"Tag"`
|
||||
ExpDate int `json:"ExpDate"`
|
||||
ExpireNotice int `json:"ExpireNotice"`
|
||||
AutoRenew bool `json:"AutoRenew"`
|
||||
UnsubscribeAble bool `json:"UnsubscribeAble"`
|
||||
Try bool `json:"Try"`
|
||||
Name string `json:"name"`
|
||||
RegionID int `json:"region_id"`
|
||||
Region *RcaRegion `json:"region"`
|
||||
Namespace string `json:"namespace"`
|
||||
APIToken string `json:"APIToken"`
|
||||
ResourceLimits RcaResourceLimits `json:"resource_limits"`
|
||||
UsageData RcaProjectUsageData `json:"usage_data"`
|
||||
VolumeSize int `json:"volume_size"`
|
||||
ChargeType string `json:"charge_type"` // 计费类型: elastic
|
||||
HourlyPrice float64 `json:"hourly_price"` // 小时价格
|
||||
NextChargeTime int `json:"next_charge_time"`
|
||||
BackupTarget RcaBackupTarget `json:"backup_target"` // 备份目标
|
||||
SftpSetting any `json:"sftp_setting"`
|
||||
IdleAlarmFlag bool `json:"idle_alarm_flag"`
|
||||
PaymentDueEnd int `json:"payment_due_end"`
|
||||
}
|
||||
|
||||
type CreateRcaProjectResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RcaProject `json:"data"`
|
||||
}
|
||||
|
||||
type RcaProjectListData struct {
|
||||
TotalRecords int `json:"TotalRecords"`
|
||||
Records []RcaProject `json:"Records"`
|
||||
}
|
||||
|
||||
type GetRcaProjectListResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RcaProjectListData `json:"data"`
|
||||
}
|
||||
|
||||
// 云应用项目的指标信息,示例如下:
|
||||
type RcaProjectMetricsData struct {
|
||||
Columns []string `json:"Columns"`
|
||||
Values [][]float64 `json:"Values"`
|
||||
}
|
||||
|
||||
type GetRcaProjectMetricsResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RcaProjectMetricsData `json:"data"`
|
||||
}
|
||||
|
||||
type RcaProjectDetailData struct {
|
||||
Data RcaProject `json:"Data"`
|
||||
}
|
||||
|
||||
type GetRcaProjectDetailResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RcaProjectDetailData `json:"data"`
|
||||
}
|
||||
|
||||
// 云应用获取区域信息
|
||||
func (s *RcaService) GetRcaRegionInfo() (*GetRcaRegionInfoResponse, error) {
|
||||
path := "/product/rca/region"
|
||||
|
||||
var resp GetRcaRegionInfoResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 开通云应用产品
|
||||
//
|
||||
// regionID: 地域ID
|
||||
func (s *RcaService) ActivateRca(regionID int) (*common.BasicOperationResponse, error) {
|
||||
path := "/product/rca/activate"
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, ActivateRcaRequest{RegionID: regionID}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 创建云应用项目
|
||||
func (s *RcaService) CreateRcaProject(req *CreateRcaProjectRequest) (*CreateRcaProjectResponse, error) {
|
||||
path := "/product/rca/project/"
|
||||
|
||||
var resp CreateRcaProjectResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用列出项目
|
||||
//
|
||||
// options: 查询参数 可以用 EncodingStandardQueryParameters 获取.
|
||||
func (s *RcaService) ListRcaProjects(options string) (*GetRcaProjectListResponse, error) {
|
||||
path := "/product/rca/project/"
|
||||
querys := map[string]string{"no_metrics": "false", "options": options} // no_metrics 含义不明
|
||||
|
||||
var resp GetRcaProjectListResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 销毁云应用项目
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) DestroyRcaProject(id int) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_DELETE, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取Rca项目的指标信息
|
||||
//
|
||||
// id: RCA项目ID
|
||||
//
|
||||
// starttime: 开始时间(timestamp)
|
||||
//
|
||||
// endtime: 结束时间(timestamp)
|
||||
func (s *RcaService) GetRcaProjectMetrics(id int, startTime int, endTime int) (*GetRcaProjectMetricsResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/metrics?start_time=%d&end_time=%d", id, startTime, endTime)
|
||||
|
||||
var resp GetRcaProjectMetricsResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 获取云应用项目详情
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) GetRcaProjectDetail(id int) (*GetRcaProjectDetailResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/", id)
|
||||
|
||||
var resp GetRcaProjectDetailResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package rca
|
||||
|
||||
import (
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 云应用雨点余额使用情况
|
||||
type RcaRaindropUsageData struct {
|
||||
ExpectedRemainDays int `json:"expected_remain_days"` // 预计剩余天数
|
||||
LastMonthUsage float64 `json:"last_month_usage"` // 上月使用量
|
||||
ExpectedNextMonthUsage float64 `json:"expected_next_month_usage"` // 预计下月使用量
|
||||
FreeTrialRemainDays int `json:"free_trial_remain_days"` // 剩余免费试用天数
|
||||
IsBeforeFirstPayment bool `json:"is_before_first_payment"`
|
||||
}
|
||||
|
||||
type GetRcaRaindropUsageResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RcaRaindropUsageData `json:"data"`
|
||||
}
|
||||
|
||||
// 雨点套餐
|
||||
type RaindropPlan struct {
|
||||
ID int `json:"id"`
|
||||
Amount int `json:"amount"`
|
||||
Price int `json:"price"`
|
||||
IsSelling bool `json:"is_selling"`
|
||||
PlanName string `json:"plan_name"`
|
||||
Chinese string `json:"chinese"`
|
||||
}
|
||||
|
||||
type GetRcaRaindropPlansListResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data []RaindropPlan `json:"data"`
|
||||
}
|
||||
|
||||
// 雨点消费明细
|
||||
type RaindropConsumeData struct {
|
||||
BasicPrice float64 `json:"basic_price"`
|
||||
TrafficBytes int `json:"traffic_bytes"`
|
||||
TrafficPrice float64 `json:"traffic_price"`
|
||||
}
|
||||
|
||||
// 雨点消费记录
|
||||
type RaindropConsumeRecord struct {
|
||||
ID int `json:"id"`
|
||||
UID int `json:"uid"`
|
||||
Time int `json:"time"`
|
||||
Type string `json:"type"`
|
||||
ProductID int `json:"product_id"`
|
||||
Amount float64 `json:"amount"`
|
||||
Data RaindropConsumeData `json:"data"`
|
||||
}
|
||||
|
||||
// 雨点消费历史
|
||||
type RaindropConsumeLogData struct {
|
||||
TotalRecords int `json:"TotalRecords"`
|
||||
Records []RaindropConsumeRecord `json:"Records"`
|
||||
}
|
||||
|
||||
type GetRaindropConsumeLogResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data RaindropConsumeLogData `json:"data"`
|
||||
}
|
||||
|
||||
// 云应用购买雨点请求
|
||||
type BuyRaindropRequest struct {
|
||||
PlanID int `json:"plan_id"`
|
||||
WithCouponID int `json:"with_coupon_id"`
|
||||
}
|
||||
|
||||
// 雨点余额
|
||||
type GetRcaRaindropBalanceResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data float64 `json:"data"`
|
||||
}
|
||||
|
||||
// 云应用获取雨点余额使用情况
|
||||
func (s *RcaService) GetRcaRaindropUsage() (*GetRcaRaindropUsageResponse, error) {
|
||||
path := "/product/rca/raindrop/usage"
|
||||
|
||||
var resp GetRcaRaindropUsageResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用获取雨点套餐列表
|
||||
func (s *RcaService) GetRcaRaindropPlansList() (*GetRcaRaindropPlansListResponse, error) {
|
||||
path := "/product/rca/raindrop/plans"
|
||||
|
||||
var resp GetRcaRaindropPlansListResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用获取雨点消费历史
|
||||
//
|
||||
// options: 查询参数 可以用 EncodingStandardQueryParameters 获取.
|
||||
func (s *RcaService) GetRaindropConsumeLog(options string) (*GetRaindropConsumeLogResponse, error) {
|
||||
path := "/product/rca/raindrop/consume_log"
|
||||
querys := map[string]string{"options": options}
|
||||
|
||||
var resp GetRaindropConsumeLogResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, querys, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用购买雨点
|
||||
//
|
||||
// planID: 雨点套餐ID
|
||||
//
|
||||
// couponID: 优惠券ID
|
||||
func (s *RcaService) BuyRaindrop(planID int, couponID int) (*common.BasicOperationResponse, error) {
|
||||
path := "/product/rca/raindrop"
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, BuyRaindropRequest{PlanID: planID, WithCouponID: couponID}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用获取雨点余额
|
||||
func (s *RcaService) GetRcaRaindropBalance() (*GetRcaRaindropBalanceResponse, error) {
|
||||
path := "/product/rca/raindrop"
|
||||
|
||||
var resp GetRcaRaindropBalanceResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package rca
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/apis/common"
|
||||
"github.com/XingfenD/rainyun_api_go_sdk/constant"
|
||||
)
|
||||
|
||||
// 云应用项目设置备份目标请求
|
||||
type SetRcaProjectBackupTargetRequest struct {
|
||||
S3AccessKey string `json:"s3_access_key"` // S3的AK
|
||||
S3BackupDirectory string `json:"s3_backup_directory"` // s3备份存储的目录
|
||||
S3Bucket string `json:"s3_bucket"` // S3存储桶名
|
||||
S3Endpoint string `json:"s3_endpoint"` // S3的端点(仅支持Virtual Host,不支持Path-Style模式)
|
||||
S3SecretKey string `json:"s3_secret_key"` // S3的SK
|
||||
TargetType string `json:"target_type"` // 目标类型,支持项目本地备份或者远程S3存储(local/s3)
|
||||
}
|
||||
|
||||
// 云应用项目磁盘扩容请求
|
||||
type RcaProjectDiskExpansionRequest struct {
|
||||
NewDiskSize int `json:"new_disk_size"` // 以GB显示的新项目磁盘大小
|
||||
}
|
||||
|
||||
// 云应用增加IP地址请求
|
||||
type RcaAddsIpAddressRequest struct {
|
||||
Ipv4Count int `json:"ipv4_count"` // 要添加的IPv4地址数量
|
||||
Ipv6Count int `json:"ipv6_count"` // 要添加的IPv6地址数量
|
||||
}
|
||||
|
||||
// 云应用移除IP地址请求
|
||||
type RcaRemoveIPRequest struct {
|
||||
IPID int `json:"ip_id"` // 要删除的IP地址ID
|
||||
}
|
||||
|
||||
// 云应用项目修改SFTP设置请求
|
||||
type RcaProjectSetSftpConfigRequest struct {
|
||||
Password string `json:"password"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
// 云应用IP信息
|
||||
type RcaIP struct {
|
||||
ID int `json:"id"` // ip id
|
||||
Region string `json:"region"` // 地域
|
||||
Type string `json:"type"` // ip类型(IPv4/IPv6)
|
||||
IP string `json:"ip"` // ip地址
|
||||
AddressPool string `json:"address_pool"` // ip池(user-ip-pool)
|
||||
Gateway string `json:"gateway"` // 网关
|
||||
Block string `json:"block"` // CIDR(24)
|
||||
UID int `json:"uid"` // 用户id
|
||||
ProjectID int `json:"project_id"`
|
||||
Info string `json:"info"`
|
||||
AllocatedDate int `json:"allocated_date"` // 分配时间
|
||||
}
|
||||
|
||||
type GetRcaProjectIPsResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data []RcaIP `json:"data"`
|
||||
}
|
||||
|
||||
// 云应用项目设置备份目标
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) SetRcaProjectBackupTarget(id int, req *SetRcaProjectBackupTargetRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/backup_target", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用项目磁盘扩容
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) ExpandRcaProjectDisk(id int, req *RcaProjectDiskExpansionRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/disk_expand", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用增加IP地址
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) AddRcaProjectIP(id int, req *RcaAddsIpAddressRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/eip", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_POST, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用移除IP地址
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) RemoveRcaProjectIP(id int, req *RcaRemoveIPRequest) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/eip", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_DELETE, path, nil, req, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用项目修改SFTP设置
|
||||
//
|
||||
// id: RCA项目ID
|
||||
//
|
||||
// password: 密码
|
||||
//
|
||||
// username: 用户名
|
||||
func (s *RcaService) SetRcaProjectSFTPConfig(id int, password string, username string) (*common.BasicOperationResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/sftp", id)
|
||||
|
||||
var resp common.BasicOperationResponse
|
||||
err := s.client.Do(constant.HTTPMethod_PATCH, path, nil, RcaProjectSetSftpConfigRequest{Password: password, Username: username}, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
|
||||
// 云应用项目列出IP地址
|
||||
//
|
||||
// id: RCA项目ID
|
||||
func (s *RcaService) ListRcaProjectIPs(id int) (*GetRcaProjectIPsResponse, error) {
|
||||
path := fmt.Sprintf("/product/rca/project/%d/eip", id)
|
||||
|
||||
var resp GetRcaProjectIPsResponse
|
||||
err := s.client.Do(constant.HTTPMethod_GET, path, nil, nil, &resp)
|
||||
return &resp, err
|
||||
}
|
||||
Reference in New Issue
Block a user