From 2e602be8c1da388546bf88439ad9783dfafa779f Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 7 Nov 2024 15:28:12 +0530 Subject: [PATCH 1/4] Update datatype for instance from int to int64 --- pkg/models/instances.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/models/instances.go b/pkg/models/instances.go index 7396e0a..1630a67 100644 --- a/pkg/models/instances.go +++ b/pkg/models/instances.go @@ -130,9 +130,9 @@ type GetInstanceResponse struct { // GetInstanceResponseInstance type GetInstanceResponseInstance struct { - ID int `json:"id,omitempty"` + ID int64 `json:"id,omitempty"` UUID string `json:"uuid,omitempty"` - AccountID int `json:"accountId,omitempty"` + AccountID int64 `json:"accountId,omitempty"` Tenant *GetInstanceResponseInstanceTenant `json:"tenant,omitempty"` InstanceType *GetInstanceResponseInstanceInstanceType `json:"instanceType,omitempty"` Group *GetInstanceResponseInstanceGroup `json:"group,omitempty"` @@ -517,12 +517,12 @@ type GetInstanceHistoryProcessType struct { } type GetInstanceHistoryProcesses struct { - ID int `json:"id" tf:"id"` - AccountID int `json:"accountId" tf:"account_id"` + ID int64 `json:"id" tf:"id"` + AccountID int64 `json:"accountId" tf:"account_id"` UniqueID string `json:"uniqueId" tf:"unique_id"` ProcessType GetInstanceHistoryProcessType `json:"processType" tf:"process_type,sub"` DisplayName string `json:"displayName" tf:"display_name"` - InstanceID int `json:"instanceId" tf:"instance_id"` + InstanceID int64 `json:"instanceId" tf:"instance_id"` Status string `json:"status" tf:"status"` Reason interface{} `json:"reason" tf:"reason"` Percent float64 `json:"percent" tf:"percent"` @@ -578,20 +578,20 @@ type CreateInstanceCloneBody struct { } type GetInstanceContainer struct { - ID int `json:"id" tf:"id"` + ID int64 `json:"id" tf:"id"` Name string `json:"name" tf:"name"` IP string `json:"ip" tf:"ip"` ExternalFqdn string `json:"externalFqdn" tf:"external_fqdn"` ContainerType NameModel `json:"containerType" tf:"container_type,sub"` Server GetInstanceContainersServer `json:"server" tf:"server,sub"` Hostname string `json:"hostname" tf:"hostname"` - MaxStorage int `json:"maxStorage" tf:"max_storage"` - MaxMemory int `json:"maxMemory" tf:"max_memory"` + MaxStorage int64 `json:"maxStorage" tf:"max_storage"` + MaxMemory int64 `json:"maxMemory" tf:"max_memory"` MaxCores int `json:"maxCores" tf:"max_cores"` } type GetInstanceContainersServer struct { - ID int `json:"id" tf:"id"` + ID int64 `json:"id" tf:"id"` Owner UserNameModel `json:"owner" tf:"owner,sub"` ComputeServerType GetInstanceContainersServerType `json:"computeServerType" tf:"compute_server_type,sub"` Visibility string `json:"visibility" tf:"visibility"` @@ -616,8 +616,8 @@ type InstancePlanResponse struct { Name string `json:"name"` Value int `json:"value"` Code string `json:"code"` - MaxStorage int `json:"maxStorage"` - MaxMemory int `json:"maxMemory"` + MaxStorage int64 `json:"maxStorage"` + MaxMemory int64 `json:"maxMemory"` MaxCPU interface{} `json:"maxCpu"` MaxCores int `json:"maxCores"` CustomCPU bool `json:"customCpu"` From 146e0cff279c7a4ef87f768ab62410e3d80766d4 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 7 Nov 2024 15:42:25 +0530 Subject: [PATCH 2/4] update functions --- pkg/client/instances.go | 4 ++-- pkg/client/instances_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/client/instances.go b/pkg/client/instances.go index c0e0334..f88950f 100644 --- a/pkg/client/instances.go +++ b/pkg/client/instances.go @@ -124,7 +124,7 @@ Get a Specific Instance @return models.GetInstanceResponse */ func (a *InstancesAPIService) GetASpecificInstance(ctx context.Context, - instanceID int) (models.GetInstanceResponse, error) { + instanceID int64) (models.GetInstanceResponse, error) { SpecificInstResp := models.GetInstanceResponse{} specificInstanceAPI := &api{ @@ -471,7 +471,7 @@ func (a *InstancesAPIService) GetStorageVolTypeID(ctx context.Context, cloudID, return StorageVol, err } -func (a *InstancesAPIService) GetStorageControllerMount(ctx context.Context, instanceID int, controllerType string, +func (a *InstancesAPIService) GetStorageControllerMount(ctx context.Context, instanceID int64, controllerType string, busNumber, unitNumber int) (ControllerMount string, err error) { controllerTypeInput := strings.ToLower(controllerType) if controllerTypeInput == "ide" { diff --git a/pkg/client/instances_test.go b/pkg/client/instances_test.go index 9d579d3..d10de87 100644 --- a/pkg/client/instances_test.go +++ b/pkg/client/instances_test.go @@ -1,4 +1,4 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP +// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP package client @@ -1120,7 +1120,7 @@ func TestInstancesAPIService_GetASpecificInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 // All expectaion captures here given func(m *MockAPIClientHandler) want models.GetInstanceResponse From ccfc80524a51198d67c7fe790e7e73ad637d3f6e Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 7 Nov 2024 15:53:43 +0530 Subject: [PATCH 3/4] update function arg --- pkg/client/instances.go | 12 ++++++------ pkg/client/instances_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/client/instances.go b/pkg/client/instances.go index f88950f..4dbb6c3 100644 --- a/pkg/client/instances.go +++ b/pkg/client/instances.go @@ -95,7 +95,7 @@ type InstancesAPIDeleteAnIstanceOpts struct { } func (a *InstancesAPIService) DeleteAnInstance(ctx context.Context, - instanceID int) (models.SuccessOrErrorMessage, error) { + instanceID int64) (models.SuccessOrErrorMessage, error) { DelInstanceResp := models.SuccessOrErrorMessage{} delInstanceAPI := &api{ @@ -177,7 +177,7 @@ Lists VMware Snapshot of the instance - @param instanceID */ func (a *InstancesAPIService) GetListOfSnapshotsForAnInstance(ctx context.Context, - instanceID int) (models.ListSnapshotResponse, error) { + instanceID int64) (models.ListSnapshotResponse, error) { ListSnapshotResp := models.ListSnapshotResponse{} listSnapshotAPI := &api{ @@ -266,7 +266,7 @@ Creates VMware Snapshot of the instance */ -func (a *InstancesAPIService) SnapshotAnInstance(ctx context.Context, instanceID int, +func (a *InstancesAPIService) SnapshotAnInstance(ctx context.Context, instanceID int64, localVarOptionals *models.SnapshotBody) (models.Instances, error) { SnapshotInstResp := models.Instances{} @@ -365,7 +365,7 @@ func (a *InstancesAPIService) SuspendAnInstance(ctx context.Context, return SuspendResp, err } -func (a *InstancesAPIService) ResizeAnInstance(ctx context.Context, instanceID int, +func (a *InstancesAPIService) ResizeAnInstance(ctx context.Context, instanceID int64, request *models.ResizeInstanceBody) (models.ResizeInstanceResponse, error) { ResizeResp := models.ResizeInstanceResponse{} @@ -386,7 +386,7 @@ func (a *InstancesAPIService) ResizeAnInstance(ctx context.Context, instanceID i func (a *InstancesAPIService) UpdatingAnInstance( ctx context.Context, - instanceID int, + instanceID int64, request *models.UpdateInstanceBody, ) (models.UpdateInstanceResponse, error) { Instance := models.UpdateInstanceResponse{} @@ -407,7 +407,7 @@ func (a *InstancesAPIService) UpdatingAnInstance( } func (a *InstancesAPIService) GetInstanceHistory( - ctx context.Context, instanceID int) (models.GetInstanceHistory, error) { + ctx context.Context, instanceID int64) (models.GetInstanceHistory, error) { History := models.GetInstanceHistory{} historyAPI := &api{ diff --git a/pkg/client/instances_test.go b/pkg/client/instances_test.go index d10de87..8a3e8ef 100644 --- a/pkg/client/instances_test.go +++ b/pkg/client/instances_test.go @@ -382,7 +382,7 @@ func TestInstancesAPIService_DeleteAnInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.SuccessOrErrorMessage wantErr bool @@ -623,7 +623,7 @@ func TestInstancesAPIService_ResizeAnInstance(t *testing.T) { tests := []struct { name string - instanceID int + instanceID int64 param models.ResizeInstanceBody given func(m *MockAPIClientHandler) want models.ResizeInstanceResponse @@ -801,7 +801,7 @@ func TestInstancesAPIService_SnapshotAnInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 param models.SnapshotBody given func(m *MockAPIClientHandler) want models.Instances @@ -963,7 +963,7 @@ func TestInstancesAPIService_UpdatingAnInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 param models.UpdateInstanceBody given func(m *MockAPIClientHandler) want models.UpdateInstanceResponse @@ -1369,7 +1369,7 @@ func TestInstancesAPIService_GetListOfSnapshotsForAnInstance(t *testing.T) { tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.ListSnapshotResponse wantErr bool @@ -1485,7 +1485,7 @@ func TestInstancesAPIService_GetInstanceHistory(t *testing.T) { tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.GetInstanceHistory wantErr bool From b0deabd3fd01b2dee18945d0720690f003a5d2bd Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 7 Nov 2024 16:03:27 +0530 Subject: [PATCH 4/4] update function arg --- pkg/client/instances.go | 12 ++++++------ pkg/client/instances_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/client/instances.go b/pkg/client/instances.go index 4dbb6c3..7da48e8 100644 --- a/pkg/client/instances.go +++ b/pkg/client/instances.go @@ -208,7 +208,7 @@ it currently exists. */ -func (a *InstancesAPIService) ImportSnapshotOfAnInstance(ctx context.Context, instanceID int, +func (a *InstancesAPIService) ImportSnapshotOfAnInstance(ctx context.Context, instanceID int64, localVarOptionals *models.ImportSnapshotBody) (models.SuccessOrErrorMessage, error) { ImportSnapshotResp := models.SuccessOrErrorMessage{} @@ -236,7 +236,7 @@ Restarts all VM running within an instance - @param instanceID */ func (a *InstancesAPIService) RestartAnInstance(ctx context.Context, - instanceID int) (models.InstancePowerResponse, error) { + instanceID int64) (models.InstancePowerResponse, error) { RestartInstResp := models.InstancePowerResponse{} restartInstAPI := &api{ @@ -294,7 +294,7 @@ Starts all VM running within an instance - @param instanceID */ func (a *InstancesAPIService) StartAnInstance(ctx context.Context, - instanceID int) (models.InstancePowerResponse, error) { + instanceID int64) (models.InstancePowerResponse, error) { StartInstanceResp := models.InstancePowerResponse{} startInstanceAPI := &api{ @@ -321,7 +321,7 @@ Stops all VM running within an instance - @param instanceID */ func (a *InstancesAPIService) StopAnInstance(ctx context.Context, - instanceID int) (models.InstancePowerResponse, error) { + instanceID int64) (models.InstancePowerResponse, error) { StopInstanceResp := models.InstancePowerResponse{} stopInstanceAPI := &api{ @@ -348,7 +348,7 @@ Suspends all VM running within an instance - @param instanceID */ func (a *InstancesAPIService) SuspendAnInstance(ctx context.Context, - instanceID int) (models.InstancePowerResponse, error) { + instanceID int64) (models.InstancePowerResponse, error) { SuspendResp := models.InstancePowerResponse{} suspendInstanceAPI := &api{ method: "PUT", @@ -425,7 +425,7 @@ func (a *InstancesAPIService) GetInstanceHistory( return History, err } -func (a *InstancesAPIService) CloneAnInstance(ctx context.Context, instanceID int, +func (a *InstancesAPIService) CloneAnInstance(ctx context.Context, instanceID int64, cloneRequest models.CreateInstanceCloneBody) (models.SuccessOrErrorMessage, error) { var CloneResp models.SuccessOrErrorMessage if v, _ := parseVersion("5.2.12"); v <= a.Client.getVersion() { diff --git a/pkg/client/instances_test.go b/pkg/client/instances_test.go index 8a3e8ef..5de56da 100644 --- a/pkg/client/instances_test.go +++ b/pkg/client/instances_test.go @@ -25,7 +25,7 @@ func TestInstancesAPIService_CloneAnInstance(t *testing.T) { tests := []struct { name string param models.CreateInstanceCloneBody - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.SuccessOrErrorMessage wantErr bool @@ -490,7 +490,7 @@ func TestInstancesAPIService_ImportSnapshotOfAnInstance(t *testing.T) { tests := []struct { name string - instanceID int + instanceID int64 param models.ImportSnapshotBody given func(m *MockAPIClientHandler) want models.SuccessOrErrorMessage @@ -1617,7 +1617,7 @@ func TestInstancesAPIService_RestartAnInstance(t *testing.T) { tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.InstancePowerResponse wantErr bool @@ -1723,7 +1723,7 @@ func TestInstancesAPIService_StartAnInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.InstancePowerResponse wantErr bool @@ -1829,7 +1829,7 @@ func TestInstancesAPIService_StopAnInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.InstancePowerResponse wantErr bool @@ -1935,7 +1935,7 @@ func TestInstancesAPIService_SuspendAnInstance(t *testing.T) { defer ctrl.Finish() tests := []struct { name string - instanceID int + instanceID int64 given func(m *MockAPIClientHandler) want models.InstancePowerResponse wantErr bool