You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2021/11/29 09:11:30 UTC

[cloudstack-go] 01/01: Rename CSLong to ManagementServerId

This is an automated email from the ASF dual-hosted git repository.

davidjumani pushed a commit to branch support-4.x
in repository https://gitbox.apache.org/repos/asf/cloudstack-go.git

commit f6ca004912a53455090ac8143022120f146e8754
Author: davidjumani <dj...@gmail.com>
AuthorDate: Mon Nov 29 14:39:48 2021 +0530

    Rename CSLong to ManagementServerId
---
 cloudstack/HostService.go     | 120 +++++++++++++++++++++---------------------
 cloudstack/cloudstack.go      |  10 ++--
 cloudstack/cloudstack_test.go |  14 ++---
 generate/generate.go          |  18 +++----
 4 files changed, 80 insertions(+), 82 deletions(-)

diff --git a/cloudstack/HostService.go b/cloudstack/HostService.go
index b662183..a2638e4 100644
--- a/cloudstack/HostService.go
+++ b/cloudstack/HostService.go
@@ -356,7 +356,7 @@ type AddBaremetalHostResponse struct {
 	Jobstatus                        int                                `json:"jobstatus"`
 	Lastannotated                    string                             `json:"lastannotated"`
 	Lastpinged                       string                             `json:"lastpinged"`
-	Managementserverid               CSLong                             `json:"managementserverid"`
+	Managementserverid               ManagementServerId                 `json:"managementserverid"`
 	Memoryallocated                  int64                              `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                              `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                             `json:"memoryallocatedpercentage"`
@@ -789,7 +789,7 @@ type AddHostResponse struct {
 	Jobstatus                        int                         `json:"jobstatus"`
 	Lastannotated                    string                      `json:"lastannotated"`
 	Lastpinged                       string                      `json:"lastpinged"`
-	Managementserverid               CSLong                      `json:"managementserverid"`
+	Managementserverid               ManagementServerId          `json:"managementserverid"`
 	Memoryallocated                  int64                       `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                       `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                      `json:"memoryallocatedpercentage"`
@@ -1032,7 +1032,7 @@ type CancelHostMaintenanceResponse struct {
 	Jobstatus                        int                                     `json:"jobstatus"`
 	Lastannotated                    string                                  `json:"lastannotated"`
 	Lastpinged                       string                                  `json:"lastpinged"`
-	Managementserverid               CSLong                                  `json:"managementserverid"`
+	Managementserverid               ManagementServerId                      `json:"managementserverid"`
 	Memoryallocated                  int64                                   `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                                   `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                                  `json:"memoryallocatedpercentage"`
@@ -1801,58 +1801,58 @@ func (s *HostService) FindHostsForMigration(p *FindHostsForMigrationParams) (*Fi
 }
 
 type FindHostsForMigrationResponse struct {
-	Averageload                      int64  `json:"averageload"`
-	Capabilities                     string `json:"capabilities"`
-	Clusterid                        string `json:"clusterid"`
-	Clustername                      string `json:"clustername"`
-	Clustertype                      string `json:"clustertype"`
-	Cpuallocated                     string `json:"cpuallocated"`
-	Cpuallocatedpercentage           string `json:"cpuallocatedpercentage"`
-	Cpuallocatedvalue                int64  `json:"cpuallocatedvalue"`
-	Cpuallocatedwithoverprovisioning string `json:"cpuallocatedwithoverprovisioning"`
-	Cpunumber                        int    `json:"cpunumber"`
-	Cpuspeed                         int64  `json:"cpuspeed"`
-	Cpuused                          string `json:"cpuused"`
-	Cpuwithoverprovisioning          string `json:"cpuwithoverprovisioning"`
-	Created                          string `json:"created"`
-	Disconnected                     string `json:"disconnected"`
-	Disksizeallocated                int64  `json:"disksizeallocated"`
-	Disksizetotal                    int64  `json:"disksizetotal"`
-	Events                           string `json:"events"`
-	Hahost                           bool   `json:"hahost"`
-	Hasenoughcapacity                bool   `json:"hasenoughcapacity"`
-	Hosttags                         string `json:"hosttags"`
-	Hypervisor                       string `json:"hypervisor"`
-	Hypervisorversion                string `json:"hypervisorversion"`
-	Id                               string `json:"id"`
-	Ipaddress                        string `json:"ipaddress"`
-	Islocalstorageactive             bool   `json:"islocalstorageactive"`
-	JobID                            string `json:"jobid"`
-	Jobstatus                        int    `json:"jobstatus"`
-	Lastpinged                       string `json:"lastpinged"`
-	Managementserverid               CSLong `json:"managementserverid"`
-	Memoryallocated                  string `json:"memoryallocated"`
-	Memoryallocatedbytes             int64  `json:"memoryallocatedbytes"`
-	Memoryallocatedpercentage        string `json:"memoryallocatedpercentage"`
-	Memorytotal                      int64  `json:"memorytotal"`
-	Memoryused                       int64  `json:"memoryused"`
-	Memorywithoverprovisioning       string `json:"memorywithoverprovisioning"`
-	Name                             string `json:"name"`
-	Networkkbsread                   int64  `json:"networkkbsread"`
-	Networkkbswrite                  int64  `json:"networkkbswrite"`
-	Oscategoryid                     string `json:"oscategoryid"`
-	Oscategoryname                   string `json:"oscategoryname"`
-	Podid                            string `json:"podid"`
-	Podname                          string `json:"podname"`
-	Removed                          string `json:"removed"`
-	RequiresStorageMotion            bool   `json:"requiresStorageMotion"`
-	Resourcestate                    string `json:"resourcestate"`
-	State                            string `json:"state"`
-	Suitableformigration             bool   `json:"suitableformigration"`
-	Type                             string `json:"type"`
-	Version                          string `json:"version"`
-	Zoneid                           string `json:"zoneid"`
-	Zonename                         string `json:"zonename"`
+	Averageload                      int64              `json:"averageload"`
+	Capabilities                     string             `json:"capabilities"`
+	Clusterid                        string             `json:"clusterid"`
+	Clustername                      string             `json:"clustername"`
+	Clustertype                      string             `json:"clustertype"`
+	Cpuallocated                     string             `json:"cpuallocated"`
+	Cpuallocatedpercentage           string             `json:"cpuallocatedpercentage"`
+	Cpuallocatedvalue                int64              `json:"cpuallocatedvalue"`
+	Cpuallocatedwithoverprovisioning string             `json:"cpuallocatedwithoverprovisioning"`
+	Cpunumber                        int                `json:"cpunumber"`
+	Cpuspeed                         int64              `json:"cpuspeed"`
+	Cpuused                          string             `json:"cpuused"`
+	Cpuwithoverprovisioning          string             `json:"cpuwithoverprovisioning"`
+	Created                          string             `json:"created"`
+	Disconnected                     string             `json:"disconnected"`
+	Disksizeallocated                int64              `json:"disksizeallocated"`
+	Disksizetotal                    int64              `json:"disksizetotal"`
+	Events                           string             `json:"events"`
+	Hahost                           bool               `json:"hahost"`
+	Hasenoughcapacity                bool               `json:"hasenoughcapacity"`
+	Hosttags                         string             `json:"hosttags"`
+	Hypervisor                       string             `json:"hypervisor"`
+	Hypervisorversion                string             `json:"hypervisorversion"`
+	Id                               string             `json:"id"`
+	Ipaddress                        string             `json:"ipaddress"`
+	Islocalstorageactive             bool               `json:"islocalstorageactive"`
+	JobID                            string             `json:"jobid"`
+	Jobstatus                        int                `json:"jobstatus"`
+	Lastpinged                       string             `json:"lastpinged"`
+	Managementserverid               ManagementServerId `json:"managementserverid"`
+	Memoryallocated                  string             `json:"memoryallocated"`
+	Memoryallocatedbytes             int64              `json:"memoryallocatedbytes"`
+	Memoryallocatedpercentage        string             `json:"memoryallocatedpercentage"`
+	Memorytotal                      int64              `json:"memorytotal"`
+	Memoryused                       int64              `json:"memoryused"`
+	Memorywithoverprovisioning       string             `json:"memorywithoverprovisioning"`
+	Name                             string             `json:"name"`
+	Networkkbsread                   int64              `json:"networkkbsread"`
+	Networkkbswrite                  int64              `json:"networkkbswrite"`
+	Oscategoryid                     string             `json:"oscategoryid"`
+	Oscategoryname                   string             `json:"oscategoryname"`
+	Podid                            string             `json:"podid"`
+	Podname                          string             `json:"podname"`
+	Removed                          string             `json:"removed"`
+	RequiresStorageMotion            bool               `json:"requiresStorageMotion"`
+	Resourcestate                    string             `json:"resourcestate"`
+	State                            string             `json:"state"`
+	Suitableformigration             bool               `json:"suitableformigration"`
+	Type                             string             `json:"type"`
+	Version                          string             `json:"version"`
+	Zoneid                           string             `json:"zoneid"`
+	Zonename                         string             `json:"zonename"`
 }
 
 type ListDedicatedHostsParams struct {
@@ -2645,7 +2645,7 @@ type Host struct {
 	Jobstatus                        int                         `json:"jobstatus"`
 	Lastannotated                    string                      `json:"lastannotated"`
 	Lastpinged                       string                      `json:"lastpinged"`
-	Managementserverid               CSLong                      `json:"managementserverid"`
+	Managementserverid               ManagementServerId          `json:"managementserverid"`
 	Memoryallocated                  int64                       `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                       `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                      `json:"memoryallocatedpercentage"`
@@ -3167,7 +3167,7 @@ type HostsMetric struct {
 	Jobstatus                        int                         `json:"jobstatus"`
 	Lastannotated                    string                      `json:"lastannotated"`
 	Lastpinged                       string                      `json:"lastpinged"`
-	Managementserverid               CSLong                      `json:"managementserverid"`
+	Managementserverid               ManagementServerId          `json:"managementserverid"`
 	Memoryallocated                  int64                       `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                       `json:"memoryallocatedbytes"`
 	Memoryallocateddisablethreshold  bool                        `json:"memoryallocateddisablethreshold"`
@@ -3331,7 +3331,7 @@ type PrepareHostForMaintenanceResponse struct {
 	Jobstatus                        int                                         `json:"jobstatus"`
 	Lastannotated                    string                                      `json:"lastannotated"`
 	Lastpinged                       string                                      `json:"lastpinged"`
-	Managementserverid               CSLong                                      `json:"managementserverid"`
+	Managementserverid               ManagementServerId                          `json:"managementserverid"`
 	Memoryallocated                  int64                                       `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                                       `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                                      `json:"memoryallocatedpercentage"`
@@ -3485,7 +3485,7 @@ type ReconnectHostResponse struct {
 	Jobstatus                        int                             `json:"jobstatus"`
 	Lastannotated                    string                          `json:"lastannotated"`
 	Lastpinged                       string                          `json:"lastpinged"`
-	Managementserverid               CSLong                          `json:"managementserverid"`
+	Managementserverid               ManagementServerId              `json:"managementserverid"`
 	Memoryallocated                  int64                           `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                           `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                          `json:"memoryallocatedpercentage"`
@@ -3880,7 +3880,7 @@ type UpdateHostResponse struct {
 	Jobstatus                        int                          `json:"jobstatus"`
 	Lastannotated                    string                       `json:"lastannotated"`
 	Lastpinged                       string                       `json:"lastpinged"`
-	Managementserverid               CSLong                       `json:"managementserverid"`
+	Managementserverid               ManagementServerId           `json:"managementserverid"`
 	Memoryallocated                  int64                        `json:"memoryallocated"`
 	Memoryallocatedbytes             int64                        `json:"memoryallocatedbytes"`
 	Memoryallocatedpercentage        string                       `json:"memoryallocatedpercentage"`
diff --git a/cloudstack/cloudstack.go b/cloudstack/cloudstack.go
index 5073fd1..5be0f9d 100644
--- a/cloudstack/cloudstack.go
+++ b/cloudstack/cloudstack.go
@@ -68,23 +68,23 @@ func (e *CSError) Error() error {
 	return fmt.Errorf("CloudStack API error %d (CSExceptionErrorCode: %d): %s", e.ErrorCode, e.CSErrorCode, e.ErrorText)
 }
 
-type CSLong string
+type ManagementServerId string
 
-func (c CSLong) MarshalJSON() ([]byte, error) {
+func (c ManagementServerId) MarshalJSON() ([]byte, error) {
 	return json.Marshal(string(c))
 }
 
-func (c *CSLong) UnmarshalJSON(data []byte) error {
+func (c *ManagementServerId) UnmarshalJSON(data []byte) error {
 	value := strings.Trim(string(data), "\"")
 	if strings.HasPrefix(string(data), "\"") {
-		*c = CSLong(value)
+		*c = ManagementServerId(value)
 		return nil
 	}
 	_, err := strconv.ParseInt(value, 10, 64)
 	if err != nil {
 		return err
 	}
-	*c = CSLong(value)
+	*c = ManagementServerId(value)
 	return nil
 }
 
diff --git a/cloudstack/cloudstack_test.go b/cloudstack/cloudstack_test.go
index 9e6251b..fd7b565 100644
--- a/cloudstack/cloudstack_test.go
+++ b/cloudstack/cloudstack_test.go
@@ -88,19 +88,19 @@ func TestCreateSyncClient(t *testing.T) {
 	}
 }
 
-type CSLongStruct struct {
-	Value CSLong `json:"value"`
+type ManagementServerIdStruct struct {
+	Value ManagementServerId `json:"value"`
 }
 
-func TestCSLong(t *testing.T) {
+func TestManagementServerId(t *testing.T) {
 	valLong := `{"value": 4801878}`
 	valString := `{"value": "994801878"}`
 	valBool := `{"value": false}`
-	res := CSLongStruct{}
+	res := ManagementServerIdStruct{}
 
 	res.Value = ""
 	if err := json.Unmarshal([]byte(valLong), &res); err != nil {
-		t.Errorf("could not unserialize long into CSLong: %s", err)
+		t.Errorf("could not unserialize long into ManagementServerId: %s", err)
 	}
 	if res.Value != "4801878" {
 		t.Errorf("unepected value '%s', expecting 4801878", res.Value)
@@ -108,7 +108,7 @@ func TestCSLong(t *testing.T) {
 
 	res.Value = ""
 	if err := json.Unmarshal([]byte(valString), &res); err != nil {
-		t.Errorf("could not unserialize string into CSLong: %s", err)
+		t.Errorf("could not unserialize string into ManagementServerId: %s", err)
 	}
 	if res.Value != "994801878" {
 		t.Errorf("unepected value '%s', expecting 994801878", res.Value)
@@ -116,6 +116,6 @@ func TestCSLong(t *testing.T) {
 
 	res.Value = ""
 	if err := json.Unmarshal([]byte(valBool), &res); err == nil {
-		t.Errorf("missing expected error when serializing bool into CSLong")
+		t.Errorf("missing expected error when serializing bool into ManagementServerId")
 	}
 }
diff --git a/generate/generate.go b/generate/generate.go
index ce13c2c..c9e6c5f 100644
--- a/generate/generate.go
+++ b/generate/generate.go
@@ -63,7 +63,6 @@ var mapRequireList = map[string]map[string]bool{
 	},
 }
 
-
 // nestedResponse is a prefilled map with the list of endpoints
 // that responses fields are nested in a parent object. The map value
 // gives the object field name.
@@ -86,7 +85,6 @@ var typeNames = map[string]bool{"Nic": true}
 
 type apiInfo map[string][]string
 
-
 type allServices struct {
 	services services
 }
@@ -312,23 +310,23 @@ func (as *allServices) GeneralCode() ([]byte, error) {
 	pn("}")
 	pn("")
 
-	pn("type CSLong string")
+	pn("type ManagementServerId string")
 	pn("")
-	pn("func (c CSLong) MarshalJSON() ([]byte, error) {")
+	pn("func (c ManagementServerId) MarshalJSON() ([]byte, error) {")
 	pn("	return json.Marshal(string(c))")
 	pn("}")
 	pn("")
-	pn("func (c *CSLong) UnmarshalJSON(data []byte) error {")
+	pn("func (c *ManagementServerId) UnmarshalJSON(data []byte) error {")
 	pn("	value := strings.Trim(string(data), \"\\\"\")")
 	pn("	if strings.HasPrefix(string(data), \"\\\"\") {")
-	pn("		*c = CSLong(value)")
+	pn("		*c = ManagementServerId(value)")
 	pn("	  return nil")
 	pn("	}")
 	pn("	_, err := strconv.ParseInt(value, 10, 64)")
 	pn("	if err != nil {")
 	pn("		return err")
 	pn("	}")
-	pn("	*c = CSLong(value)")
+	pn("	*c = ManagementServerId(value)")
 	pn("	return nil")
 	pn("}")
 
@@ -1834,12 +1832,12 @@ func sourceDir() (string, error) {
 
 func mapType(aName string, pName string, pType string) string {
 	if _, ok := longToStringCompat[pName]; ok {
-		pType = "CSLong"
+		pType = "ManagementServerId"
 	}
 
 	switch pType {
-	case "CSLong":
-		return "CSLong"
+	case "ManagementServerId":
+		return "ManagementServerId"
 	case "boolean":
 		return "bool"
 	case "short", "int", "integer":