Skip to content

Commit

Permalink
Merge pull request #77 from HewlettPackard/add-storage-vol
Browse files Browse the repository at this point in the history
Add get storage-vol-type api call
  • Loading branch information
manjunath-batakurki authored Sep 12, 2024
2 parents 61cb94a + 0affabb commit 38cfff9
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
24 changes: 23 additions & 1 deletion pkg/client/instances.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

package client

Expand Down Expand Up @@ -447,3 +447,25 @@ func (a *InstancesAPIService) CloneAnInstance(ctx context.Context, instanceID in

return CloneResp, err
}

func (a *InstancesAPIService) GetStorageVolTypeID(ctx context.Context, cloudID, layoutID string,
) (models.InstancePlanResponse, error) {
StorageVol := models.InstancePlanResponse{}

apiCaller := &api{
method: "GET",
path: consts.InstancePlanPath,
client: a.Client,

jsonParser: func(body []byte) error {
return json.Unmarshal(body, &StorageVol)
},
}
queryParams := map[string]string{
"zoneId": cloudID,
"layoutId": layoutID,
}
err := apiCaller.do(ctx, nil, queryParams)

return StorageVol, err
}
4 changes: 3 additions & 1 deletion pkg/common/constants.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

package common

Expand Down Expand Up @@ -26,6 +26,8 @@ const (
LibraryInstanceTypesPath = "library/instance-types"
// Service plans path
ServicePlansPath = "service-plans"
// Instance Service Plan for storage vol type
InstancePlanPath = "instances/service-plans"
// CloudsPath
CloudsPath = "clouds"
// ZonePath
Expand Down
3 changes: 2 additions & 1 deletion pkg/models/instance_tf.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2021 Hewlett Packard Enterprise Development LP
// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

// This file contains struct models related to terraform, but not the API
package models
Expand All @@ -25,6 +25,7 @@ type TFInstanceVolume struct {
DatastoreID string `tf:"datastore_id"`
ID int `tf:"id"`
Root bool `tf:"root"`
StorageType int `tf:"storage_type"`
}

type TFInstanceNetwork struct {
Expand Down
36 changes: 36 additions & 0 deletions pkg/models/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ type GetInstanceResponseInstanceVolumes struct {
Size int `json:"size,omitempty"`
Name string `json:"name,omitempty"`
RootVolume bool `json:"rootVolume,omitempty"`
StorageType int `json:"storageType,omitempty"`
ID int `json:"id,omitempty"`
DatastoreID interface{} `json:"datastoreId,omitempty"`
MaxStorage float64 `json:"maxStorage,omitempty"`
Expand Down Expand Up @@ -591,3 +592,38 @@ type GetInstanceContainersServerType struct {
Managed bool `json:"managed" tf:"managed"`
ExternalDelete bool `json:"externalDelete" tf:"external_delete"`
}

type InstancePlanResponse struct {
Plans []struct {
ID int `json:"id"`
Name string `json:"name"`
Value int `json:"value"`
Code string `json:"code"`
MaxStorage int `json:"maxStorage"`
MaxMemory int `json:"maxMemory"`
MaxCPU interface{} `json:"maxCpu"`
MaxCores int `json:"maxCores"`
CustomCPU bool `json:"customCpu"`
CustomMaxMemory bool `json:"customMaxMemory"`
CustomMaxStorage bool `json:"customMaxStorage"`
CustomMaxDataStorage bool `json:"customMaxDataStorage"`
CustomCoresPerSocket bool `json:"customCoresPerSocket"`
CoresPerSocket int `json:"coresPerSocket"`
StorageTypes []InstanceStorageType `json:"storageTypes"`
RootStorageTypes []InstanceStorageType `json:"rootStorageTypes"`
} `json:"plans"`
}

type InstanceStorageType struct {
ID int `json:"id" tf:"id,computed"`
Code string `json:"code" tf:"code"`
DisplayName string `json:"displayName"`
Name string `json:"name" tf:"name"`
ConfigurableIOPS bool `json:"configurableIOPS"`
PlanResizable bool `json:"planResizable"`
CustomLabel bool `json:"customLabel"`
Enabled bool `json:"enabled"`
Description string `json:"description"`
VolumeCategory string `json:"volumeCategory"`
ExternalID string `json:"externalId"`
}

0 comments on commit 38cfff9

Please sign in to comment.