diff --git a/Makefile b/Makefile index 181e180..d2bc83d 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ generate: deps mockgen --destination ./internal/mocks/racks_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/racks.go mockgen --destination ./internal/mocks/invoices_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/invoices.go mockgen --destination ./internal/mocks/account_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/accounts.go + mockgen --destination ./internal/mocks/locations_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/locations.go sed -i '' 's|github.com/serverscom/srvctl/vendor/github.com/serverscom/serverscom-go-client/pkg|github.com/serverscom/serverscom-go-client/pkg|g' \ ./internal/mocks/ssh_service.go \ ./internal/mocks/hosts_service.go \ @@ -23,5 +24,6 @@ generate: deps ./internal/mocks/racks_service.go \ ./internal/mocks/invoices_service.go \ ./internal/mocks/account_service.go \ - ./internal/mocks/collection.go + ./internal/mocks/collection.go \ + ./internal/mocks/locations_service.go diff --git a/cmd/entities/hosts/hosts_test.go b/cmd/entities/hosts/hosts_test.go index f16b44a..78e83f9 100644 --- a/cmd/entities/hosts/hosts_test.go +++ b/cmd/entities/hosts/hosts_test.go @@ -26,6 +26,7 @@ var ( } testDS = serverscom.DedicatedServer{ ID: testId, + RackID: testId, Type: "dedicated_server", Title: "example.aa", Status: "active", @@ -33,15 +34,20 @@ var ( Updated: fixedTime, } testKBM = serverscom.KubernetesBaremetalNode{ - ID: testId, - Type: "kubernetes_baremetal_node", - Title: "example.aa", - Status: "active", - Created: fixedTime, - Updated: fixedTime, + ID: testId, + RackID: testId, + KubernetesClusterID: testId, + KubernetesClusterNodeID: testId, + KubernetesClusterNodeNumber: 1, + Type: "kubernetes_baremetal_node", + Title: "example.aa", + Status: "active", + Created: fixedTime, + Updated: fixedTime, } testSBM = serverscom.SBMServer{ ID: testId, + RackID: testId, Type: "sbm_server", Title: "example.aa", Status: "active", diff --git a/cmd/entities/locations/get.go b/cmd/entities/locations/get.go new file mode 100644 index 0000000..10b7be6 --- /dev/null +++ b/cmd/entities/locations/get.go @@ -0,0 +1,45 @@ +package locations + +import ( + "fmt" + "strconv" + + "github.com/serverscom/srvctl/cmd/base" + "github.com/spf13/cobra" +) + +func newGetCmd(cmdContext *base.CmdContext) *cobra.Command { + cmd := &cobra.Command{ + Use: "get ", + Short: "Get a location", + Long: "Get a location by id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + manager := cmdContext.GetManager() + + ctx, cancel := base.SetupContext(cmd, manager) + defer cancel() + + base.SetupProxy(cmd, manager) + + scClient := cmdContext.GetClient().SetVerbose(manager.GetVerbose(cmd)).GetScClient() + + id, err := strconv.Atoi(args[0]) + if err != nil { + return fmt.Errorf("location id should be integer") + } + location, err := scClient.Locations.GetLocation(ctx, int64(id)) + if err != nil { + return err + } + + if location != nil { + formatter := cmdContext.GetOrCreateFormatter(cmd) + return formatter.Format(location) + } + return nil + }, + } + + return cmd +} diff --git a/cmd/entities/locations/list.go b/cmd/entities/locations/list.go new file mode 100644 index 0000000..f23ed49 --- /dev/null +++ b/cmd/entities/locations/list.go @@ -0,0 +1,21 @@ +package locations + +import ( + serverscom "github.com/serverscom/serverscom-go-client/pkg" + "github.com/serverscom/srvctl/cmd/base" + "github.com/spf13/cobra" +) + +func newListCmd(cmdContext *base.CmdContext) *cobra.Command { + factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.Location] { + scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient() + return scClient.Locations.Collection() + } + + opts := base.NewListOptions( + &base.BaseListOptions[serverscom.Location]{}, + &base.SearchPatternOption[serverscom.Location]{}, + ) + + return base.NewListCmd("list", "locations", factory, cmdContext, opts...) +} diff --git a/cmd/entities/locations/locations.go b/cmd/entities/locations/locations.go new file mode 100644 index 0000000..b1910cc --- /dev/null +++ b/cmd/entities/locations/locations.go @@ -0,0 +1,41 @@ +package locations + +import ( + "log" + + serverscom "github.com/serverscom/serverscom-go-client/pkg" + "github.com/serverscom/srvctl/cmd/base" + "github.com/serverscom/srvctl/internal/output/entities" + "github.com/spf13/cobra" +) + +func NewCmd(cmdContext *base.CmdContext) *cobra.Command { + locationEntity, err := entities.Registry.GetEntityFromValue(serverscom.Location{}) + if err != nil { + log.Fatal(err) + } + entitiesMap := make(map[string]entities.EntityInterface) + entitiesMap["locations"] = locationEntity + cmd := &cobra.Command{ + Use: "locations", + Short: "Manage locations", + PersistentPreRunE: base.CombinePreRunE( + base.CheckFormatterFlags(cmdContext, entitiesMap), + base.CheckEmptyContexts(cmdContext), + ), + Args: base.NoArgs, + Run: base.UsageRun, + } + + cmd.AddCommand( + newListCmd(cmdContext), + // newAddCmd(cmdContext), + newGetCmd(cmdContext), + // newUpdateCmd(cmdContext), + // newDeleteCmd(cmdContext), + ) + + base.AddFormatFlags(cmd) + + return cmd +} diff --git a/cmd/entities/locations/locations_test.go b/cmd/entities/locations/locations_test.go new file mode 100644 index 0000000..6e7b51e --- /dev/null +++ b/cmd/entities/locations/locations_test.go @@ -0,0 +1,240 @@ +package locations + +import ( + "errors" + "path/filepath" + "testing" + + "fmt" + + . "github.com/onsi/gomega" + serverscom "github.com/serverscom/serverscom-go-client/pkg" + "github.com/serverscom/srvctl/cmd/testutils" + "github.com/serverscom/srvctl/internal/mocks" + "go.uber.org/mock/gomock" +) + +var ( + testId = int64(1) + fixtureBasePath = filepath.Join("..", "..", "..", "testdata", "entities", "locations") + testLocation = serverscom.Location{ + ID: testId, + Name: "test-location", + Status: "active", + Code: "test", + SupportedFeatures: []string{"feature1", "feature2"}, + } +) + +func TestGetLocationCmd(t *testing.T) { + testCases := []struct { + name string + id int64 + output string + expectedOutput []byte + expectError bool + }{ + { + name: "get location in default format", + id: testId, + output: "", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.txt")), + }, + { + name: "get location in JSON format", + id: testId, + output: "json", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.json")), + }, + { + name: "get location in YAML format", + id: testId, + output: "yaml", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "get.yaml")), + }, + { + name: "get location with error", + id: testId, + expectError: true, + }, + } + + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + locationsServiceHandler := mocks.NewMockLocationsService(mockCtrl) + + scClient := serverscom.NewClientWithEndpoint("", "") + scClient.Locations = locationsServiceHandler + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + g := NewWithT(t) + + var err error + if tc.expectError { + err = errors.New("some error") + } + locationsServiceHandler.EXPECT(). + GetLocation(gomock.Any(), testId). + Return(&testLocation, err) + + testCmdContext := testutils.NewTestCmdContext(scClient) + locationCmd := NewCmd(testCmdContext) + + args := []string{"locations", "get", fmt.Sprint(tc.id)} + if tc.output != "" { + args = append(args, "--output", tc.output) + } + + builder := testutils.NewTestCommandBuilder(). + WithCommand(locationCmd). + WithArgs(args) + + cmd := builder.Build() + + err = cmd.Execute() + + if tc.expectError { + g.Expect(err).To(HaveOccurred()) + } else { + g.Expect(err).To(BeNil()) + g.Expect(builder.GetOutput()).To(BeEquivalentTo(string(tc.expectedOutput))) + } + }) + } +} + +func TestListLocationsCmd(t *testing.T) { + testLocation1 := testLocation + testLocation2 := testLocation + testLocation1.ID = 1 + testLocation2.Name = "test-location 2" + testLocation2.ID = 2 + + testCases := []struct { + name string + output string + args []string + expectedOutput []byte + expectError bool + configureMock func(*mocks.MockCollection[serverscom.Location]) + }{ + { + name: "list all locations", + output: "json", + args: []string{"-A"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_all.json")), + configureMock: func(mock *mocks.MockCollection[serverscom.Location]) { + mock.EXPECT(). + Collect(gomock.Any()). + Return([]serverscom.Location{ + testLocation1, + testLocation2, + }, nil) + }, + }, + { + name: "list locations", + output: "json", + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list.json")), + configureMock: func(mock *mocks.MockCollection[serverscom.Location]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.Location{ + testLocation1, + }, nil) + }, + }, + { + name: "list locations with template", + args: []string{"--template", "{{range .}}Name: {{.Name}}\n{{end}}"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_template.txt")), + configureMock: func(mock *mocks.MockCollection[serverscom.Location]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.Location{ + testLocation1, + testLocation2, + }, nil) + }, + }, + { + name: "list locations with pageView", + args: []string{"--page-view"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_pageview.txt")), + configureMock: func(mock *mocks.MockCollection[serverscom.Location]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.Location{ + testLocation1, + testLocation2, + }, nil) + }, + }, + { + name: "list locations with error", + expectError: true, + configureMock: func(mock *mocks.MockCollection[serverscom.Location]) { + mock.EXPECT(). + List(gomock.Any()). + Return(nil, errors.New("some error")) + }, + }, + } + + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + locationsServiceHandler := mocks.NewMockLocationsService(mockCtrl) + collectionHandler := mocks.NewMockCollection[serverscom.Location](mockCtrl) + + locationsServiceHandler.EXPECT(). + Collection(). + Return(collectionHandler). + AnyTimes() + + collectionHandler.EXPECT(). + SetParam(gomock.Any(), gomock.Any()). + Return(collectionHandler). + AnyTimes() + + scClient := serverscom.NewClientWithEndpoint("", "") + scClient.Locations = locationsServiceHandler + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + g := NewWithT(t) + + if tc.configureMock != nil { + tc.configureMock(collectionHandler) + } + + testCmdContext := testutils.NewTestCmdContext(scClient) + locationCmd := NewCmd(testCmdContext) + + args := []string{"locations", "list"} + if len(tc.args) > 0 { + args = append(args, tc.args...) + } + if tc.output != "" { + args = append(args, "--output", tc.output) + } + + builder := testutils.NewTestCommandBuilder(). + WithCommand(locationCmd). + WithArgs(args) + + cmd := builder.Build() + + err := cmd.Execute() + + if tc.expectError { + g.Expect(err).To(HaveOccurred()) + } else { + g.Expect(err).To(BeNil()) + g.Expect(builder.GetOutput()).To(BeEquivalentTo(string(tc.expectedOutput))) + } + }) + } +} diff --git a/cmd/root.go b/cmd/root.go index 6b7b6a4..8f0c661 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,6 +8,7 @@ import ( "github.com/serverscom/srvctl/cmd/entities/hosts" "github.com/serverscom/srvctl/cmd/entities/invoices" loadbalancers "github.com/serverscom/srvctl/cmd/entities/load_balancers" + "github.com/serverscom/srvctl/cmd/entities/locations" "github.com/serverscom/srvctl/cmd/entities/racks" sshkeys "github.com/serverscom/srvctl/cmd/entities/ssh-keys" "github.com/serverscom/srvctl/cmd/entities/ssl" @@ -48,6 +49,7 @@ func NewRootCmd(version string) *cobra.Command { cmd.AddCommand(racks.NewCmd(cmdContext)) cmd.AddCommand(invoices.NewCmd(cmdContext)) cmd.AddCommand(account.NewCmd(cmdContext)) + cmd.AddCommand(locations.NewCmd(cmdContext)) return cmd } diff --git a/go.mod b/go.mod index 6b8203d..2186b3c 100644 --- a/go.mod +++ b/go.mod @@ -6,14 +6,14 @@ require ( github.com/creack/pty v1.1.24 github.com/jmespath/go-jmespath v0.4.0 github.com/onsi/gomega v1.36.2 - github.com/serverscom/serverscom-go-client v1.0.14 + github.com/serverscom/serverscom-go-client v1.0.17 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 github.com/stoewer/go-strcase v1.3.0 go.uber.org/mock v0.5.0 - golang.org/x/term v0.30.0 - golang.org/x/text v0.23.0 + golang.org/x/term v0.32.0 + golang.org/x/text v0.25.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -35,7 +35,7 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.37.0 // indirect - golang.org/x/sys v0.31.0 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index cc06d94..7a2fca1 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/serverscom/serverscom-go-client v1.0.14 h1:/SR4moqSL6MqW+gt6wtF9Wl5KfckP4RcqeS0AECwwAs= -github.com/serverscom/serverscom-go-client v1.0.14/go.mod h1:o4lNYX+shv5TZ6miuGAaMDJP8y7Z7TdPEhMsCcL9PrU= +github.com/serverscom/serverscom-go-client v1.0.17 h1:noPj7s8G3CdnhfwHadMu7f0cqt+H9rpv01wjHHaoafs= +github.com/serverscom/serverscom-go-client v1.0.17/go.mod h1:/Nf+XygKOxm19Sl2gvMzT55O4X+tWDkj/UM4mjzfKgM= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -88,14 +88,14 @@ go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= -golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= diff --git a/internal/mocks/locations_service.go b/internal/mocks/locations_service.go new file mode 100644 index 0000000..e504469 --- /dev/null +++ b/internal/mocks/locations_service.go @@ -0,0 +1,288 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: ./vendor/github.com/serverscom/serverscom-go-client/pkg/locations.go +// +// Generated by this command: +// +// mockgen --destination ./internal/mocks/locations_service.go --package=mocks --source ./vendor/github.com/serverscom/serverscom-go-client/pkg/locations.go +// + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + serverscom "github.com/serverscom/serverscom-go-client/pkg" + gomock "go.uber.org/mock/gomock" +) + +// MockLocationsService is a mock of LocationsService interface. +type MockLocationsService struct { + ctrl *gomock.Controller + recorder *MockLocationsServiceMockRecorder + isgomock struct{} +} + +// MockLocationsServiceMockRecorder is the mock recorder for MockLocationsService. +type MockLocationsServiceMockRecorder struct { + mock *MockLocationsService +} + +// NewMockLocationsService creates a new mock instance. +func NewMockLocationsService(ctrl *gomock.Controller) *MockLocationsService { + mock := &MockLocationsService{ctrl: ctrl} + mock.recorder = &MockLocationsServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockLocationsService) EXPECT() *MockLocationsServiceMockRecorder { + return m.recorder +} + +// BandwidthOptions mocks base method. +func (m *MockLocationsService) BandwidthOptions(locationID, serverModelID, uplinkID int64) serverscom.Collection[serverscom.BandwidthOption] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BandwidthOptions", locationID, serverModelID, uplinkID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.BandwidthOption]) + return ret0 +} + +// BandwidthOptions indicates an expected call of BandwidthOptions. +func (mr *MockLocationsServiceMockRecorder) BandwidthOptions(locationID, serverModelID, uplinkID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BandwidthOptions", reflect.TypeOf((*MockLocationsService)(nil).BandwidthOptions), locationID, serverModelID, uplinkID) +} + +// Collection mocks base method. +func (m *MockLocationsService) Collection() serverscom.Collection[serverscom.Location] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Collection") + ret0, _ := ret[0].(serverscom.Collection[serverscom.Location]) + return ret0 +} + +// Collection indicates an expected call of Collection. +func (mr *MockLocationsServiceMockRecorder) Collection() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Collection", reflect.TypeOf((*MockLocationsService)(nil).Collection)) +} + +// DriveModelOptions mocks base method. +func (m *MockLocationsService) DriveModelOptions(locationID, serverModelID int64) serverscom.Collection[serverscom.DriveModel] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DriveModelOptions", locationID, serverModelID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.DriveModel]) + return ret0 +} + +// DriveModelOptions indicates an expected call of DriveModelOptions. +func (mr *MockLocationsServiceMockRecorder) DriveModelOptions(locationID, serverModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DriveModelOptions", reflect.TypeOf((*MockLocationsService)(nil).DriveModelOptions), locationID, serverModelID) +} + +// GetBandwidthOption mocks base method. +func (m *MockLocationsService) GetBandwidthOption(ctx context.Context, locationID, serverModelID, uplinkModelID, bandwidthID int64) (*serverscom.BandwidthOption, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBandwidthOption", ctx, locationID, serverModelID, uplinkModelID, bandwidthID) + ret0, _ := ret[0].(*serverscom.BandwidthOption) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetBandwidthOption indicates an expected call of GetBandwidthOption. +func (mr *MockLocationsServiceMockRecorder) GetBandwidthOption(ctx, locationID, serverModelID, uplinkModelID, bandwidthID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBandwidthOption", reflect.TypeOf((*MockLocationsService)(nil).GetBandwidthOption), ctx, locationID, serverModelID, uplinkModelID, bandwidthID) +} + +// GetDriveModelOption mocks base method. +func (m *MockLocationsService) GetDriveModelOption(ctx context.Context, locationID, serverModelID, driveModelID int64) (*serverscom.DriveModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDriveModelOption", ctx, locationID, serverModelID, driveModelID) + ret0, _ := ret[0].(*serverscom.DriveModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetDriveModelOption indicates an expected call of GetDriveModelOption. +func (mr *MockLocationsServiceMockRecorder) GetDriveModelOption(ctx, locationID, serverModelID, driveModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDriveModelOption", reflect.TypeOf((*MockLocationsService)(nil).GetDriveModelOption), ctx, locationID, serverModelID, driveModelID) +} + +// GetLocation mocks base method. +func (m *MockLocationsService) GetLocation(ctx context.Context, locationID int64) (*serverscom.Location, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLocation", ctx, locationID) + ret0, _ := ret[0].(*serverscom.Location) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetLocation indicates an expected call of GetLocation. +func (mr *MockLocationsServiceMockRecorder) GetLocation(ctx, locationID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLocation", reflect.TypeOf((*MockLocationsService)(nil).GetLocation), ctx, locationID) +} + +// GetOperatingSystemOption mocks base method. +func (m *MockLocationsService) GetOperatingSystemOption(ctx context.Context, locationID, serverModelID, operatingSystemID int64) (*serverscom.OperatingSystemOption, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOperatingSystemOption", ctx, locationID, serverModelID, operatingSystemID) + ret0, _ := ret[0].(*serverscom.OperatingSystemOption) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetOperatingSystemOption indicates an expected call of GetOperatingSystemOption. +func (mr *MockLocationsServiceMockRecorder) GetOperatingSystemOption(ctx, locationID, serverModelID, operatingSystemID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOperatingSystemOption", reflect.TypeOf((*MockLocationsService)(nil).GetOperatingSystemOption), ctx, locationID, serverModelID, operatingSystemID) +} + +// GetSBMFlavorOption mocks base method. +func (m *MockLocationsService) GetSBMFlavorOption(ctx context.Context, locationID, sbmFlavorModelID int64) (*serverscom.SBMFlavor, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSBMFlavorOption", ctx, locationID, sbmFlavorModelID) + ret0, _ := ret[0].(*serverscom.SBMFlavor) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSBMFlavorOption indicates an expected call of GetSBMFlavorOption. +func (mr *MockLocationsServiceMockRecorder) GetSBMFlavorOption(ctx, locationID, sbmFlavorModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSBMFlavorOption", reflect.TypeOf((*MockLocationsService)(nil).GetSBMFlavorOption), ctx, locationID, sbmFlavorModelID) +} + +// GetSBMOperatingSystemOption mocks base method. +func (m *MockLocationsService) GetSBMOperatingSystemOption(ctx context.Context, locationID, sbmFlavorModelID, operatingSystemID int64) (*serverscom.OperatingSystemOption, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSBMOperatingSystemOption", ctx, locationID, sbmFlavorModelID, operatingSystemID) + ret0, _ := ret[0].(*serverscom.OperatingSystemOption) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSBMOperatingSystemOption indicates an expected call of GetSBMOperatingSystemOption. +func (mr *MockLocationsServiceMockRecorder) GetSBMOperatingSystemOption(ctx, locationID, sbmFlavorModelID, operatingSystemID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSBMOperatingSystemOption", reflect.TypeOf((*MockLocationsService)(nil).GetSBMOperatingSystemOption), ctx, locationID, sbmFlavorModelID, operatingSystemID) +} + +// GetServerModelOption mocks base method. +func (m *MockLocationsService) GetServerModelOption(ctx context.Context, locationID, serverModelID int64) (*serverscom.ServerModelOptionDetail, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetServerModelOption", ctx, locationID, serverModelID) + ret0, _ := ret[0].(*serverscom.ServerModelOptionDetail) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetServerModelOption indicates an expected call of GetServerModelOption. +func (mr *MockLocationsServiceMockRecorder) GetServerModelOption(ctx, locationID, serverModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetServerModelOption", reflect.TypeOf((*MockLocationsService)(nil).GetServerModelOption), ctx, locationID, serverModelID) +} + +// GetUplinkOption mocks base method. +func (m *MockLocationsService) GetUplinkOption(ctx context.Context, locationID, serverModelID, uplinkModelID int64) (*serverscom.UplinkOption, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUplinkOption", ctx, locationID, serverModelID, uplinkModelID) + ret0, _ := ret[0].(*serverscom.UplinkOption) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUplinkOption indicates an expected call of GetUplinkOption. +func (mr *MockLocationsServiceMockRecorder) GetUplinkOption(ctx, locationID, serverModelID, uplinkModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUplinkOption", reflect.TypeOf((*MockLocationsService)(nil).GetUplinkOption), ctx, locationID, serverModelID, uplinkModelID) +} + +// OperatingSystemOptions mocks base method. +func (m *MockLocationsService) OperatingSystemOptions(locationID, serverModelID int64) serverscom.Collection[serverscom.OperatingSystemOption] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "OperatingSystemOptions", locationID, serverModelID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.OperatingSystemOption]) + return ret0 +} + +// OperatingSystemOptions indicates an expected call of OperatingSystemOptions. +func (mr *MockLocationsServiceMockRecorder) OperatingSystemOptions(locationID, serverModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OperatingSystemOptions", reflect.TypeOf((*MockLocationsService)(nil).OperatingSystemOptions), locationID, serverModelID) +} + +// RAMOptions mocks base method. +func (m *MockLocationsService) RAMOptions(locationID, serverModelID int64) serverscom.Collection[serverscom.RAMOption] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RAMOptions", locationID, serverModelID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.RAMOption]) + return ret0 +} + +// RAMOptions indicates an expected call of RAMOptions. +func (mr *MockLocationsServiceMockRecorder) RAMOptions(locationID, serverModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RAMOptions", reflect.TypeOf((*MockLocationsService)(nil).RAMOptions), locationID, serverModelID) +} + +// SBMFlavorOptions mocks base method. +func (m *MockLocationsService) SBMFlavorOptions(locationID int64) serverscom.Collection[serverscom.SBMFlavor] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SBMFlavorOptions", locationID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.SBMFlavor]) + return ret0 +} + +// SBMFlavorOptions indicates an expected call of SBMFlavorOptions. +func (mr *MockLocationsServiceMockRecorder) SBMFlavorOptions(locationID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SBMFlavorOptions", reflect.TypeOf((*MockLocationsService)(nil).SBMFlavorOptions), locationID) +} + +// SBMOperatingSystemOptions mocks base method. +func (m *MockLocationsService) SBMOperatingSystemOptions(locationID, sbmFlavorModelID int64) serverscom.Collection[serverscom.OperatingSystemOption] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SBMOperatingSystemOptions", locationID, sbmFlavorModelID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.OperatingSystemOption]) + return ret0 +} + +// SBMOperatingSystemOptions indicates an expected call of SBMOperatingSystemOptions. +func (mr *MockLocationsServiceMockRecorder) SBMOperatingSystemOptions(locationID, sbmFlavorModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SBMOperatingSystemOptions", reflect.TypeOf((*MockLocationsService)(nil).SBMOperatingSystemOptions), locationID, sbmFlavorModelID) +} + +// ServerModelOptions mocks base method. +func (m *MockLocationsService) ServerModelOptions(locationID int64) serverscom.Collection[serverscom.ServerModelOption] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ServerModelOptions", locationID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.ServerModelOption]) + return ret0 +} + +// ServerModelOptions indicates an expected call of ServerModelOptions. +func (mr *MockLocationsServiceMockRecorder) ServerModelOptions(locationID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ServerModelOptions", reflect.TypeOf((*MockLocationsService)(nil).ServerModelOptions), locationID) +} + +// UplinkOptions mocks base method. +func (m *MockLocationsService) UplinkOptions(locationID, serverModelID int64) serverscom.Collection[serverscom.UplinkOption] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UplinkOptions", locationID, serverModelID) + ret0, _ := ret[0].(serverscom.Collection[serverscom.UplinkOption]) + return ret0 +} + +// UplinkOptions indicates an expected call of UplinkOptions. +func (mr *MockLocationsServiceMockRecorder) UplinkOptions(locationID, serverModelID any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UplinkOptions", reflect.TypeOf((*MockLocationsService)(nil).UplinkOptions), locationID, serverModelID) +} diff --git a/internal/output/entities/hosts.go b/internal/output/entities/hosts.go index d79e7c9..a2b80ce 100644 --- a/internal/output/entities/hosts.go +++ b/internal/output/entities/hosts.go @@ -47,6 +47,7 @@ func RegisterHostDefinition() { hostEntity := &Entity{ fields: []Field{ {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + // {ID: "RackID", Name: "RackID", Path: "RackID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Type", Name: "Type", Path: "Type", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Title", Name: "Title", Path: "Title", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "LocationID", Name: "LocationID", Path: "LocationID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, @@ -57,7 +58,9 @@ func RegisterHostDefinition() { {ID: "Configuration", Name: "Configuration", Path: "Configuration", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PrivateIPv4Address", Name: "PrivateIPv4Address", Path: "PrivateIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + // {ID: "LeaseStart", Name: "LeaseStart", Path: "LeaseStart", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "ScheduledRelease", Name: "ScheduledRelease", Path: "ScheduledRelease", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler}, + // {ID: "OobIPv4Address", Name: "OobIPv4Address", Path: "OobIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Created", Name: "Created", Path: "Created", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, }, @@ -73,6 +76,7 @@ func RegisterDedicatedServerDefinition() { serverEntity := &Entity{ fields: []Field{ {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "RackID", Name: "RackID", Path: "RackID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Type", Name: "Type", Path: "Type", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Title", Name: "Title", Path: "Title", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "LocationID", Name: "LocationID", Path: "LocationID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, @@ -83,7 +87,9 @@ func RegisterDedicatedServerDefinition() { {ID: "Configuration", Name: "Configuration", Path: "Configuration", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PrivateIPv4Address", Name: "PrivateIPv4Address", Path: "PrivateIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LeaseStart", Name: "LeaseStart", Path: "LeaseStart", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "ScheduledRelease", Name: "ScheduledRelease", Path: "ScheduledRelease", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler}, + {ID: "OobIPv4Address", Name: "OobIPv4Address", Path: "OobIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Labels", Name: "Labels", Path: "Labels", PageViewHandlerFunc: mapPvHandler}, {ID: "Created", Name: "Created", Path: "Created", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, @@ -101,6 +107,10 @@ func RegisterKubernetesBaremetalNodeDefinition() { serverEntity := &Entity{ fields: []Field{ {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "KubernetesClusterId", Name: "KubernetesClusterId", Path: "KubernetesClusterId", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "KubernetesClusterNodeId", Name: "KubernetesClusterNodeId", Path: "KubernetesClusterNodeId", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "KubernetesClusterNodeNumber", Name: "KubernetesClusterNodeNumber", Path: "KubernetesClusterNodeNumber", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "RackID", Name: "RackID", Path: "RackID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Type", Name: "Type", Path: "Type", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Title", Name: "Title", Path: "Title", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "LocationID", Name: "LocationID", Path: "LocationID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, @@ -111,7 +121,9 @@ func RegisterKubernetesBaremetalNodeDefinition() { {ID: "Configuration", Name: "Configuration", Path: "Configuration", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PrivateIPv4Address", Name: "PrivateIPv4Address", Path: "PrivateIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LeaseStart", Name: "LeaseStart", Path: "LeaseStart", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "ScheduledRelease", Name: "ScheduledRelease", Path: "ScheduledRelease", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler}, + {ID: "OobIPv4Address", Name: "OobIPv4Address", Path: "OobIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Labels", Name: "Labels", Path: "Labels", PageViewHandlerFunc: mapPvHandler}, {ID: "Created", Name: "Created", Path: "Created", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, @@ -129,6 +141,7 @@ func RegisterSBMServerDefinition() { serverEntity := &Entity{ fields: []Field{ {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "RackID", Name: "RackID", Path: "RackID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Type", Name: "Type", Path: "Type", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Title", Name: "Title", Path: "Title", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "LocationID", Name: "LocationID", Path: "LocationID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, @@ -139,7 +152,9 @@ func RegisterSBMServerDefinition() { {ID: "Configuration", Name: "Configuration", Path: "Configuration", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PrivateIPv4Address", Name: "PrivateIPv4Address", Path: "PrivateIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LeaseStart", Name: "LeaseStart", Path: "LeaseStart", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "ScheduledRelease", Name: "ScheduledRelease", Path: "ScheduledRelease", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler}, + {ID: "OobIPv4Address", Name: "OobIPv4Address", Path: "OobIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "Labels", Name: "Labels", Path: "Labels", PageViewHandlerFunc: mapPvHandler}, {ID: "Created", Name: "Created", Path: "Created", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, diff --git a/internal/output/entities/init.go b/internal/output/entities/init.go index d88bf12..e9cdb31 100644 --- a/internal/output/entities/init.go +++ b/internal/output/entities/init.go @@ -18,4 +18,5 @@ func init() { RegisterRackDefinition() RegisterInvoiceDefinition() RegisterAccountDefinition() + RegisterLocationDefinition() } diff --git a/internal/output/entities/location.go b/internal/output/entities/location.go new file mode 100644 index 0000000..fc55977 --- /dev/null +++ b/internal/output/entities/location.go @@ -0,0 +1,31 @@ +package entities + +import ( + "log" + "reflect" + + serverscom "github.com/serverscom/serverscom-go-client/pkg" +) + +var ( + LocationType = reflect.TypeOf(serverscom.Location{}) +) + +func RegisterLocationDefinition() { + locationEntity := &Entity{ + fields: []Field{ + {ID: "ID", Name: "ID", Path: "ID", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Name", Name: "Name", Path: "Name", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Status", Name: "Status", Path: "Status", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "Code", Name: "Code", Path: "Code", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, + {ID: "SupportedFeatures", Name: "SupportedFeatures", Path: "SupportedFeatures", PageViewHandlerFunc: slicePvHandler}, + {ID: "L2SegmentsEnabled", Name: "L2SegmentsEnabled", Path: "L2SegmentsEnabled", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "PrivateRacksEnabled", Name: "PrivateRacksEnabled", Path: "PrivateRacksEnabled", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LoadBalancersEnabled", Name: "LoadBalancersEnabled", Path: "LoadBalancersEnabled", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + }, + eType: LocationType, + } + if err := Registry.Register(locationEntity); err != nil { + log.Fatal(err) + } +} diff --git a/testdata/entities/hosts/create_ds_resp.json b/testdata/entities/hosts/create_ds_resp.json index 5e5b5a4..11e39b6 100644 --- a/testdata/entities/hosts/create_ds_resp.json +++ b/testdata/entities/hosts/create_ds_resp.json @@ -1,6 +1,7 @@ [ { "id": "testId", + "rack_id": "testId", "type": "dedicated_server", "title": "example.aa", "location_id": 0, @@ -11,7 +12,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/create_sbm_resp.json b/testdata/entities/hosts/create_sbm_resp.json index 546b2de..e6724f4 100644 --- a/testdata/entities/hosts/create_sbm_resp.json +++ b/testdata/entities/hosts/create_sbm_resp.json @@ -1,6 +1,7 @@ [ { "id": "testId", + "rack_id": "testId", "type": "sbm_server", "title": "example.aa", "location_id": 0, @@ -11,7 +12,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/get_ds.json b/testdata/entities/hosts/get_ds.json index 0b9c042..ed236e3 100644 --- a/testdata/entities/hosts/get_ds.json +++ b/testdata/entities/hosts/get_ds.json @@ -1,5 +1,6 @@ { "id": "testId", + "rack_id": "testId", "type": "dedicated_server", "title": "example.aa", "location_id": 0, @@ -10,7 +11,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/get_ds.txt b/testdata/entities/hosts/get_ds.txt index 1b3e9d2..ff67a25 100644 --- a/testdata/entities/hosts/get_ds.txt +++ b/testdata/entities/hosts/get_ds.txt @@ -1,2 +1,2 @@ -ID Title Status Created Updated -testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z +ID RackID Title Status Created Updated +testId testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/get_ds.yaml b/testdata/entities/hosts/get_ds.yaml index f1ab606..013c84b 100644 --- a/testdata/entities/hosts/get_ds.yaml +++ b/testdata/entities/hosts/get_ds.yaml @@ -1,4 +1,5 @@ id: testId +rackid: testId type: dedicated_server title: example.aa locationid: 0 @@ -9,7 +10,9 @@ powerstatus: "" configuration: "" privateipv4address: null publicipv4address: null +leasestart: "" scheduledrelease: null +oobipv4address: "" configurationdetails: ramsize: 0 servermodelid: null diff --git a/testdata/entities/hosts/get_kbm.json b/testdata/entities/hosts/get_kbm.json index c427763..9c836d8 100644 --- a/testdata/entities/hosts/get_kbm.json +++ b/testdata/entities/hosts/get_kbm.json @@ -1,5 +1,9 @@ { "id": "testId", + "kubernetes_cluster_id": "testId", + "kubernetes_cluster_node_id": "testId", + "kubernetes_cluster_node_number": 1, + "rack_id": "testId", "type": "kubernetes_baremetal_node", "title": "example.aa", "location_id": 0, @@ -10,7 +14,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/get_kbm.txt b/testdata/entities/hosts/get_kbm.txt index 1b3e9d2..ff67a25 100644 --- a/testdata/entities/hosts/get_kbm.txt +++ b/testdata/entities/hosts/get_kbm.txt @@ -1,2 +1,2 @@ -ID Title Status Created Updated -testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z +ID RackID Title Status Created Updated +testId testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/get_kbm.yaml b/testdata/entities/hosts/get_kbm.yaml index ab9a00b..8e49d21 100644 --- a/testdata/entities/hosts/get_kbm.yaml +++ b/testdata/entities/hosts/get_kbm.yaml @@ -1,4 +1,8 @@ id: testId +kubernetesclusterid: testId +kubernetesclusternodeid: testId +kubernetesclusternodenumber: 1 +rackid: testId type: kubernetes_baremetal_node title: example.aa locationid: 0 @@ -9,7 +13,9 @@ powerstatus: "" configuration: "" privateipv4address: null publicipv4address: null +leasestart: "" scheduledrelease: null +oobipv4address: "" configurationdetails: ramsize: 0 servermodelid: null diff --git a/testdata/entities/hosts/get_sbm.json b/testdata/entities/hosts/get_sbm.json index c9f75a0..fd10f4f 100644 --- a/testdata/entities/hosts/get_sbm.json +++ b/testdata/entities/hosts/get_sbm.json @@ -1,5 +1,6 @@ { "id": "testId", + "rack_id": "testId", "type": "sbm_server", "title": "example.aa", "location_id": 0, @@ -10,7 +11,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/get_sbm.txt b/testdata/entities/hosts/get_sbm.txt index 1b3e9d2..ff67a25 100644 --- a/testdata/entities/hosts/get_sbm.txt +++ b/testdata/entities/hosts/get_sbm.txt @@ -1,2 +1,2 @@ -ID Title Status Created Updated -testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z +ID RackID Title Status Created Updated +testId testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/get_sbm.yaml b/testdata/entities/hosts/get_sbm.yaml index 990b8bf..10958d6 100644 --- a/testdata/entities/hosts/get_sbm.yaml +++ b/testdata/entities/hosts/get_sbm.yaml @@ -1,4 +1,5 @@ id: testId +rackid: testId type: sbm_server title: example.aa locationid: 0 @@ -9,7 +10,9 @@ powerstatus: "" configuration: "" privateipv4address: null publicipv4address: null +leasestart: "" scheduledrelease: null +oobipv4address: "" configurationdetails: ramsize: 0 servermodelid: null diff --git a/testdata/entities/hosts/release_ds_resp.json b/testdata/entities/hosts/release_ds_resp.json index c187c7e..531ade2 100644 --- a/testdata/entities/hosts/release_ds_resp.json +++ b/testdata/entities/hosts/release_ds_resp.json @@ -1,5 +1,6 @@ { "id": "testId", + "rack_id": "testId", "type": "dedicated_server", "title": "example.aa", "location_id": 0, @@ -10,7 +11,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": "2025-01-01T12:00:00Z", + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/update_ds_resp.json b/testdata/entities/hosts/update_ds_resp.json index e4555e8..c76aced 100644 --- a/testdata/entities/hosts/update_ds_resp.json +++ b/testdata/entities/hosts/update_ds_resp.json @@ -1,5 +1,6 @@ { "id": "testId", + "rack_id": "testId", "type": "dedicated_server", "title": "example.aa", "location_id": 0, @@ -10,7 +11,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/update_kbm_resp.json b/testdata/entities/hosts/update_kbm_resp.json index 50d7f63..153bc4e 100644 --- a/testdata/entities/hosts/update_kbm_resp.json +++ b/testdata/entities/hosts/update_kbm_resp.json @@ -1,5 +1,9 @@ { "id": "testId", + "kubernetes_cluster_id": "testId", + "kubernetes_cluster_node_id": "testId", + "kubernetes_cluster_node_number": 1, + "rack_id": "testId", "type": "kubernetes_baremetal_node", "title": "example.aa", "location_id": 0, @@ -10,7 +14,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/hosts/update_sbm_resp.json b/testdata/entities/hosts/update_sbm_resp.json index bf5318d..7edd9d1 100644 --- a/testdata/entities/hosts/update_sbm_resp.json +++ b/testdata/entities/hosts/update_sbm_resp.json @@ -1,5 +1,6 @@ { "id": "testId", + "rack_id": "testId", "type": "sbm_server", "title": "example.aa", "location_id": 0, @@ -10,7 +11,9 @@ "configuration": "", "private_ipv4_address": null, "public_ipv4_address": null, + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", "configuration_details": { "ram_size": 0, "server_model_id": null, diff --git a/testdata/entities/locations/get.json b/testdata/entities/locations/get.json new file mode 100644 index 0000000..0c1c187 --- /dev/null +++ b/testdata/entities/locations/get.json @@ -0,0 +1,13 @@ +{ + "id": 1, + "name": "test-location", + "status": "active", + "code": "test", + "supported_features": [ + "feature1", + "feature2" + ], + "l2_segments_enabled": false, + "private_racks_enabled": false, + "load_balancers_enabled": false +} \ No newline at end of file diff --git a/testdata/entities/locations/get.txt b/testdata/entities/locations/get.txt new file mode 100644 index 0000000..53d9457 --- /dev/null +++ b/testdata/entities/locations/get.txt @@ -0,0 +1,2 @@ +ID Name Status Code +1 test-location active test diff --git a/testdata/entities/locations/get.yaml b/testdata/entities/locations/get.yaml new file mode 100644 index 0000000..f593b8f --- /dev/null +++ b/testdata/entities/locations/get.yaml @@ -0,0 +1,10 @@ +id: 1 +name: test-location +status: active +code: test +supportedfeatures: + - feature1 + - feature2 +l2segmentsenabled: false +privateracksenabled: false +loadbalancersenabled: false diff --git a/testdata/entities/locations/list.json b/testdata/entities/locations/list.json new file mode 100644 index 0000000..b5cfeab --- /dev/null +++ b/testdata/entities/locations/list.json @@ -0,0 +1,15 @@ +[ + { + "id": 1, + "name": "test-location", + "status": "active", + "code": "test", + "supported_features": [ + "feature1", + "feature2" + ], + "l2_segments_enabled": false, + "private_racks_enabled": false, + "load_balancers_enabled": false + } +] \ No newline at end of file diff --git a/testdata/entities/locations/list_all.json b/testdata/entities/locations/list_all.json new file mode 100644 index 0000000..b54c022 --- /dev/null +++ b/testdata/entities/locations/list_all.json @@ -0,0 +1,28 @@ +[ + { + "id": 1, + "name": "test-location", + "status": "active", + "code": "test", + "supported_features": [ + "feature1", + "feature2" + ], + "l2_segments_enabled": false, + "private_racks_enabled": false, + "load_balancers_enabled": false + }, + { + "id": 2, + "name": "test-location 2", + "status": "active", + "code": "test", + "supported_features": [ + "feature1", + "feature2" + ], + "l2_segments_enabled": false, + "private_racks_enabled": false, + "load_balancers_enabled": false + } +] \ No newline at end of file diff --git a/testdata/entities/locations/list_pageview.txt b/testdata/entities/locations/list_pageview.txt new file mode 100644 index 0000000..f883ce4 --- /dev/null +++ b/testdata/entities/locations/list_pageview.txt @@ -0,0 +1,19 @@ +ID: 1 +Name: test-location +Status: active +Code: test +SupportedFeatures: feature1 + feature2 +L2SegmentsEnabled: false +PrivateRacksEnabled: false +LoadBalancersEnabled: false +--- +ID: 2 +Name: test-location 2 +Status: active +Code: test +SupportedFeatures: feature1 + feature2 +L2SegmentsEnabled: false +PrivateRacksEnabled: false +LoadBalancersEnabled: false diff --git a/testdata/entities/locations/list_template.txt b/testdata/entities/locations/list_template.txt new file mode 100644 index 0000000..3f39e39 --- /dev/null +++ b/testdata/entities/locations/list_template.txt @@ -0,0 +1,2 @@ +Name: test-location +Name: test-location 2