diff --git a/system_limit.go b/system_limit.go index 5080943..e58ca7e 100644 --- a/system_limit.go +++ b/system_limit.go @@ -20,14 +20,10 @@ import ( types "github.com/dell/goscaleio/types/v1" ) -type QuerySystemLimitsParam struct { -} - // GetSystemLimits gets list of sytem limits - -func (c *Client) GetSystemLimits() (systemLimits *types.Limit, err error) { +func (c *Client) GetSystemLimits() (systemLimits *types.QuerySystemLimitsResponse, err error) { defer TimeSpent("GetSystemLimits", time.Now()) - var body QuerySystemLimitsParam + var body *types.QuerySystemLimitsParam path := "/api/instances/System/action/querySystemLimits" err = c.getJSONWithRetry( http.MethodPost, path, body, &systemLimits) @@ -41,16 +37,16 @@ func (c *Client) GetSystemLimits() (systemLimits *types.Limit, err error) { // GetMaxVol returns max volume size in GB func (c *Client) GetMaxVol() (systemLimits string, err error) { defer TimeSpent("GetMaxVol", time.Now()) - maxLimitType, err := c.GetSystemLimits() + sysLimit, err := c.GetSystemLimits() if err != nil { return "", err } - for _, systemType := range maxLimitType.SystemLimitEntryList { + for _, systemLimit := range sysLimit.SystemLimitEntryList { - if systemType.Type == "volumeSizeGb" { - return systemType.MaxVal, nil + if systemLimit.Type == "volumeSizeGb" { + return systemLimit.MaxVal, nil } } diff --git a/system_limit_test.go b/system_limit_test.go index 5438cab..1ecc384 100644 --- a/system_limit_test.go +++ b/system_limit_test.go @@ -25,23 +25,23 @@ import ( ) func TestGetSystemLimits(t *testing.T) { - type checkFn func(*testing.T, *types.Limit, error) + type checkFn func(*testing.T, *types.QuerySystemLimitsResponse, error) check := func(fns ...checkFn) []checkFn { return fns } - hasNoError := func(t *testing.T, syslimit *types.Limit, err error) { + hasNoError := func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { if err != nil { t.Fatalf("expected no error") } } - hasError := func(t *testing.T, syslimit *types.Limit, err error) { + hasError := func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { if err == nil { t.Fatalf("expected error") } } - checkLimitType := func(expectedType string) func(t *testing.T, syslimit *types.Limit, err error) { - return func(t *testing.T, syslimit *types.Limit, err error) { + checkLimitType := func(expectedType string) func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { + return func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { if err == nil { // Add your custom assertions here to check the syslimit.Type. assert.Equal(t, expectedType, syslimit.SystemLimitEntryList[0].Type) @@ -49,8 +49,8 @@ func TestGetSystemLimits(t *testing.T) { } } - checkLimitDescription := func(expectedDescription string) func(t *testing.T, syslimit *types.Limit, err error) { - return func(t *testing.T, syslimit *types.Limit, err error) { + checkLimitDescription := func(expectedDescription string) func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { + return func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { if err == nil { // Add your custom assertions here to check the syslimit.Description. assert.Equal(t, expectedDescription, syslimit.SystemLimitEntryList[0].Description) @@ -58,8 +58,8 @@ func TestGetSystemLimits(t *testing.T) { } } - checkLimitMaxVal := func(expectedMaxVal string) func(t *testing.T, syslimit *types.Limit, err error) { - return func(t *testing.T, syslimit *types.Limit, err error) { + checkLimitMaxVal := func(expectedMaxVal string) func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { + return func(t *testing.T, syslimit *types.QuerySystemLimitsResponse, err error) { if err == nil { // Add your custom assertions here to check the syslimit.MaxVal. assert.Equal(t, expectedMaxVal, syslimit.SystemLimitEntryList[0].MaxVal) @@ -81,8 +81,8 @@ func TestGetSystemLimits(t *testing.T) { } // Simulate a successful response for GetSystemLimits. - resp := types.Limit{ - SystemLimitEntryList: []types.QuerySystemLimits{ + resp := types.QuerySystemLimitsResponse{ + SystemLimitEntryList: []types.SystemLimits{ { Type: "volumeSizeGb", Description: "Maximum volume size in GB", diff --git a/types/v1/types.go b/types/v1/types.go index fe8ca86..6ec8a3b 100644 --- a/types/v1/types.go +++ b/types/v1/types.go @@ -1739,14 +1739,17 @@ type MDMQueueCommandDetails struct { AllowedPhase string `json:"allowedPhase,omitempty"` } -// QuerySystemLimits defines struct for query system limits -type QuerySystemLimits struct { +// SystemLimits defines struct for system limits +type SystemLimits struct { Type string `json:"type,omitempty"` Description string `json:"description,omitempty"` MaxVal string `json:"maxVal,omitempty"` } // SystemLimitEntryList defines struct for system limit entryList -type Limit struct { - SystemLimitEntryList []QuerySystemLimits `json:"systemLimitEntryList"` +type QuerySystemLimitsResponse struct { + SystemLimitEntryList []SystemLimits `json:"systemLimitEntryList"` +} + +type QuerySystemLimitsParam struct { }