diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78f172e..ed8cd22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,15 +7,15 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - go: [ '1.17' ] + go: [ '1.21' ] steps: - name: Checkout workspace - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: 1.17 + go-version: '1.21' - name: Install necessary tools run: make tools diff --git a/Makefile b/Makefile index 52c108a..86e044d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ #! /usr/bin/make -#(C) Copyright 2021 Hewlett Packard Enterprise Development LP +#(C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP # Inspiration from https://github.com/rightscale/go-boilerplate/blob/master/Makefile VERSION=0.0.1 @@ -54,5 +54,5 @@ all: lint test .PHONY: all tools: - GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 + GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0 .PHONY: tools diff --git a/go.mod b/go.mod index ed9547f..9643257 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,15 @@ module github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk -go 1.17 +go 1.21 require ( github.com/antihax/optional v1.0.0 github.com/golang/mock v1.6.0 +) + +require ( golang.org/x/mod v0.4.2 // indirect - golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/sys v0.21.0 // indirect golang.org/x/tools v0.1.4 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index 7fb2ffb..3762b4f 100644 --- a/go.sum +++ b/go.sum @@ -2,30 +2,25 @@ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwc github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/yuin/goldmark v1.3.5 h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= diff --git a/golangci-lint-config.yaml b/golangci-lint-config.yaml index 5b23ce4..2994b4f 100644 --- a/golangci-lint-config.yaml +++ b/golangci-lint-config.yaml @@ -1,10 +1,8 @@ -#(C) Copyright 2021 Hewlett Packard Enterprise Development LP +#(C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP run: deadline: 240s tests: false - skip-dirs: - - vendor build-tags: acceptance linters-settings: @@ -24,11 +22,11 @@ linters-settings: statements: 60 linters: - enable-all: true + # enable-all: true disable: - wsl - gci - - goerr113 + - err113 - godot - gomnd - gochecknoinits @@ -36,12 +34,10 @@ linters: - testpackage - nolintlint - dupl - - maligned # Temporarily disabling paralleltest # - paralleltest #Temporarily disabling wrapcheck, exhaustivestruct, forbidigo, tagliatelle - wrapcheck - - exhaustivestruct - forbidigo - tagliatelle - forcetypeassert @@ -51,7 +47,8 @@ linters: - cyclop issues: - + exclude-dirs: + - vendor exclude-rules: # Exclude lll issues for long lines with go:generate - linters: @@ -61,7 +58,7 @@ issues: # ignore function length for tests as look up tables typically exceed. - linters: - funlen - - goerr113 + - err113 path: _test\.go - linters: diff --git a/pkg/client/api.go b/pkg/client/api.go index 19dd963..ef21d67 100644 --- a/pkg/client/api.go +++ b/pkg/client/api.go @@ -5,7 +5,7 @@ package client import ( "context" "fmt" - "io/ioutil" + "io" "net/url" "strings" @@ -81,7 +81,7 @@ func (a *api) do(ctx context.Context, request interface{}, queryParams map[strin return ParseError(localVarHTTPResponse) } - localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) defer localVarHTTPResponse.Body.Close() if err != nil { return err diff --git a/pkg/client/clouds.go b/pkg/client/clouds.go index f1cf3af..b7cefd1 100644 --- a/pkg/client/clouds.go +++ b/pkg/client/clouds.go @@ -20,15 +20,14 @@ type CloudsAPIService struct { /* CloudsAPIService Get All Cloud Data Stores - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - * @param cloudID The cloud ID - + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID + - @param cloudID The cloud ID */ func (a *CloudsAPIService) GetAllCloudDataStores(ctx context.Context, cloudID int, queryParams map[string]string) (models.DataStoresResp, error) { - allCloudDSResp := models.DataStoresResp{} + AllCloudDSResp := models.DataStoresResp{} allCloudDSAPI := &api{ method: "GET", @@ -37,7 +36,7 @@ func (a *CloudsAPIService) GetAllCloudDataStores(ctx context.Context, cloudID in client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &allCloudDSResp) + return json.Unmarshal(body, &AllCloudDSResp) }, validations: []validationFunc{ func() error { @@ -51,21 +50,20 @@ func (a *CloudsAPIService) GetAllCloudDataStores(ctx context.Context, cloudID in } err := allCloudDSAPI.do(ctx, nil, queryParams) - return allCloudDSResp, err + return AllCloudDSResp, err } /* CloudsAPIService Get All Cloud Resource Pools - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - * @param cloudID The cloud ID - + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID + - @param cloudID The cloud ID */ func (a *CloudsAPIService) GetAllCloudResourcePools(ctx context.Context, cloudID int, queryParams map[string]string) (models.ResourcePoolsResp, error) { - allCloudRPoolResp := models.ResourcePoolsResp{} + AllCloudRPoolResp := models.ResourcePoolsResp{} allCloudRPoolAPI := &api{ method: "GET", @@ -74,7 +72,7 @@ func (a *CloudsAPIService) GetAllCloudResourcePools(ctx context.Context, cloudID client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &allCloudRPoolResp) + return json.Unmarshal(body, &AllCloudRPoolResp) }, validations: []validationFunc{ func() error { @@ -88,20 +86,19 @@ func (a *CloudsAPIService) GetAllCloudResourcePools(ctx context.Context, cloudID } err := allCloudRPoolAPI.do(ctx, nil, queryParams) - return allCloudRPoolResp, err + return AllCloudRPoolResp, err } /* CloudsAPIService Get All Clouds - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID */ func (a *CloudsAPIService) GetAllClouds(ctx context.Context, queryParams map[string]string) (models.CloudsResp, error) { - allCloudResp := models.CloudsResp{} + AllCloudResp := models.CloudsResp{} allCloudAPI := &api{ method: "GET", @@ -109,17 +106,17 @@ func (a *CloudsAPIService) GetAllClouds(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &allCloudResp) + return json.Unmarshal(body, &AllCloudResp) }, } err := allCloudAPI.do(ctx, nil, queryParams) - return allCloudResp, err + return AllCloudResp, err } func (a *CloudsAPIService) GetAllCloudNetworks(ctx context.Context, cloudID, provisionTypeID int) (models.GetAllCloudNetworks, error) { - allCloudNetworkResp := models.GetAllCloudNetworks{} + AllCloudNetworkResp := models.GetAllCloudNetworks{} allCloudNetworkAPI := &api{ method: "GET", @@ -128,7 +125,7 @@ func (a *CloudsAPIService) GetAllCloudNetworks(ctx context.Context, cloudID, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &allCloudNetworkResp) + return json.Unmarshal(body, &AllCloudNetworkResp) }, } queryParams := map[string]string{ @@ -137,7 +134,7 @@ func (a *CloudsAPIService) GetAllCloudNetworks(ctx context.Context, cloudID, } err := allCloudNetworkAPI.do(ctx, nil, queryParams) - return allCloudNetworkResp, err + return AllCloudNetworkResp, err } func (a *CloudsAPIService) GetAllCloudFolders( @@ -145,7 +142,7 @@ func (a *CloudsAPIService) GetAllCloudFolders( cloudID int, queryParams map[string]string, ) (models.GetAllCloudFolders, error) { - folders := models.GetAllCloudFolders{} + Folders := models.GetAllCloudFolders{} folderAPI := &api{ method: "GET", @@ -154,7 +151,7 @@ func (a *CloudsAPIService) GetAllCloudFolders( client: a.Client, // jsonParser also stores folder response, since folders is not a local variable jsonParser: func(body []byte) error { - return json.Unmarshal(body, &folders) + return json.Unmarshal(body, &Folders) }, // validate cloud id > 1 validations: []validationFunc{ @@ -170,7 +167,7 @@ func (a *CloudsAPIService) GetAllCloudFolders( err := folderAPI.do(ctx, nil, queryParams) - return folders, err + return Folders, err } func (a *CloudsAPIService) GetSpecificCloudFolder( @@ -178,7 +175,7 @@ func (a *CloudsAPIService) GetSpecificCloudFolder( cloudID int, folderID int, ) (models.GetSpecificCloudFolder, error) { - folder := models.GetSpecificCloudFolder{} + Folder := models.GetSpecificCloudFolder{} folderAPI := &api{ method: "GET", @@ -187,7 +184,7 @@ func (a *CloudsAPIService) GetSpecificCloudFolder( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &folder) + return json.Unmarshal(body, &Folder) }, // validate cloud id > 1 validations: []validationFunc{ @@ -203,14 +200,14 @@ func (a *CloudsAPIService) GetSpecificCloudFolder( err := folderAPI.do(ctx, nil, nil) - return folder, err + return Folder, err } func (a *CloudsAPIService) GetSpecificCloud( ctx context.Context, cloudID int, ) (models.GetSpecificCloud, error) { - folder := models.GetSpecificCloud{} + Folder := models.GetSpecificCloud{} folderAPI := &api{ method: "GET", @@ -219,19 +216,19 @@ func (a *CloudsAPIService) GetSpecificCloud( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &folder) + return json.Unmarshal(body, &Folder) }, } err := folderAPI.do(ctx, nil, nil) - return folder, err + return Folder, err } func (a *CloudsAPIService) GetSpecificCloudDataStores( ctx context.Context, cloudID, datastoreID int, ) (models.GetSpecificCloudDataStores, error) { - folder := models.GetSpecificCloudDataStores{} + Folder := models.GetSpecificCloudDataStores{} folderAPI := &api{ method: "GET", @@ -240,12 +237,12 @@ func (a *CloudsAPIService) GetSpecificCloudDataStores( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &folder) + return json.Unmarshal(body, &Folder) }, } err := folderAPI.do(ctx, nil, nil) - return folder, err + return Folder, err } func (a *CloudsAPIService) GetSpecificCloudResourcePool( @@ -253,7 +250,7 @@ func (a *CloudsAPIService) GetSpecificCloudResourcePool( cloudID int, resourcePoolID int, ) (models.GetSpecificCloudResourcePool, error) { - resp := models.GetSpecificCloudResourcePool{} + Resp := models.GetSpecificCloudResourcePool{} api := &api{ method: "GET", @@ -261,10 +258,10 @@ func (a *CloudsAPIService) GetSpecificCloudResourcePool( consts.ZonePath, cloudID, consts.ResourcePoolPath, resourcePoolID), client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := api.do(ctx, nil, nil) - return resp, err + return Resp, err } diff --git a/pkg/client/clouds_test.go b/pkg/client/clouds_test.go index e158037..71b2b0f 100644 --- a/pkg/client/clouds_test.go +++ b/pkg/client/clouds_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -44,7 +44,7 @@ func TestCloudsAPIService_GetAllCloudDataStores(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "datastores": [{ "id": 1, @@ -106,7 +106,7 @@ func TestCloudsAPIService_GetAllCloudDataStores(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -190,7 +190,7 @@ func TestCloudsAPIService_GetAllCloudResourcePools(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "resourcePools": [{ "id": 1, @@ -251,7 +251,7 @@ func TestCloudsAPIService_GetAllCloudResourcePools(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -332,7 +332,7 @@ func TestCloudsAPIService_GetAllClouds(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "zones": [{ "id": 1, @@ -391,7 +391,7 @@ func TestCloudsAPIService_GetAllClouds(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -462,7 +462,7 @@ func TestCloudsAPIService_GetAllCloudFolders(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "folders": [{ "id": 1, @@ -523,7 +523,7 @@ func TestCloudsAPIService_GetAllCloudFolders(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -591,7 +591,7 @@ func TestCloudsAPIService_GetAllCloudNetworks(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "data": { "networkTypes": [{ @@ -654,7 +654,7 @@ func TestCloudsAPIService_GetAllCloudNetworks(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -724,7 +724,7 @@ func TestCloudsAPIService_GetSpecificCloudFolder(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "folder": { "id": 1, @@ -775,7 +775,7 @@ func TestCloudsAPIService_GetSpecificCloudFolder(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/dhcp_server.go b/pkg/client/dhcp_server.go index 33e2b4b..dd5fe38 100644 --- a/pkg/client/dhcp_server.go +++ b/pkg/client/dhcp_server.go @@ -23,7 +23,7 @@ func (lb *DhcpServerAPIService) CreateDhcpServer( serverID int, request models.CreateNetworkDhcpServerRequest, ) (models.CreateNetworkDhcpServerResp, error) { - dhcpServerResp := models.CreateNetworkDhcpServerResp{} + DhcpServerResp := models.CreateNetworkDhcpServerResp{} dhcpServerAPI := &api{ compatibleVersion: dhcpCompatibleVersion, method: "POST", @@ -32,12 +32,12 @@ func (lb *DhcpServerAPIService) CreateDhcpServer( serverID, consts.DhcpServerPath), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &dhcpServerResp) + return json.Unmarshal(body, &DhcpServerResp) }, } err := dhcpServerAPI.do(ctx, request, nil) - return dhcpServerResp, err + return DhcpServerResp, err } func (lb *DhcpServerAPIService) UpdateDhcpServer( @@ -46,7 +46,7 @@ func (lb *DhcpServerAPIService) UpdateDhcpServer( dhcpID int, request models.CreateNetworkDhcpServerRequest, ) (models.CreateNetworkDhcpServerResp, error) { - dhcpServerResp := models.CreateNetworkDhcpServerResp{} + DhcpServerResp := models.CreateNetworkDhcpServerResp{} dhcpServerAPI := &api{ compatibleVersion: dhcpCompatibleVersion, method: "PUT", @@ -55,12 +55,12 @@ func (lb *DhcpServerAPIService) UpdateDhcpServer( serverID, consts.DhcpServerPath, dhcpID), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &dhcpServerResp) + return json.Unmarshal(body, &DhcpServerResp) }, } err := dhcpServerAPI.do(ctx, request, nil) - return dhcpServerResp, err + return DhcpServerResp, err } func (lb *DhcpServerAPIService) DeleteDhcpServer( @@ -68,7 +68,7 @@ func (lb *DhcpServerAPIService) DeleteDhcpServer( serverID int, dhcpID int, ) (models.SuccessOrErrorMessage, error) { - dhcpServerResp := models.SuccessOrErrorMessage{} + DhcpServerResp := models.SuccessOrErrorMessage{} dhcpServerAPI := &api{ compatibleVersion: dhcpCompatibleVersion, method: "DELETE", @@ -77,19 +77,19 @@ func (lb *DhcpServerAPIService) DeleteDhcpServer( serverID, consts.DhcpServerPath, dhcpID), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &dhcpServerResp) + return json.Unmarshal(body, &DhcpServerResp) }, } err := dhcpServerAPI.do(ctx, nil, nil) - return dhcpServerResp, err + return DhcpServerResp, err } func (lb *DhcpServerAPIService) GetDhcpServers( ctx context.Context, serverID int, ) (models.GetNetworkDhcpServers, error) { - dhcpServerResp := models.GetNetworkDhcpServers{} + DhcpServerResp := models.GetNetworkDhcpServers{} dhcpServerAPI := &api{ compatibleVersion: dhcpCompatibleVersion, method: "GET", @@ -98,12 +98,12 @@ func (lb *DhcpServerAPIService) GetDhcpServers( serverID, consts.DhcpServerPath), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &dhcpServerResp) + return json.Unmarshal(body, &DhcpServerResp) }, } err := dhcpServerAPI.do(ctx, nil, nil) - return dhcpServerResp, err + return DhcpServerResp, err } func (lb *DhcpServerAPIService) GetSpecificDhcpServer( @@ -111,7 +111,7 @@ func (lb *DhcpServerAPIService) GetSpecificDhcpServer( serverID int, dhcpID int, ) (models.GetSpecificNetworkDhcpServer, error) { - dhcpServerResp := models.GetSpecificNetworkDhcpServer{} + DhcpServerResp := models.GetSpecificNetworkDhcpServer{} dhcpServerAPI := &api{ compatibleVersion: dhcpCompatibleVersion, method: "GET", @@ -120,10 +120,10 @@ func (lb *DhcpServerAPIService) GetSpecificDhcpServer( serverID, consts.DhcpServerPath, dhcpID), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &dhcpServerResp) + return json.Unmarshal(body, &DhcpServerResp) }, } err := dhcpServerAPI.do(ctx, nil, nil) - return dhcpServerResp, err + return DhcpServerResp, err } diff --git a/pkg/client/dhcp_server_test.go b/pkg/client/dhcp_server_test.go index e2467d1..f58919a 100644 --- a/pkg/client/dhcp_server_test.go +++ b/pkg/client/dhcp_server_test.go @@ -3,7 +3,7 @@ package client import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -51,7 +51,7 @@ func Test_dhcpServerAPIService_CreateDhcpServer(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -124,7 +124,7 @@ func Test_dhcpServerAPIService_UpdateDhcpServer(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -180,7 +180,7 @@ func Test_dhcpServerAPIService_DeleteDhcpServer(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -246,7 +246,7 @@ func Test_dhcpServerAPIService_GetSpecificDhcpServer(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkDhcpServer":{ "id": 1, diff --git a/pkg/client/domain.go b/pkg/client/domain.go index 51d220c..b9c4e2c 100644 --- a/pkg/client/domain.go +++ b/pkg/client/domain.go @@ -20,7 +20,7 @@ func (d *DomainAPIService) GetAllDomains( ctx context.Context, param map[string]string, ) (models.GetAllDomains, error) { - var domainResp models.GetAllDomains + var DomainResp models.GetAllDomains networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%s", @@ -28,19 +28,19 @@ func (d *DomainAPIService) GetAllDomains( client: d.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &domainResp) + return json.Unmarshal(body, &DomainResp) }, } err := networkAPI.do(ctx, nil, param) - return domainResp, err + return DomainResp, err } func (d *DomainAPIService) GetSpecificDomain( ctx context.Context, domainID int, ) (models.GetSpecificDomain, error) { - var domainResp models.GetSpecificDomain + var DomainResp models.GetSpecificDomain networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%s/%d", @@ -48,10 +48,10 @@ func (d *DomainAPIService) GetSpecificDomain( client: d.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &domainResp) + return json.Unmarshal(body, &DomainResp) }, } err := networkAPI.do(ctx, nil, nil) - return domainResp, err + return DomainResp, err } diff --git a/pkg/client/domain_test.go b/pkg/client/domain_test.go index 8f53b2f..7b0b93c 100644 --- a/pkg/client/domain_test.go +++ b/pkg/client/domain_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -41,7 +41,7 @@ func TestDomainAPIService_GetAllDomains(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkDomains": [{ "id": 1, @@ -100,7 +100,7 @@ func TestDomainAPIService_GetAllDomains(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -168,7 +168,7 @@ func TestDomainAPIService_GetSpecificDomain(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkDomain": { "id": 1, @@ -217,7 +217,7 @@ func TestDomainAPIService_GetSpecificDomain(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/environment.go b/pkg/client/environment.go index cd5b018..740731d 100644 --- a/pkg/client/environment.go +++ b/pkg/client/environment.go @@ -18,7 +18,7 @@ type EnvironmentAPIService struct { func (e *EnvironmentAPIService) GetAllEnvironment(ctx context.Context, param map[string]string) (models.GetAllEnvironment, error) { - response := models.GetAllEnvironment{} + Response := models.GetAllEnvironment{} allEnvAPI := &api{ method: "GET", @@ -26,31 +26,31 @@ func (e *EnvironmentAPIService) GetAllEnvironment(ctx context.Context, client: e.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allEnvAPI.do(ctx, nil, param) - return response, err + return Response, err } func (e *EnvironmentAPIService) GetSpecificEnvironment( ctx context.Context, envID int, ) (models.GetSpecificEnvironment, error) { - response := models.GetSpecificEnvironment{} + Response := models.GetSpecificEnvironment{} allEnvAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%d", consts.EnvironmentPath, envID), client: e.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allEnvAPI.do(ctx, nil, nil) - return response, err + return Response, err } diff --git a/pkg/client/environment_test.go b/pkg/client/environment_test.go index 9df1a15..5db4da3 100644 --- a/pkg/client/environment_test.go +++ b/pkg/client/environment_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -42,7 +42,7 @@ func TestEnvironmentAPIService_GetAllEnvironment(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "environments": [{ "id": 1, @@ -100,7 +100,7 @@ func TestEnvironmentAPIService_GetAllEnvironment(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/groups.go b/pkg/client/groups.go index bedf21e..4eb44bb 100644 --- a/pkg/client/groups.go +++ b/pkg/client/groups.go @@ -19,15 +19,14 @@ type GroupsAPIService struct { /* GroupsAPIService Get a Specific Group - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - * @param groupID The Group ID - + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID + - @param groupID The Group ID */ func (a *GroupsAPIService) GetASpecificGroup(ctx context.Context, groupID int) (models.GroupResp, error) { - specificGrpResp := models.GroupResp{} + SpecificGrpResp := models.GroupResp{} specificGrpRespAPI := &api{ method: "GET", @@ -36,7 +35,7 @@ func (a *GroupsAPIService) GetASpecificGroup(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &specificGrpResp) + return json.Unmarshal(body, &SpecificGrpResp) }, validations: []validationFunc{ func() error { @@ -50,20 +49,19 @@ func (a *GroupsAPIService) GetASpecificGroup(ctx context.Context, } err := specificGrpRespAPI.do(ctx, nil, nil) - return specificGrpResp, err + return SpecificGrpResp, err } /* GroupsAPIService This endpoint retrieves all groups and a list of zones associated with the group by id. - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID */ func (a *GroupsAPIService) GetAllGroups(ctx context.Context, queryParams map[string]string) (models.Groups, error) { - allGrpResp := models.Groups{} + AllGrpResp := models.Groups{} allGrpRespAPI := &api{ method: "GET", @@ -71,10 +69,10 @@ func (a *GroupsAPIService) GetAllGroups(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &allGrpResp) + return json.Unmarshal(body, &AllGrpResp) }, } err := allGrpRespAPI.do(ctx, nil, queryParams) - return allGrpResp, err + return AllGrpResp, err } diff --git a/pkg/client/groups_test.go b/pkg/client/groups_test.go index a244772..2991eb6 100644 --- a/pkg/client/groups_test.go +++ b/pkg/client/groups_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -40,7 +40,7 @@ func TestGroupsAPIService_GetASpecificGroup(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "group": { "id": 1, @@ -89,7 +89,7 @@ func TestGroupsAPIService_GetASpecificGroup(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -158,7 +158,7 @@ func TestGroupsAPIService_GetAllGroups(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "groups": [{ "id": 1, @@ -217,7 +217,7 @@ func TestGroupsAPIService_GetAllGroups(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/instances.go b/pkg/client/instances.go index 8aac9f5..174d6ad 100644 --- a/pkg/client/instances.go +++ b/pkg/client/instances.go @@ -48,7 +48,7 @@ Create an Instance func (a *InstancesAPIService) CreateAnInstance(ctx context.Context, localVarOptionals *models.CreateInstanceBody) (models.GetInstanceResponse, error) { - createInstanceResp := models.GetInstanceResponse{} + CreateInstanceResp := models.GetInstanceResponse{} // Pre-pending 'pool-' to ResourcePoolId in 6.0.3 and above if v, _ := parseVersion("6.0.3"); v <= a.Client.getVersion() { @@ -68,13 +68,13 @@ func (a *InstancesAPIService) CreateAnInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &createInstanceResp) + return json.Unmarshal(body, &CreateInstanceResp) }, } err := createInstanceAPI.do(ctx, localVarOptionals, nil) - return createInstanceResp, err + return CreateInstanceResp, err } /* @@ -95,7 +95,7 @@ type InstancesAPIDeleteAnIstanceOpts struct { func (a *InstancesAPIService) DeleteAnInstance(ctx context.Context, instanceID int) (models.SuccessOrErrorMessage, error) { - delInstanceResp := models.SuccessOrErrorMessage{} + DelInstanceResp := models.SuccessOrErrorMessage{} delInstanceAPI := &api{ method: "DELETE", @@ -104,12 +104,12 @@ func (a *InstancesAPIService) DeleteAnInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &delInstanceResp) + return json.Unmarshal(body, &DelInstanceResp) }, } err := delInstanceAPI.do(ctx, nil, nil) - return delInstanceResp, err + return DelInstanceResp, err } /* @@ -124,7 +124,7 @@ Get a Specific Instance */ func (a *InstancesAPIService) GetASpecificInstance(ctx context.Context, instanceID int) (models.GetInstanceResponse, error) { - specificInstResp := models.GetInstanceResponse{} + SpecificInstResp := models.GetInstanceResponse{} specificInstanceAPI := &api{ method: "GET", @@ -133,12 +133,12 @@ func (a *InstancesAPIService) GetASpecificInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &specificInstResp) + return json.Unmarshal(body, &SpecificInstResp) }, } err := specificInstanceAPI.do(ctx, nil, nil) - return specificInstResp, err + return SpecificInstResp, err } /* @@ -151,7 +151,7 @@ Get All Instances func (a *InstancesAPIService) GetAllInstances(ctx context.Context, queryParams map[string]string) (models.Instances, error) { - getAllInstance := models.Instances{} + GetAllInstance := models.Instances{} instanceAPI := &api{ method: "GET", @@ -159,12 +159,12 @@ func (a *InstancesAPIService) GetAllInstances(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &getAllInstance) + return json.Unmarshal(body, &GetAllInstance) }, } err := instanceAPI.do(ctx, nil, queryParams) - return getAllInstance, err + return GetAllInstance, err } /* @@ -177,7 +177,7 @@ Lists VMware Snapshot of the instance */ func (a *InstancesAPIService) GetListOfSnapshotsForAnInstance(ctx context.Context, instanceID int) (models.ListSnapshotResponse, error) { - listSnapshotResp := models.ListSnapshotResponse{} + ListSnapshotResp := models.ListSnapshotResponse{} listSnapshotAPI := &api{ method: "GET", @@ -186,12 +186,12 @@ func (a *InstancesAPIService) GetListOfSnapshotsForAnInstance(ctx context.Contex client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &listSnapshotResp) + return json.Unmarshal(body, &ListSnapshotResp) }, } err := listSnapshotAPI.do(ctx, nil, nil) - return listSnapshotResp, err + return ListSnapshotResp, err } /* @@ -209,7 +209,7 @@ it currently exists. func (a *InstancesAPIService) ImportSnapshotOfAnInstance(ctx context.Context, instanceID int, localVarOptionals *models.ImportSnapshotBody) (models.SuccessOrErrorMessage, error) { - importSnapshotResp := models.SuccessOrErrorMessage{} + ImportSnapshotResp := models.SuccessOrErrorMessage{} importSnapshotAPI := &api{ method: "PUT", @@ -218,12 +218,12 @@ func (a *InstancesAPIService) ImportSnapshotOfAnInstance(ctx context.Context, in client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &importSnapshotResp) + return json.Unmarshal(body, &ImportSnapshotResp) }, } err := importSnapshotAPI.do(ctx, localVarOptionals, nil) - return importSnapshotResp, err + return ImportSnapshotResp, err } /* @@ -236,7 +236,7 @@ Restarts all VM running within an instance */ func (a *InstancesAPIService) RestartAnInstance(ctx context.Context, instanceID int) (models.InstancePowerResponse, error) { - restartInstResp := models.InstancePowerResponse{} + RestartInstResp := models.InstancePowerResponse{} restartInstAPI := &api{ method: "PUT", @@ -245,12 +245,12 @@ func (a *InstancesAPIService) RestartAnInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &restartInstResp) + return json.Unmarshal(body, &RestartInstResp) }, } err := restartInstAPI.do(ctx, nil, nil) - return restartInstResp, err + return RestartInstResp, err } /* @@ -267,7 +267,7 @@ Creates VMware Snapshot of the instance func (a *InstancesAPIService) SnapshotAnInstance(ctx context.Context, instanceID int, localVarOptionals *models.SnapshotBody) (models.Instances, error) { - snapshotInstResp := models.Instances{} + SnapshotInstResp := models.Instances{} instanceAPI := &api{ method: "PUT", @@ -276,12 +276,12 @@ func (a *InstancesAPIService) SnapshotAnInstance(ctx context.Context, instanceID client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &snapshotInstResp) + return json.Unmarshal(body, &SnapshotInstResp) }, } err := instanceAPI.do(ctx, localVarOptionals, nil) - return snapshotInstResp, err + return SnapshotInstResp, err } /* @@ -294,7 +294,7 @@ Starts all VM running within an instance */ func (a *InstancesAPIService) StartAnInstance(ctx context.Context, instanceID int) (models.InstancePowerResponse, error) { - startInstanceResp := models.InstancePowerResponse{} + StartInstanceResp := models.InstancePowerResponse{} startInstanceAPI := &api{ method: "PUT", @@ -303,12 +303,12 @@ func (a *InstancesAPIService) StartAnInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &startInstanceResp) + return json.Unmarshal(body, &StartInstanceResp) }, } err := startInstanceAPI.do(ctx, nil, nil) - return startInstanceResp, err + return StartInstanceResp, err } /* @@ -321,7 +321,7 @@ Stops all VM running within an instance */ func (a *InstancesAPIService) StopAnInstance(ctx context.Context, instanceID int) (models.InstancePowerResponse, error) { - stopInstanceResp := models.InstancePowerResponse{} + StopInstanceResp := models.InstancePowerResponse{} stopInstanceAPI := &api{ method: "PUT", @@ -330,12 +330,12 @@ func (a *InstancesAPIService) StopAnInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &stopInstanceResp) + return json.Unmarshal(body, &StopInstanceResp) }, } err := stopInstanceAPI.do(ctx, nil, nil) - return stopInstanceResp, err + return StopInstanceResp, err } /* @@ -348,7 +348,7 @@ Suspends all VM running within an instance */ func (a *InstancesAPIService) SuspendAnInstance(ctx context.Context, instanceID int) (models.InstancePowerResponse, error) { - suspendResp := models.InstancePowerResponse{} + SuspendResp := models.InstancePowerResponse{} suspendInstanceAPI := &api{ method: "PUT", path: fmt.Sprintf("%s/%d/suspend", @@ -356,17 +356,17 @@ func (a *InstancesAPIService) SuspendAnInstance(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &suspendResp) + return json.Unmarshal(body, &SuspendResp) }, } err := suspendInstanceAPI.do(ctx, nil, nil) - return suspendResp, err + return SuspendResp, err } func (a *InstancesAPIService) ResizeAnInstance(ctx context.Context, instanceID int, request *models.ResizeInstanceBody) (models.ResizeInstanceResponse, error) { - resizeResp := models.ResizeInstanceResponse{} + ResizeResp := models.ResizeInstanceResponse{} instanceAPI := &api{ method: "PUT", @@ -375,12 +375,12 @@ func (a *InstancesAPIService) ResizeAnInstance(ctx context.Context, instanceID i client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resizeResp) + return json.Unmarshal(body, &ResizeResp) }, } err := instanceAPI.do(ctx, request, nil) - return resizeResp, err + return ResizeResp, err } func (a *InstancesAPIService) UpdatingAnInstance( @@ -388,7 +388,7 @@ func (a *InstancesAPIService) UpdatingAnInstance( instanceID int, request *models.UpdateInstanceBody, ) (models.UpdateInstanceResponse, error) { - instance := models.UpdateInstanceResponse{} + Instance := models.UpdateInstanceResponse{} instanceAPI := &api{ method: "PUT", @@ -397,17 +397,17 @@ func (a *InstancesAPIService) UpdatingAnInstance( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &instance) + return json.Unmarshal(body, &Instance) }, } err := instanceAPI.do(ctx, request, nil) - return instance, err + return Instance, err } func (a *InstancesAPIService) GetInstanceHistory( ctx context.Context, instanceID int) (models.GetInstanceHistory, error) { - history := models.GetInstanceHistory{} + History := models.GetInstanceHistory{} historyAPI := &api{ method: "GET", @@ -416,17 +416,17 @@ func (a *InstancesAPIService) GetInstanceHistory( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &history) + return json.Unmarshal(body, &History) }, } err := historyAPI.do(ctx, nil, nil) - return history, err + return History, err } func (a *InstancesAPIService) CloneAnInstance(ctx context.Context, instanceID int, cloneRequest models.CreateInstanceCloneBody) (models.SuccessOrErrorMessage, error) { - var cloneResp models.SuccessOrErrorMessage + var CloneResp models.SuccessOrErrorMessage if v, _ := parseVersion("5.2.12"); v <= a.Client.getVersion() { cloneRequest.Tags = cloneRequest.Metadata cloneRequest.Metadata = nil @@ -440,10 +440,10 @@ func (a *InstancesAPIService) CloneAnInstance(ctx context.Context, instanceID in client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &cloneResp) + return json.Unmarshal(body, &CloneResp) }, } err := instanceClone.do(ctx, cloneRequest, nil) - return cloneResp, err + return CloneResp, err } diff --git a/pkg/client/instances_test.go b/pkg/client/instances_test.go index 7b88bf5..9d579d3 100644 --- a/pkg/client/instances_test.go +++ b/pkg/client/instances_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -43,7 +43,7 @@ func TestInstancesAPIService_CloneAnInstance(t *testing.T) { method := "PUT" // headers := getDefaultHeaders() headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "cloud": { "ID": 1 @@ -52,7 +52,7 @@ func TestInstancesAPIService_CloneAnInstance(t *testing.T) { } `))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "message": "Successfully cloned an instance" @@ -120,7 +120,7 @@ func TestInstancesAPIService_CloneAnInstance(t *testing.T) { // headers := getDefaultHeaders() headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "cloud": { "ID": 1 @@ -129,7 +129,7 @@ func TestInstancesAPIService_CloneAnInstance(t *testing.T) { } `))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -202,14 +202,14 @@ func TestInstancesAPIService_CreateAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances" method := "POST" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "zoneId": "1", "name": "Instance_Create" } `))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "instance": { "id": 1, @@ -250,14 +250,14 @@ func TestInstancesAPIService_CreateAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances" method := "POST" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "zoneId": "1", "name": "Instance_Create" } `))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "instance": { "id": 1, @@ -321,14 +321,14 @@ func TestInstancesAPIService_CreateAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances" method := "POST" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "zoneId": "1", "name": "Instance_Create" } `))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -396,7 +396,7 @@ func TestInstancesAPIService_DeleteAnInstance(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "message": "Successfully Deleted the instance" @@ -441,7 +441,7 @@ func TestInstancesAPIService_DeleteAnInstance(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -507,11 +507,11 @@ func TestInstancesAPIService_ImportSnapshotOfAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1/import-snapshot" method := "PUT" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + postBody := io.NopCloser(bytes.NewReader([]byte(`{ "storageProviderId" : 1 }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "message": "Successfully imported a snapshot of an instance" @@ -566,11 +566,11 @@ func TestInstancesAPIService_ImportSnapshotOfAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1/import-snapshot" method := "PUT" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + postBody := io.NopCloser(bytes.NewReader([]byte(`{ "storageProviderId" : 1 }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -646,14 +646,14 @@ func TestInstancesAPIService_ResizeAnInstance(t *testing.T) { m.EXPECT().getHost().Return(mockHost) path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1/resize" method := "PUT" - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "instance" : {"id": 1}, "volumes" : [{"id": 1, "name": "test_instance_volume" }], "deleteOriginalVolumes" : false }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + respBody := io.NopCloser(bytes.NewReader([]byte(`{ "instance": { "id": 1, "string": "test_instance_response" @@ -736,14 +736,14 @@ func TestInstancesAPIService_ResizeAnInstance(t *testing.T) { m.EXPECT().getHost().Return(mockHost) path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1/resize" method := "PUT" - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "instance" : {"id": 1}, "volumes" : [{"id": 1, "name": "test_instance_volume" }], "deleteOriginalVolumes" : false }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -821,7 +821,7 @@ func TestInstancesAPIService_SnapshotAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1/snapshot" method := "PUT" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "snapshot": { "name": "test_snapshot_name", @@ -829,7 +829,7 @@ func TestInstancesAPIService_SnapshotAnInstance(t *testing.T) { } }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + respBody := io.NopCloser(bytes.NewReader([]byte(`{ "instances": [{ "id": 1, "name": "test_snapshot_name" @@ -900,7 +900,7 @@ func TestInstancesAPIService_SnapshotAnInstance(t *testing.T) { path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1/snapshot" method := "PUT" headers := getDefaultHeaders() - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "snapshot": { "name": "test_snapshot_name", @@ -908,7 +908,7 @@ func TestInstancesAPIService_SnapshotAnInstance(t *testing.T) { } }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -982,7 +982,7 @@ func TestInstancesAPIService_UpdatingAnInstance(t *testing.T) { m.EXPECT().getHost().Return(mockHost) path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1" method := "PUT" - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "snapshot": { "name": "test_update_instance_name", @@ -990,7 +990,7 @@ func TestInstancesAPIService_UpdatingAnInstance(t *testing.T) { } }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + respBody := io.NopCloser(bytes.NewReader([]byte(`{ "instance": { "id": 1, "name": "test_update_instance_name" @@ -1058,7 +1058,7 @@ func TestInstancesAPIService_UpdatingAnInstance(t *testing.T) { m.EXPECT().getHost().Return(mockHost) path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/instances/1" method := "PUT" - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "snapshot": { "name": "test_update_instance_name", @@ -1066,7 +1066,7 @@ func TestInstancesAPIService_UpdatingAnInstance(t *testing.T) { } }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + respBody := io.NopCloser(bytes.NewReader([]byte(`{ { "message": "Internal Server Error", "recommendedActions": [ @@ -1135,7 +1135,7 @@ func TestInstancesAPIService_GetASpecificInstance(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "instance": { "id": 1, @@ -1186,7 +1186,7 @@ func TestInstancesAPIService_GetASpecificInstance(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1255,7 +1255,7 @@ func TestInstancesAPIService_GetAllInstances(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "instances": [{ "id": 1, @@ -1316,7 +1316,7 @@ func TestInstancesAPIService_GetAllInstances(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1383,7 +1383,7 @@ func TestInstancesAPIService_GetListOfSnapshotsForAnInstance(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "snapshots": [{ "id": 1, @@ -1434,7 +1434,7 @@ func TestInstancesAPIService_GetListOfSnapshotsForAnInstance(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1499,7 +1499,7 @@ func TestInstancesAPIService_GetInstanceHistory(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "processes": [ { @@ -1566,7 +1566,7 @@ func TestInstancesAPIService_GetInstanceHistory(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1632,7 +1632,7 @@ func TestInstancesAPIService_RestartAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1675,7 +1675,7 @@ func TestInstancesAPIService_RestartAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1738,7 +1738,7 @@ func TestInstancesAPIService_StartAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1781,7 +1781,7 @@ func TestInstancesAPIService_StartAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1844,7 +1844,7 @@ func TestInstancesAPIService_StopAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1887,7 +1887,7 @@ func TestInstancesAPIService_StopAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -1950,7 +1950,7 @@ func TestInstancesAPIService_SuspendAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1993,7 +1993,7 @@ func TestInstancesAPIService_SuspendAnInstance(t *testing.T) { method := "PUT" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/library.go b/pkg/client/library.go index fc0aac9..27027a0 100644 --- a/pkg/client/library.go +++ b/pkg/client/library.go @@ -19,14 +19,13 @@ type LibraryAPIService struct { /* LibrariesAPIService Get All layouts - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID */ func (a *LibraryAPIService) GetAllLayouts(ctx context.Context, param map[string]string) (models.LayoutsResp, error) { - response := models.LayoutsResp{} + Response := models.LayoutsResp{} allLayoutsAPI := &api{ method: "GET", @@ -34,17 +33,17 @@ func (a *LibraryAPIService) GetAllLayouts(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allLayoutsAPI.do(ctx, nil, param) - return response, err + return Response, err } func (a *LibraryAPIService) GetAllInstanceTypes(ctx context.Context, param map[string]string) (models.InstanceTypesResp, error) { - response := models.InstanceTypesResp{} + Response := models.InstanceTypesResp{} allInstTypeAPI := &api{ method: "GET", @@ -52,19 +51,19 @@ func (a *LibraryAPIService) GetAllInstanceTypes(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allInstTypeAPI.do(ctx, nil, param) - return response, err + return Response, err } func (a *LibraryAPIService) GetSpecificLayout( ctx context.Context, layoutID int, ) (models.GetSpecificLayout, error) { - response := models.GetSpecificLayout{} + Response := models.GetSpecificLayout{} allLayoutsAPI := &api{ method: "GET", @@ -72,10 +71,10 @@ func (a *LibraryAPIService) GetSpecificLayout( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allLayoutsAPI.do(ctx, nil, nil) - return response, err + return Response, err } diff --git a/pkg/client/library_test.go b/pkg/client/library_test.go index e7d6880..17338c6 100644 --- a/pkg/client/library_test.go +++ b/pkg/client/library_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -42,7 +42,7 @@ func TestLibraryAPIService_GetAllLayouts(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "instanceTypeLayouts": [{ "id": 1, @@ -102,7 +102,7 @@ func TestLibraryAPIService_GetAllLayouts(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -174,7 +174,7 @@ func TestLibraryAPIService_GetAllInstanceTypes(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "instanceTypes": [{ "id": 1, @@ -233,7 +233,7 @@ func TestLibraryAPIService_GetAllInstanceTypes(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/load_balancer.go b/pkg/client/load_balancer.go index 290e4ad..3b09800 100644 --- a/pkg/client/load_balancer.go +++ b/pkg/client/load_balancer.go @@ -20,18 +20,18 @@ func (lb *LoadBalancerAPIService) CreateLoadBalancer( ctx context.Context, request models.CreateLoadBalancerRequest, ) (models.CreateNetworkLoadBalancerResp, error) { - loadBalancerResp := models.CreateNetworkLoadBalancerResp{} + LoadBalancerResp := models.CreateNetworkLoadBalancerResp{} loadBalancerAPI := &api{ method: "POST", path: consts.LoadBalancerPath, client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &loadBalancerResp) + return json.Unmarshal(body, &LoadBalancerResp) }, } err := loadBalancerAPI.do(ctx, request, nil) - return loadBalancerResp, err + return LoadBalancerResp, err } func (lb *LoadBalancerAPIService) UpdateLoadBalancer( @@ -39,91 +39,91 @@ func (lb *LoadBalancerAPIService) UpdateLoadBalancer( lbID int, request models.CreateLoadBalancerRequest, ) (models.CreateNetworkLoadBalancerResp, error) { - loadBalancerResp := models.CreateNetworkLoadBalancerResp{} + LoadBalancerResp := models.CreateNetworkLoadBalancerResp{} loadBalancerAPI := &api{ method: "PUT", path: fmt.Sprintf("%s/%d", consts.LoadBalancerPath, lbID), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &loadBalancerResp) + return json.Unmarshal(body, &LoadBalancerResp) }, } err := loadBalancerAPI.do(ctx, request, nil) - return loadBalancerResp, err + return LoadBalancerResp, err } func (lb *LoadBalancerAPIService) DeleteLoadBalancer( ctx context.Context, lbID int, ) (models.SuccessOrErrorMessage, error) { - loadBalancerResp := models.SuccessOrErrorMessage{} + LoadBalancerResp := models.SuccessOrErrorMessage{} loadBalancerAPI := &api{ method: "DELETE", path: fmt.Sprintf("%s/%d", consts.LoadBalancerPath, lbID), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &loadBalancerResp) + return json.Unmarshal(body, &LoadBalancerResp) }, } err := loadBalancerAPI.do(ctx, nil, nil) - return loadBalancerResp, err + return LoadBalancerResp, err } func (lb *LoadBalancerAPIService) GetLoadBalancers( ctx context.Context, ) (models.GetNetworkLoadBalancers, error) { - loadBalancerResp := models.GetNetworkLoadBalancers{} + LoadBalancerResp := models.GetNetworkLoadBalancers{} loadBalancerAPI := &api{ method: "GET", path: consts.LoadBalancerPath, client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &loadBalancerResp) + return json.Unmarshal(body, &LoadBalancerResp) }, } err := loadBalancerAPI.do(ctx, nil, nil) - return loadBalancerResp, err + return LoadBalancerResp, err } func (lb *LoadBalancerAPIService) GetLoadBalancerTypes( ctx context.Context, queryParams map[string]string, ) (models.GetLoadBalancerTypes, error) { - loadBalancerResp := models.GetLoadBalancerTypes{} + LoadBalancerResp := models.GetLoadBalancerTypes{} loadBalancerAPI := &api{ method: "GET", path: consts.LoadBalancerTypePath, client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &loadBalancerResp) + return json.Unmarshal(body, &LoadBalancerResp) }, } err := loadBalancerAPI.do(ctx, nil, nil) - return loadBalancerResp, err + return LoadBalancerResp, err } func (lb *LoadBalancerAPIService) GetSpecificLoadBalancers( ctx context.Context, lbID int, ) (models.GetSpecificNetworkLoadBalancer, error) { - loadBalancerResp := models.GetSpecificNetworkLoadBalancer{} + LoadBalancerResp := models.GetSpecificNetworkLoadBalancer{} loadBalancerAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%d", consts.LoadBalancerPath, lbID), client: lb.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &loadBalancerResp) + return json.Unmarshal(body, &LoadBalancerResp) }, } err := loadBalancerAPI.do(ctx, nil, nil) - return loadBalancerResp, err + return LoadBalancerResp, err } func (lb *LoadBalancerAPIService) CreateLBMonitor( diff --git a/pkg/client/load_balancer_test.go b/pkg/client/load_balancer_test.go index 69ade53..ae2ba26 100644 --- a/pkg/client/load_balancer_test.go +++ b/pkg/client/load_balancer_test.go @@ -3,7 +3,7 @@ package client import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -51,7 +51,7 @@ func Test_loadBalancerAPIService_CreateLoadBalancer(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -125,7 +125,7 @@ func Test_loadBalancerAPIService_UpdateLoadBalancer(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -182,7 +182,7 @@ func Test_loadBalancerAPIService_DeleteLoadBalancer(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -248,7 +248,7 @@ func Test_loadBalancerAPIService_GetSpecificLoadBalancers(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "loadBalancer":{ "id": 1, @@ -333,7 +333,7 @@ func Test_loadBalancerAPIService_CreateLBMonitor(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -407,7 +407,7 @@ func Test_loadBalancerAPIService_UpdateLBMonitor(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -464,7 +464,7 @@ func Test_loadBalancerAPIService_DeleteLBMonitor(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -529,7 +529,7 @@ func Test_loadBalancerAPIService_GetSpecificLBMonitor(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "loadBalancerMonitor":{ "name":"test_template_get_a_specific_LB" @@ -612,7 +612,7 @@ func Test_loadBalancerAPIService_CreateLBProfile(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -686,7 +686,7 @@ func Test_loadBalancerAPIService_UpdateLBProfile(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -743,7 +743,7 @@ func Test_loadBalancerAPIService_DeleteLBProfile(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -809,7 +809,7 @@ func Test_loadBalancerAPIService_GetSpecificLBProfile(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "loadBalancerProfile":{ "id": 1, @@ -894,7 +894,7 @@ func Test_loadBalancerAPIService_CreateLBPool(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -968,7 +968,7 @@ func Test_loadBalancerAPIService_UpdateLBPool(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1025,7 +1025,7 @@ func Test_loadBalancerAPIService_DeleteLBPool(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1091,7 +1091,7 @@ func Test_loadBalancerAPIService_GetSpecificLBPool(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "loadBalancerPool":{ "id": 1, @@ -1176,7 +1176,7 @@ func Test_loadBalancerAPIService_CreateLBVirtualServers(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1250,7 +1250,7 @@ func Test_loadBalancerAPIService_UpdateLBVirtualServers(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1306,7 +1306,7 @@ func Test_loadBalancerAPIService_DeleteLBVirtualServers(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1372,7 +1372,7 @@ func Test_loadBalancerAPIService_GetSpecificLBVirtualServers(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "loadBalancerInstance":{ "id": 1, diff --git a/pkg/client/networks.go b/pkg/client/networks.go index 550a4a0..8fc519f 100644 --- a/pkg/client/networks.go +++ b/pkg/client/networks.go @@ -22,45 +22,45 @@ func (n *NetworksAPIService) GetAllNetworks( ctx context.Context, param map[string]string, ) (models.ListNetworksBody, error) { - var networksResp models.ListNetworksBody + var NetworksResp models.ListNetworksBody networkAPI := &api{ method: "GET", path: consts.NetworksPath, client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &networksResp) + return json.Unmarshal(body, &NetworksResp) }, } err := networkAPI.do(ctx, nil, param) - return networksResp, err + return NetworksResp, err } func (n *NetworksAPIService) GetSpecificNetwork( ctx context.Context, networkID int, ) (models.GetSpecificNetworkBody, error) { - var networksResp models.GetSpecificNetworkBody + var NetworksResp models.GetSpecificNetworkBody networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%d", consts.NetworksPath, networkID), client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &networksResp) + return json.Unmarshal(body, &NetworksResp) }, } err := networkAPI.do(ctx, nil, nil) - return networksResp, err + return NetworksResp, err } func (n *NetworksAPIService) CreateNetwork( ctx context.Context, networkReq models.CreateNetworkRequest, ) (models.CreateNetworkResponse, error) { - var networksResp models.CreateNetworkResponse + var NetworksResp models.CreateNetworkResponse if v, _ := parseVersion("5.4.4"); v <= n.Client.getVersion() { // network Pool is not required for DHCP if networkReq.Network.NetworkPool != nil { @@ -75,19 +75,19 @@ func (n *NetworksAPIService) CreateNetwork( client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &networksResp) + return json.Unmarshal(body, &NetworksResp) }, } err := networkAPI.do(ctx, networkReq, nil) - return networksResp, err + return NetworksResp, err } func (n *NetworksAPIService) DeleteNetwork( ctx context.Context, networkID int, ) (models.SuccessOrErrorMessage, error) { - var output models.SuccessOrErrorMessage + var Output models.SuccessOrErrorMessage networkAPI := &api{ compatibleVersion: networkCompatibleVersion, method: "DELETE", @@ -95,19 +95,19 @@ func (n *NetworksAPIService) DeleteNetwork( client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &output) + return json.Unmarshal(body, &Output) }, } err := networkAPI.do(ctx, nil, nil) - return output, err + return Output, err } func (n *NetworksAPIService) GetNetworkType( ctx context.Context, params map[string]string, ) (models.GetNetworkTypesResponse, error) { - var resp models.GetNetworkTypesResponse + var Resp models.GetNetworkTypesResponse networkAPI := &api{ compatibleVersion: networkCompatibleVersion, method: "GET", @@ -115,38 +115,38 @@ func (n *NetworksAPIService) GetNetworkType( client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := networkAPI.do(ctx, nil, params) - return resp, err + return Resp, err } func (n *NetworksAPIService) GetNetworkPool( ctx context.Context, params map[string]string, ) (models.GetNetworkPoolsResp, error) { - var resp models.GetNetworkPoolsResp + var Resp models.GetNetworkPoolsResp networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%s", consts.NetworksPath, consts.NetworkPoolPath), client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := networkAPI.do(ctx, nil, params) - return resp, err + return Resp, err } func (n *NetworksAPIService) GetSpecificNetworkPool( ctx context.Context, networkPoolID int, ) (models.GetSpecificNetworkPool, error) { - var resp models.GetSpecificNetworkPool + var Resp models.GetSpecificNetworkPool networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%s/%d", @@ -154,12 +154,12 @@ func (n *NetworksAPIService) GetSpecificNetworkPool( client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := networkAPI.do(ctx, nil, nil) - return resp, err + return Resp, err } func (n *NetworksAPIService) UpdateNetwork( @@ -167,7 +167,7 @@ func (n *NetworksAPIService) UpdateNetwork( networkID int, request models.CreateNetworkRequest, ) (models.SuccessOrErrorMessage, error) { - var output models.SuccessOrErrorMessage + var Output models.SuccessOrErrorMessage networkAPI := &api{ compatibleVersion: "5.2.13", method: "PUT", @@ -175,57 +175,57 @@ func (n *NetworksAPIService) UpdateNetwork( client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &output) + return json.Unmarshal(body, &Output) }, } err := networkAPI.do(ctx, request, nil) - return output, err + return Output, err } func (n *NetworksAPIService) GetNetworkProxy( ctx context.Context, params map[string]string, ) (models.GetAllNetworkProxies, error) { - var proxyResp models.GetAllNetworkProxies + var ProxyResp models.GetAllNetworkProxies networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%s", consts.NetworksPath, consts.NetworkProxyPath), client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &proxyResp) + return json.Unmarshal(body, &ProxyResp) }, } err := networkAPI.do(ctx, nil, params) - return proxyResp, err + return ProxyResp, err } func (n *NetworksAPIService) GetSpecificNetworkProxy( ctx context.Context, proxyID int, ) (models.GetSpecificNetworkProxy, error) { - var proxyResp models.GetSpecificNetworkProxy + var ProxyResp models.GetSpecificNetworkProxy networkAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%s/%d", consts.NetworksPath, consts.NetworkProxyPath, proxyID), client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &proxyResp) + return json.Unmarshal(body, &ProxyResp) }, } err := networkAPI.do(ctx, nil, nil) - return proxyResp, err + return ProxyResp, err } func (n *NetworksAPIService) GetSpecificNetworkType( ctx context.Context, typeID int, ) (models.GetaNetworkType, error) { - var resp models.GetaNetworkType + var Resp models.GetaNetworkType networkAPI := &api{ compatibleVersion: networkCompatibleVersion, method: "GET", @@ -233,10 +233,10 @@ func (n *NetworksAPIService) GetSpecificNetworkType( client: n.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := networkAPI.do(ctx, nil, nil) - return resp, err + return Resp, err } diff --git a/pkg/client/networks_test.go b/pkg/client/networks_test.go index 0991ac8..35ba3ee 100644 --- a/pkg/client/networks_test.go +++ b/pkg/client/networks_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -42,7 +42,7 @@ func TestNetworksAPIService_GetAllNetworks(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networks": [{ "id": 1, @@ -103,7 +103,7 @@ func TestNetworksAPIService_GetAllNetworks(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -184,7 +184,7 @@ func TestNetworksAPIService_CreateNetwork(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "Success": true, "network": { @@ -271,7 +271,7 @@ func TestNetworksAPIService_UpdateNetwork(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "Success": true } @@ -327,7 +327,7 @@ func TestNetworksAPIService_GetNetworkProxy(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkProxies": [ { @@ -403,7 +403,7 @@ func TestNetworksAPIService_GetSpecificNetwork(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "network": { "id": 1, @@ -452,7 +452,7 @@ func TestNetworksAPIService_GetSpecificNetwork(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -518,7 +518,7 @@ func TestNetworksAPIService_DeleteNetwork(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "message": "test_template_delete_network" @@ -563,7 +563,7 @@ func TestNetworksAPIService_DeleteNetwork(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -632,7 +632,7 @@ func TestNetworksAPIService_GetNetworkType(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkTypes": [{ "id": 1, @@ -691,7 +691,7 @@ func TestNetworksAPIService_GetNetworkType(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -762,7 +762,7 @@ func TestNetworksAPIService_GetNetworkPool(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkPools": [{ "id": 1, @@ -821,7 +821,7 @@ func TestNetworksAPIService_GetNetworkPool(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -889,7 +889,7 @@ func TestNetworksAPIService_GetSpecificNetworkPool(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkPool": { "id": 1, @@ -938,7 +938,7 @@ func TestNetworksAPIService_GetSpecificNetworkPool(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/plans.go b/pkg/client/plans.go index 41dce2e..39dd5c3 100644 --- a/pkg/client/plans.go +++ b/pkg/client/plans.go @@ -19,13 +19,13 @@ type PlansAPIService struct { /* PlansAPIService Get All Service Plans - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID */ func (a *PlansAPIService) GetAllServicePlans(ctx context.Context, param map[string]string) (models.ServicePlans, error) { - response := models.ServicePlans{} + Response := models.ServicePlans{} allServicePlansAPI := &api{ method: "GET", @@ -33,19 +33,19 @@ func (a *PlansAPIService) GetAllServicePlans(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allServicePlansAPI.do(ctx, nil, param) - return response, err + return Response, err } func (a *PlansAPIService) GetSpecificServicePlan( ctx context.Context, planID int, ) (models.GetSpecificServicePlan, error) { - response := models.GetSpecificServicePlan{} + Response := models.GetSpecificServicePlan{} allServicePlansAPI := &api{ method: "GET", @@ -53,10 +53,10 @@ func (a *PlansAPIService) GetSpecificServicePlan( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allServicePlansAPI.do(ctx, nil, nil) - return response, err + return Response, err } diff --git a/pkg/client/plans_test.go b/pkg/client/plans_test.go index 40623b6..f2d3606 100644 --- a/pkg/client/plans_test.go +++ b/pkg/client/plans_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -42,7 +42,7 @@ func TestPlansAPIService_GetAllServicePlans(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "servicePlans": [{ "id": 1, @@ -102,7 +102,7 @@ func TestPlansAPIService_GetAllServicePlans(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/power_schedule.go b/pkg/client/power_schedule.go index a3705d1..ebcdb64 100644 --- a/pkg/client/power_schedule.go +++ b/pkg/client/power_schedule.go @@ -19,15 +19,16 @@ type PowerSchedulesAPIService struct { /* VirtualImageApiService Get All Virtual images - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - * @param name/phrase optional + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID + - @param name/phrase optional + @return models.VirtualImages */ func (a *PowerSchedulesAPIService) GetAllPowerSchedules(ctx context.Context, param map[string]string) (models.GetAllPowerSchedules, error) { - response := models.GetAllPowerSchedules{} + Response := models.GetAllPowerSchedules{} allPowerScheduleAPI := &api{ method: "GET", @@ -35,19 +36,19 @@ func (a *PowerSchedulesAPIService) GetAllPowerSchedules(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allPowerScheduleAPI.do(ctx, nil, param) - return response, err + return Response, err } func (a *PowerSchedulesAPIService) GetSpecificPowerSchedule( ctx context.Context, powerID int, ) (models.GetSpecificPowerSchedule, error) { - response := models.GetSpecificPowerSchedule{} + Response := models.GetSpecificPowerSchedule{} allPowerScheduleAPI := &api{ method: "GET", @@ -55,10 +56,10 @@ func (a *PowerSchedulesAPIService) GetSpecificPowerSchedule( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allPowerScheduleAPI.do(ctx, nil, nil) - return response, err + return Response, err } diff --git a/pkg/client/power_schedule_test.go b/pkg/client/power_schedule_test.go index 524dc3d..5706108 100644 --- a/pkg/client/power_schedule_test.go +++ b/pkg/client/power_schedule_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -42,7 +42,7 @@ func TestPowerSchedulesAPIService_GetAllPowerSchedules(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "schedules": [{ "id": 1, @@ -101,7 +101,7 @@ func TestPowerSchedulesAPIService_GetAllPowerSchedules(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/provisioning.go b/pkg/client/provisioning.go index 7ae10da..c674551 100644 --- a/pkg/client/provisioning.go +++ b/pkg/client/provisioning.go @@ -17,7 +17,7 @@ type ProvisioningAPIService struct { func (a *ProvisioningAPIService) GetAllProvisioningTypes(ctx context.Context, param map[string]string) (models.GetAllProvisioningTypes, error) { - response := models.GetAllProvisioningTypes{} + Response := models.GetAllProvisioningTypes{} allProvisionAPI := &api{ method: "GET", @@ -25,11 +25,11 @@ func (a *ProvisioningAPIService) GetAllProvisioningTypes(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allProvisionAPI.do(ctx, nil, param) - return response, err + return Response, err } diff --git a/pkg/client/provisioning_test.go b/pkg/client/provisioning_test.go index 95762aa..3c1452d 100644 --- a/pkg/client/provisioning_test.go +++ b/pkg/client/provisioning_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -40,7 +40,7 @@ func TestProvisioningAPIService_GetAllProvisioningTypes(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "provisionTypes": [{ "id": 1, @@ -99,7 +99,7 @@ func TestProvisioningAPIService_GetAllProvisioningTypes(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/router.go b/pkg/client/router.go index 3265d5c..433f2e5 100644 --- a/pkg/client/router.go +++ b/pkg/client/router.go @@ -22,26 +22,26 @@ func (r *RouterAPIService) GetAllRouter( ctx context.Context, queryParams map[string]string, ) (models.GetAllNetworkRouter, error) { - routerResp := models.GetAllNetworkRouter{} + RouterResp := models.GetAllNetworkRouter{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "GET", path: fmt.Sprintf("%s/%s", consts.NetworksPath, consts.NetworkRouterPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, nil, queryParams) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) GetSpecificRouter( ctx context.Context, routerID int, ) (models.GetSpecificRouterResp, error) { - routerResp := models.GetSpecificRouterResp{} + RouterResp := models.GetSpecificRouterResp{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "GET", @@ -49,31 +49,31 @@ func (r *RouterAPIService) GetSpecificRouter( consts.NetworksPath, consts.NetworkRouterPath, routerID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, nil, nil) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) CreateRouter( ctx context.Context, request models.CreateRouterRequest, ) (models.CreateRouterResp, error) { - routerResp := models.CreateRouterResp{} + RouterResp := models.CreateRouterResp{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "POST", path: fmt.Sprintf("%s/%s", consts.NetworksPath, consts.NetworkRouterPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, request, nil) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) UpdateRouter( @@ -81,7 +81,7 @@ func (r *RouterAPIService) UpdateRouter( routerID int, request models.CreateRouterRequest, ) (models.SuccessOrErrorMessage, error) { - routerResp := models.SuccessOrErrorMessage{} + RouterResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "PUT", @@ -89,19 +89,19 @@ func (r *RouterAPIService) UpdateRouter( consts.NetworksPath, consts.NetworkRouterPath, routerID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, request, nil) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) DeleteRouter( ctx context.Context, routerID int, ) (models.SuccessOrErrorMessage, error) { - routerResp := models.SuccessOrErrorMessage{} + RouterResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "DELETE", @@ -109,38 +109,38 @@ func (r *RouterAPIService) DeleteRouter( consts.NetworksPath, consts.NetworkRouterPath, routerID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, nil, nil) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) GetRouterTypes( ctx context.Context, queryParams map[string]string, ) (models.GetNetworlRouterTypes, error) { - routerResp := models.GetNetworlRouterTypes{} + RouterResp := models.GetNetworlRouterTypes{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "GET", path: consts.NetworkRouterTypePath, client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, nil, queryParams) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) GetNetworkServices( ctx context.Context, queryParams map[string]string, ) (models.GetNetworkServicesResp, error) { - routerResp := models.GetNetworkServicesResp{} + RouterResp := models.GetNetworkServicesResp{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "GET", @@ -148,12 +148,12 @@ func (r *RouterAPIService) GetNetworkServices( consts.NetworkServicePath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &routerResp) + return json.Unmarshal(body, &RouterResp) }, } err := routerAPI.do(ctx, nil, queryParams) - return routerResp, err + return RouterResp, err } func (r *RouterAPIService) RefreshNetworkServices( @@ -161,7 +161,7 @@ func (r *RouterAPIService) RefreshNetworkServices( serverID int, queryParams map[string]string, ) (models.SuccessOrErrorMessage, error) { - serverResp := models.SuccessOrErrorMessage{} + ServerResp := models.SuccessOrErrorMessage{} serverAPI := &api{ compatibleVersion: consts.CMPSixZeroFiveVersion, method: "POST", @@ -169,12 +169,12 @@ func (r *RouterAPIService) RefreshNetworkServices( consts.ServerPath, serverID, consts.RefreshPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &serverResp) + return json.Unmarshal(body, &ServerResp) }, } err := serverAPI.do(ctx, nil, queryParams) - return serverResp, err + return ServerResp, err } func (r *RouterAPIService) CreateRouterNat( @@ -182,7 +182,7 @@ func (r *RouterAPIService) CreateRouterNat( routerID int, request models.CreateRouterNatRequest, ) (models.SuccessOrErrorMessage, error) { - natResp := models.SuccessOrErrorMessage{} + NatResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "POST", @@ -190,19 +190,19 @@ func (r *RouterAPIService) CreateRouterNat( consts.NetworkRouterPath, routerID, consts.RoutersNatPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &natResp) + return json.Unmarshal(body, &NatResp) }, } err := routerAPI.do(ctx, request, nil) - return natResp, err + return NatResp, err } func (r *RouterAPIService) GetSpecificRouterNat( ctx context.Context, routerID, natID int, ) (models.GetSpecificRouterNatResponse, error) { - natResp := models.GetSpecificRouterNatResponse{} + NatResp := models.GetSpecificRouterNatResponse{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "GET", @@ -210,12 +210,12 @@ func (r *RouterAPIService) GetSpecificRouterNat( consts.NetworkRouterPath, routerID, consts.RoutersNatPath, natID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &natResp) + return json.Unmarshal(body, &NatResp) }, } err := routerAPI.do(ctx, nil, nil) - return natResp, err + return NatResp, err } func (r *RouterAPIService) UpdateRouterNat( @@ -223,7 +223,7 @@ func (r *RouterAPIService) UpdateRouterNat( routerID, natID int, req models.CreateRouterNatRequest, ) (models.SuccessOrErrorMessage, error) { - natResp := models.SuccessOrErrorMessage{} + NatResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "PUT", @@ -231,19 +231,19 @@ func (r *RouterAPIService) UpdateRouterNat( consts.NetworkRouterPath, routerID, consts.RoutersNatPath, natID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &natResp) + return json.Unmarshal(body, &NatResp) }, } err := routerAPI.do(ctx, req, nil) - return natResp, err + return NatResp, err } func (r *RouterAPIService) DeleteRouterNat( ctx context.Context, routerID, natID int, ) (models.SuccessOrErrorMessage, error) { - natResp := models.SuccessOrErrorMessage{} + NatResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "DELETE", @@ -251,12 +251,12 @@ func (r *RouterAPIService) DeleteRouterNat( consts.NetworkRouterPath, routerID, consts.RoutersNatPath, natID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &natResp) + return json.Unmarshal(body, &NatResp) }, } err := routerAPI.do(ctx, nil, nil) - return natResp, err + return NatResp, err } func (r *RouterAPIService) CreateRouterFirewallRuleGroup( @@ -264,7 +264,7 @@ func (r *RouterAPIService) CreateRouterFirewallRuleGroup( routerID int, request models.CreateRouterFirewallRuleGroupRequest, ) (models.SuccessOrErrorMessage, error) { - firewallGroupResp := models.SuccessOrErrorMessage{} + FirewallGroupResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "POST", @@ -272,19 +272,19 @@ func (r *RouterAPIService) CreateRouterFirewallRuleGroup( consts.NetworkRouterPath, routerID, consts.RoutersFirewallRuleGroupPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &firewallGroupResp) + return json.Unmarshal(body, &FirewallGroupResp) }, } err := routerAPI.do(ctx, request, nil) - return firewallGroupResp, err + return FirewallGroupResp, err } func (r *RouterAPIService) GetSpecificRouterFirewallRuleGroup( ctx context.Context, routerID, firewallGroupID int, ) (models.GetSpecificRouterFirewallRuleGroupResponse, error) { - firewallGroupResp := models.GetSpecificRouterFirewallRuleGroupResponse{} + FirewallGroupResp := models.GetSpecificRouterFirewallRuleGroupResponse{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "GET", @@ -292,19 +292,19 @@ func (r *RouterAPIService) GetSpecificRouterFirewallRuleGroup( consts.NetworkRouterPath, routerID, consts.RoutersFirewallRuleGroupPath, firewallGroupID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &firewallGroupResp) + return json.Unmarshal(body, &FirewallGroupResp) }, } err := routerAPI.do(ctx, nil, nil) - return firewallGroupResp, err + return FirewallGroupResp, err } func (r *RouterAPIService) DeleteRouterFirewallRuleGroup( ctx context.Context, routerID, firewallGroupID int, ) (models.SuccessOrErrorMessage, error) { - firewallGroupResp := models.SuccessOrErrorMessage{} + FirewallGroupResp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: routerCompatibleVersion, method: "DELETE", @@ -312,12 +312,12 @@ func (r *RouterAPIService) DeleteRouterFirewallRuleGroup( consts.NetworkRouterPath, routerID, consts.RoutersFirewallRuleGroupPath, firewallGroupID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &firewallGroupResp) + return json.Unmarshal(body, &FirewallGroupResp) }, } err := routerAPI.do(ctx, nil, nil) - return firewallGroupResp, err + return FirewallGroupResp, err } func (r *RouterAPIService) CreateRouterRoute( @@ -325,7 +325,7 @@ func (r *RouterAPIService) CreateRouterRoute( routerID int, req models.CreateRouterRoute, ) (models.SuccessOrErrorMessage, error) { - resp := models.SuccessOrErrorMessage{} + Resp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "POST", @@ -333,19 +333,19 @@ func (r *RouterAPIService) CreateRouterRoute( consts.NetworkRouterPath, routerID, consts.RouterRoutePath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, req, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) GetSpecificRouterRoute( ctx context.Context, routerID, routeID int, ) (models.GetSpecificRouterRoute, error) { - resp := models.GetSpecificRouterRoute{} + Resp := models.GetSpecificRouterRoute{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "GET", @@ -353,19 +353,19 @@ func (r *RouterAPIService) GetSpecificRouterRoute( consts.NetworkRouterPath, routerID, consts.RouterRoutePath, routeID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, nil, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) DeleteRouterRoute( ctx context.Context, routerID, routeID int, ) (models.SuccessOrErrorMessage, error) { - resp := models.SuccessOrErrorMessage{} + Resp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "DELETE", @@ -373,12 +373,12 @@ func (r *RouterAPIService) DeleteRouterRoute( consts.NetworkRouterPath, routerID, consts.RouterRoutePath, routeID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, nil, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) CreateRouterBgpNeighbor( @@ -386,7 +386,7 @@ func (r *RouterAPIService) CreateRouterBgpNeighbor( routerID int, req models.CreateNetworkRouterBgpNeighborRequest, ) (models.SuccessOrErrorMessage, error) { - resp := models.SuccessOrErrorMessage{} + Resp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "POST", @@ -394,19 +394,19 @@ func (r *RouterAPIService) CreateRouterBgpNeighbor( consts.NetworkRouterPath, routerID, consts.RouterBgpNeighborPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, req, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) GetSpecificRouterBgpNeighbor( ctx context.Context, routerID, bgpNeighborID int, ) (models.GetSpecificNetworkRouterBgpNeighbor, error) { - resp := models.GetSpecificNetworkRouterBgpNeighbor{} + Resp := models.GetSpecificNetworkRouterBgpNeighbor{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "GET", @@ -414,12 +414,12 @@ func (r *RouterAPIService) GetSpecificRouterBgpNeighbor( consts.NetworkRouterPath, routerID, consts.RouterBgpNeighborPath, bgpNeighborID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, nil, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) UpdateRouterBgpNeighbor( @@ -427,7 +427,7 @@ func (r *RouterAPIService) UpdateRouterBgpNeighbor( routerID, bgpNeighborID int, req models.CreateNetworkRouterBgpNeighborRequest, ) (models.SuccessOrErrorMessage, error) { - resp := models.SuccessOrErrorMessage{} + Resp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "PUT", @@ -435,19 +435,19 @@ func (r *RouterAPIService) UpdateRouterBgpNeighbor( consts.NetworkRouterPath, routerID, consts.RouterBgpNeighborPath, bgpNeighborID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, req, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) DeleteRouterBgpNeighbor( ctx context.Context, routerID, bgpNeighborID int, ) (models.SuccessOrErrorMessage, error) { - resp := models.SuccessOrErrorMessage{} + Resp := models.SuccessOrErrorMessage{} routerAPI := &api{ compatibleVersion: "5.2.12", method: "DELETE", @@ -455,12 +455,12 @@ func (r *RouterAPIService) DeleteRouterBgpNeighbor( consts.NetworkRouterPath, routerID, consts.RouterBgpNeighborPath, bgpNeighborID), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } err := routerAPI.do(ctx, nil, nil) - return resp, err + return Resp, err } func (r *RouterAPIService) GetTransportZones( @@ -468,7 +468,7 @@ func (r *RouterAPIService) GetTransportZones( serviceID int, transportName string, ) (models.NetworkScope, error) { - resp := models.TransportZonesResp{} + Resp := models.TransportZonesResp{} routerAPI := &api{ compatibleVersion: "5.2.13", method: "GET", @@ -476,7 +476,7 @@ func (r *RouterAPIService) GetTransportZones( consts.NetworksPath, consts.ServerPath, serviceID, consts.NetworkScopePath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } @@ -484,7 +484,7 @@ func (r *RouterAPIService) GetTransportZones( return models.NetworkScope{}, err } - for _, t := range resp.NetworkScopes { + for _, t := range Resp.NetworkScopes { if t.Name == transportName { return t, nil } @@ -498,7 +498,7 @@ func (r *RouterAPIService) GetEdgeCluster( serviceID int, edgeClusterName string, ) (models.NetworkEdgeClusters, error) { - resp := models.NetworkEdgeClustersResp{} + Resp := models.NetworkEdgeClustersResp{} routerAPI := &api{ compatibleVersion: "5.2.13", method: "GET", @@ -506,7 +506,7 @@ func (r *RouterAPIService) GetEdgeCluster( consts.NetworksPath, consts.ServerPath, serviceID, consts.NetworkEdgeClusterPath), client: r.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &resp) + return json.Unmarshal(body, &Resp) }, } @@ -514,7 +514,7 @@ func (r *RouterAPIService) GetEdgeCluster( return models.NetworkEdgeClusters{}, err } - for _, t := range resp.NetworkEdgeClusters { + for _, t := range Resp.NetworkEdgeClusters { if t.Name == edgeClusterName { return t, nil } diff --git a/pkg/client/router_test.go b/pkg/client/router_test.go index 34367e9..1ca80af 100644 --- a/pkg/client/router_test.go +++ b/pkg/client/router_test.go @@ -7,7 +7,7 @@ import ( "context" "encoding/json" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -43,7 +43,7 @@ func TestRouterAPIService_GetAllRouters(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouters": [{ "id": 1, @@ -102,7 +102,7 @@ func TestRouterAPIService_GetAllRouters(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -172,7 +172,7 @@ func TestRouterAPIService_GetNetworkRouterTypes(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouterTypes": [{ "id": 1, @@ -231,7 +231,7 @@ func TestRouterAPIService_GetNetworkRouterTypes(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -312,7 +312,7 @@ func TestRouterAPIService_CreateRouter(t *testing.T) { m.EXPECT().callAPI(req).Return(&http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader([]byte(` + Body: io.NopCloser(bytes.NewReader([]byte(` { "success": true, "id": 16 @@ -375,14 +375,14 @@ func TestRouterAPIService_UpdateRouter(t *testing.T) { m.EXPECT().getHost().Return(mockHost) path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/networks/routers/1" method := "PUT" - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouter": { "name": "test_update_router_name" } }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + respBody := io.NopCloser(bytes.NewReader([]byte(`{ "success": true }`))) pBody := models.CreateRouterRequest{ @@ -440,14 +440,14 @@ func TestRouterAPIService_UpdateRouter(t *testing.T) { m.EXPECT().getHost().Return(mockHost) path := mockHost + "/" + consts.VmaasCmpAPIBasePath + "/networks/routers/1" method := "PUT" - postBody := ioutil.NopCloser(bytes.NewReader([]byte(` + postBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouter": { "name": "test_update_router_name" } }`))) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(`{ + respBody := io.NopCloser(bytes.NewReader([]byte(`{ { "message": "Internal Server Error", "recommendedActions": [ @@ -516,7 +516,7 @@ func TestRouterAPIService_GetSpecificRouter(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouter":{ "id": 1, @@ -586,7 +586,7 @@ func TestRouterAPIService_DeleteRouter(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "message": "test_template_delete_a_router" @@ -631,7 +631,7 @@ func TestRouterAPIService_DeleteRouter(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -698,7 +698,7 @@ func TestRouterAPIService_GetNetworkServices(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkServices": [{ "id": 1, @@ -757,7 +757,7 @@ func TestRouterAPIService_GetNetworkServices(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -829,7 +829,7 @@ func TestRouterAPIService_DeleteRouterNat(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -898,7 +898,7 @@ func TestRouterAPIService_GetSpecificRouterNat(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouterNAT": { "id": 1 @@ -982,9 +982,9 @@ func TestRouterAPIService_CreateRouterNat(t *testing.T) { }, } jsonByte, _ := json.Marshal(reqModel) - postBody := ioutil.NopCloser(bytes.NewReader(jsonByte)) + postBody := io.NopCloser(bytes.NewReader(jsonByte)) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "id": 2 @@ -1068,9 +1068,9 @@ func TestRouterAPIService_UpdateRouterNat(t *testing.T) { }, } jsonByte, _ := json.Marshal(reqModel) - postBody := ioutil.NopCloser(bytes.NewReader(jsonByte)) + postBody := io.NopCloser(bytes.NewReader(jsonByte)) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "id": 2 @@ -1144,7 +1144,7 @@ func TestRouterAPIService_DeleteRouterFirewallRuleGroup(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1213,7 +1213,7 @@ func TestRouterAPIService_GetSpecificRouterFirewallRuleGroup(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "ruleGroup": { "id": 1 @@ -1297,9 +1297,9 @@ func TestRouterAPIService_CreateRouterFirewallRuleGroup(t *testing.T) { }, } jsonByte, _ := json.Marshal(reqModel) - postBody := ioutil.NopCloser(bytes.NewReader(jsonByte)) + postBody := io.NopCloser(bytes.NewReader(jsonByte)) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "id": 2 @@ -1370,7 +1370,7 @@ func TestRouterAPIService_DeleteRouterBgpNeighbor(t *testing.T) { method := "DELETE" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } @@ -1439,7 +1439,7 @@ func TestRouterAPIService_GetSpecificRouterBgpNeighbor(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "networkRouterBgpNeighbor": { "id": 1 @@ -1523,9 +1523,9 @@ func TestRouterAPIService_CreateRouterBgpNeighbor(t *testing.T) { }, } jsonByte, _ := json.Marshal(reqModel) - postBody := ioutil.NopCloser(bytes.NewReader(jsonByte)) + postBody := io.NopCloser(bytes.NewReader(jsonByte)) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true, "id": 2 @@ -1609,9 +1609,9 @@ func TestRouterAPIService_UpdateRouterBgpNeighbor(t *testing.T) { }, } jsonByte, _ := json.Marshal(reqModel) - postBody := ioutil.NopCloser(bytes.NewReader(jsonByte)) + postBody := io.NopCloser(bytes.NewReader(jsonByte)) req, _ := http.NewRequest(method, path, postBody) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "success": true } diff --git a/pkg/client/servers.go b/pkg/client/servers.go index c6d1f41..2f5a8d3 100644 --- a/pkg/client/servers.go +++ b/pkg/client/servers.go @@ -19,40 +19,41 @@ type ServersAPIService struct { /* ServersApiService Get All Servers - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param name/phrase optional + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param name/phrase optional + @return models.Servers */ func (a *ServersAPIService) GetAllServers( ctx context.Context, queryParams map[string]string, ) (models.ServersResponse, error) { - serversResponse := models.ServersResponse{} + ServersResponse := models.ServersResponse{} serverAPI := &api{ method: "GET", path: consts.ServerPath, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &serversResponse) + return json.Unmarshal(body, &ServersResponse) }, } err := serverAPI.do(ctx, nil, queryParams) - return serversResponse, err + return ServersResponse, err } func (a *ServersAPIService) GetSpecificServer( ctx context.Context, serverID int) (models.GetSpecificServerResponse, error) { - serversResponse := models.GetSpecificServerResponse{} + ServersResponse := models.GetSpecificServerResponse{} serverAPI := &api{ method: "GET", path: fmt.Sprintf("%s/%d", consts.ServerPath, serverID), client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &serversResponse) + return json.Unmarshal(body, &ServersResponse) }, validations: []validationFunc{ func() error { @@ -66,5 +67,5 @@ func (a *ServersAPIService) GetSpecificServer( } err := serverAPI.do(ctx, nil, nil) - return serversResponse, err + return ServersResponse, err } diff --git a/pkg/client/servers_test.go b/pkg/client/servers_test.go index 94ec312..edcedd6 100644 --- a/pkg/client/servers_test.go +++ b/pkg/client/servers_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -42,7 +42,7 @@ func TestServersAPIService_GetAllServers(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "servers": [{ "id": 1, @@ -103,7 +103,7 @@ func TestServersAPIService_GetAllServers(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ @@ -173,7 +173,7 @@ func TestServersAPIService_GetSpecificServer(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "server": { "id": 1, @@ -224,7 +224,7 @@ func TestServersAPIService_GetSpecificServer(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [ diff --git a/pkg/client/status.go b/pkg/client/status.go index 2901f38..7bcdec1 100644 --- a/pkg/client/status.go +++ b/pkg/client/status.go @@ -16,7 +16,7 @@ type CmpStatus struct { } func (a *CmpStatus) GetCmpVersion(ctx context.Context) (models.CmpVersionModel, error) { - checkResp := models.CmpVersionModel{} + CheckResp := models.CmpVersionModel{} statusAPI := &api{ method: "GET", @@ -24,10 +24,10 @@ func (a *CmpStatus) GetCmpVersion(ctx context.Context) (models.CmpVersionModel, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &checkResp) + return json.Unmarshal(body, &CheckResp) }, } err := statusAPI.do(ctx, nil, nil) - return checkResp, err + return CheckResp, err } diff --git a/pkg/client/virtual_images.go b/pkg/client/virtual_images.go index f1bff69..b3f296a 100644 --- a/pkg/client/virtual_images.go +++ b/pkg/client/virtual_images.go @@ -19,15 +19,16 @@ type VirtualImagesAPIService struct { /* VirtualImageAPIService Get All Virtual images - * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. - Passed from http.Request or context.Background(). - * @param serviceInstanceID - * @param name/phrase optional + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. + Passed from http.Request or context.Background(). + - @param serviceInstanceID + - @param name/phrase optional + @return models.VirtualImages */ func (a *VirtualImagesAPIService) GetAllVirtualImages(ctx context.Context, param map[string]string) (models.VirtualImages, error) { - response := models.VirtualImages{} + Response := models.VirtualImages{} allVirtualImagesAPI := &api{ method: "GET", @@ -35,20 +36,20 @@ func (a *VirtualImagesAPIService) GetAllVirtualImages(ctx context.Context, client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := allVirtualImagesAPI.do(ctx, nil, param) - return response, err + return Response, err } func (a *VirtualImagesAPIService) GetSpecificVirtualImage( ctx context.Context, virtualImageID int, ) (models.GetSpecificVirtualImage, error) { - response := models.GetSpecificVirtualImage{} + Response := models.GetSpecificVirtualImage{} api := &api{ method: "GET", @@ -56,11 +57,11 @@ func (a *VirtualImagesAPIService) GetSpecificVirtualImage( client: a.Client, jsonParser: func(body []byte) error { - return json.Unmarshal(body, &response) + return json.Unmarshal(body, &Response) }, } err := api.do(ctx, nil, nil) - return response, err + return Response, err } diff --git a/pkg/client/virtual_images_test.go b/pkg/client/virtual_images_test.go index 9fc790b..22704ab 100644 --- a/pkg/client/virtual_images_test.go +++ b/pkg/client/virtual_images_test.go @@ -6,7 +6,7 @@ import ( "bytes" "context" "errors" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -43,7 +43,7 @@ func TestVirtualImagesAPIService_GetAllVirtualImages(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "virtualImages": [{ "id": 1, @@ -104,7 +104,7 @@ func TestVirtualImagesAPIService_GetAllVirtualImages(t *testing.T) { method := "GET" headers := getDefaultHeaders() req, _ := http.NewRequest(method, path, nil) - respBody := ioutil.NopCloser(bytes.NewReader([]byte(` + respBody := io.NopCloser(bytes.NewReader([]byte(` { "message": "Internal Server Error", "recommendedActions": [