From ea1c2dd0ca57834672adba3011cd868de2f5e532 Mon Sep 17 00:00:00 2001 From: Lance52259 Date: Thu, 15 Apr 2021 19:52:27 +0800 Subject: [PATCH] append the sdk content of bcs --- openstack/bcs/v2/blockchains/requests.go | 10 +-- openstack/bcs/v2/blockchains/results.go | 92 +++++++++++++++++------- openstack/bcs/v2/blockchains/urls.go | 24 ++----- 3 files changed, 80 insertions(+), 46 deletions(-) diff --git a/openstack/bcs/v2/blockchains/requests.go b/openstack/bcs/v2/blockchains/requests.go index d5c66703..c5af5595 100644 --- a/openstack/bcs/v2/blockchains/requests.go +++ b/openstack/bcs/v2/blockchains/requests.go @@ -131,7 +131,7 @@ func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateRe return } - _, r.Err = client.Post(createURL(client), b, &r.Body, &golangsdk.RequestOpts{ + _, r.Err = client.Post(rootURL(client), b, &r.Body, &golangsdk.RequestOpts{ OkCodes: []int{200, 202}, }) return @@ -158,7 +158,7 @@ func (opts DeleteOpts) ToInstanceDeleteQuery() (string, error) { //Delete is a method to delete an existing bcs instance func Delete(client *golangsdk.ServiceClient, opts DeleteOptsBuilder, id string) (r DeleteResult) { - url := deleteURL(client, id) + url := resourceURL(client, id) if opts != nil { query, err := opts.ToInstanceDeleteQuery() if err != nil { @@ -177,7 +177,7 @@ func Delete(client *golangsdk.ServiceClient, opts DeleteOptsBuilder, id string) //Get is a method to obtain the detailed information of an existing bcs instance func Get(client *golangsdk.ServiceClient, id string) (r ShowResult) { - _, r.Err = client.Get(getURL(client, id), &r.Body, nil) + _, r.Err = client.Get(resourceURL(client, id), &r.Body, nil) return } @@ -189,7 +189,7 @@ func GetStatus(client *golangsdk.ServiceClient, id string) (r StatusResult) { //List is a method to obtain the detailed information list of all existing bcs instance func List(client *golangsdk.ServiceClient) (r ListResult) { - _, r.Err = client.Get(listURL(client), &r.Body, nil) + _, r.Err = client.Get(rootURL(client), &r.Body, nil) return } @@ -232,7 +232,7 @@ func Update(client *golangsdk.ServiceClient, opts UpdateOptsBuilder, id string) return } - _, r.Err = client.Post(updateURL(client, id), b, nil, &golangsdk.RequestOpts{ + _, r.Err = client.Post(resourceURL(client, id), b, nil, &golangsdk.RequestOpts{ OkCodes: []int{200, 202}, }) return diff --git a/openstack/bcs/v2/blockchains/results.go b/openstack/bcs/v2/blockchains/results.go index 8297bc2c..71a12916 100644 --- a/openstack/bcs/v2/blockchains/results.go +++ b/openstack/bcs/v2/blockchains/results.go @@ -54,30 +54,45 @@ type BCSInstance struct { } type Basic struct { - ID string `json:"id"` - Name string `json:"name"` - Version string `json:"version"` - VersionType int `json:"version_type"` - ServiceType string `json:"service_type"` - PurchaseType string `json:"purchase_type"` - SignAlgorithm string `json:"sign_algorithm"` - Consensus string `json:"consensus"` - ChargingMode int `json:"charging_mode"` - DatabaseType string `json:"database_type"` - ClusterID string `json:"cluster_id"` - ClusterName string `json:"cluster_name"` - ClusterType string `json:"cluster_type"` - ClusterAvailabilityZone string `json:"cluster_az"` - CreatedTime string `json:"created_time"` - DeployType string `json:"deploy_type"` - IsCrossRegion bool `json:"is_cross_region"` - IsSupportRollback bool `json:"is_support_rollback"` - IsSupportRestful bool `json:"is_support_restful"` - IsOldService bool `json:"is_old_service"` - OldServiceVersion string `json:"old_service_version"` - AgentPortalAddress []string `json:"agent_portal_addrs"` - Status string `json:"status"` - ProcessStatus string `json:"process_status"` + ID string `json:"id"` + Name string `json:"name"` + KernelType string `json:"kernel_type"` + Version string `json:"version"` + VersionType int `json:"version_type"` + VolumeType string `json:"volume_type"` + ServiceType string `json:"service_type"` + PurchaseType string `json:"purchase_type"` + SignAlgorithm string `json:"sign_algorithm"` + Consensus string `json:"consensus"` + ChargingMode int `json:"charging_mode"` + DatabaseType string `json:"database_type"` + ClusterID string `json:"cluster_id"` + ClusterName string `json:"cluster_name"` + ClusterType string `json:"cluster_type"` + ClusterPlatformType string `json:"cluster_platform_type"` + ClusterAvailabilityZone string `json:"cluster_az"` + CreatedTime string `json:"created_time"` + DeployType string `json:"deploy_type"` + DeployScale int `json:"deploy_scale"` + DeployStatus int `json:"deploy_status"` + DetailStatus DetailStatus `json:"detail_status"` + IsCrossRegion bool `json:"is_cross_region"` + IsSupportRollback bool `json:"is_support_rollback"` + IsSupportRestful bool `json:"is_support_restful"` + IsSupportTc3 bool `json:"is_support_tc3"` + IsOldService bool `json:"is_old_service"` + OldServiceVersion string `json:"old_service_version"` + AgentPortalAddress []string `json:"agent_portal_addrs"` + Status string `json:"status"` + ProcessStatus string `json:"process_status"` + Tc3TaskServerPortalAddrs []string `json:"tc3_taskserver_portal_addrs"` + TotalDeployPeer int `json:"total_deploy_peer"` + OrderStatus int `json:"order_status"` + OrderInfo OrderInfo `json:"order_info"` + OrderFadeCache int `json:"order_fade_cache"` + OrderFadeEnable bool `json:"order_fade_enable"` + IEFClusterInfo IEFCluster `json:"ief_cluster_info"` + IEFAPIVersion string `json:"iefapi_version"` } type Channel struct { @@ -107,6 +122,9 @@ type CouchDB struct { type DMSKafka struct { Address []string `json:"addr"` + Name string `json:"name"` + Status string `json:"status"` + NodeCount int `json:"node_cnt"` OrderFadeEnable bool `json:"order_fade_enable"` OrderFadeCache int `json:"order_fade_cache"` } @@ -115,6 +133,13 @@ type IEF struct { DeployMode int `json:"deploy_mode"` } +type IEFCluster struct { + GroupID string `json:"group_id"` + GroupName string `json:"group_name"` + InstanceID string `json:"instance_id"` + InstanceName string `json:"instance_name"` +} + type SFS struct { Name string `json:"name"` PVCName string `json:"pvc_name"` @@ -131,6 +156,25 @@ type OBS struct { Address string `json:"addr"` } +type DetailStatus struct { + AgentStatus string `json:"agent_status"` + ConsensusStatus string `json:"consensus_status"` + OrgStatus string `json:"org_status"` + PeerStatus string `json:"peer_status"` + PluginStatus string `json:"plugin_status"` +} + +type OrderInfo struct { + Delete int `json:"delete"` + Operate int `json:"operate"` + OrderID string `json:"order_id"` + OrderStatus int `json:"order_status"` + OrderType int `json:"order_type"` + Release int `json:"release"` + ResourceErrorCode string `json:"resource_error_code"` + ResourceStatus int `json:"resource_status"` +} + func (r ShowResult) Extract() (*BCSInstance, error) { var res BCSInstance err := r.ExtractInto(&res) diff --git a/openstack/bcs/v2/blockchains/urls.go b/openstack/bcs/v2/blockchains/urls.go index 8e2ad4fa..4cac1429 100644 --- a/openstack/bcs/v2/blockchains/urls.go +++ b/openstack/bcs/v2/blockchains/urls.go @@ -2,26 +2,16 @@ package blockchains import "github.com/huaweicloud/golangsdk" -func createURL(c *golangsdk.ServiceClient) string { - return c.ServiceURL("blockchains") -} - -func listURL(c *golangsdk.ServiceClient) string { - return c.ServiceURL("blockchains") -} - -func getURL(c *golangsdk.ServiceClient, instanceID string) string { - return c.ServiceURL("blockchains", instanceID) -} +const resourcePath = "blockchains" -func updateURL(c *golangsdk.ServiceClient, instanceID string) string { - return c.ServiceURL("blockchains", instanceID) +func rootURL(c *golangsdk.ServiceClient) string { + return c.ServiceURL(resourcePath) } -func deleteURL(c *golangsdk.ServiceClient, instanceID string) string { - return c.ServiceURL("blockchains", instanceID) +func resourceURL(c *golangsdk.ServiceClient, instanceID string) string { + return c.ServiceURL(resourcePath, instanceID) } -func extraURL(c *golangsdk.ServiceClient, instanceID string, extra string) string { - return c.ServiceURL("blockchains", instanceID, extra) +func extraURL(c *golangsdk.ServiceClient, instanceID, extra string) string { + return c.ServiceURL(resourcePath, instanceID, extra) }