From 981cf0e7483009b7149da334e95d88f0b96f1c7d Mon Sep 17 00:00:00 2001 From: Oleg Isakov Date: Wed, 27 Aug 2025 13:39:32 +0300 Subject: [PATCH] refactor hosts list to use separate api calls; update hosts default fields; update tests --- cmd/base/list_options.go | 14 + cmd/entities/hosts/hosts.go | 7 +- cmd/entities/hosts/hosts_test.go | 275 ++++++++++++++---- cmd/entities/hosts/list.go | 88 ++++-- go.mod | 2 +- go.sum | 4 +- internal/mocks/hosts_service.go | 42 +++ internal/output/entities/hosts.go | 49 ++-- testdata/entities/hosts/create_ds_resp.json | 26 +- testdata/entities/hosts/create_sbm_resp.json | 26 +- testdata/entities/hosts/get_ds.json | 26 +- testdata/entities/hosts/get_ds.txt | 4 +- testdata/entities/hosts/get_ds.yaml | 26 +- testdata/entities/hosts/get_kbm.json | 26 +- testdata/entities/hosts/get_kbm.txt | 4 +- testdata/entities/hosts/get_kbm.yaml | 26 +- testdata/entities/hosts/get_sbm.json | 26 +- testdata/entities/hosts/get_sbm.txt | 4 +- testdata/entities/hosts/get_sbm.yaml | 26 +- testdata/entities/hosts/list_ds.json | 21 +- testdata/entities/hosts/list_ds_all.json | 42 ++- testdata/entities/hosts/list_ds_pageview.txt | 40 ++- testdata/entities/hosts/list_hosts.json | 34 +++ .../entities/hosts/list_hosts_pageview.txt | 29 ++ .../entities/hosts/list_hosts_template.txt | 2 + testdata/entities/hosts/list_kbm.json | 24 +- testdata/entities/hosts/list_kbm_all.json | 48 ++- testdata/entities/hosts/list_kbm_pageview.txt | 94 ++++-- testdata/entities/hosts/list_sbm.json | 21 +- testdata/entities/hosts/list_sbm_all.json | 42 ++- testdata/entities/hosts/list_sbm_pageview.txt | 40 ++- testdata/entities/hosts/release_ds_resp.json | 26 +- testdata/entities/hosts/update_ds_resp.json | 26 +- testdata/entities/hosts/update_kbm_resp.json | 26 +- testdata/entities/hosts/update_sbm_resp.json | 26 +- 35 files changed, 907 insertions(+), 335 deletions(-) create mode 100644 testdata/entities/hosts/list_hosts.json create mode 100644 testdata/entities/hosts/list_hosts_pageview.txt create mode 100644 testdata/entities/hosts/list_hosts_template.txt diff --git a/cmd/base/list_options.go b/cmd/base/list_options.go index a54f213..6602048 100644 --- a/cmd/base/list_options.go +++ b/cmd/base/list_options.go @@ -445,3 +445,17 @@ func (o *AttachedSubnetworksOption[T]) ApplyToCollection(collection serverscom.C collection.SetParam("attached", "true") } } + +type RackIDOption[T any] struct { + rackID string +} + +func (o *RackIDOption[T]) AddFlags(cmd *cobra.Command) { + cmd.Flags().StringVar(&o.rackID, "rack-id", "", "Filter results by rack ID where host is deployed") +} + +func (o *RackIDOption[T]) ApplyToCollection(collection serverscom.Collection[T]) { + if o.rackID != "" { + collection.SetParam("rack_id", o.rackID) + } +} diff --git a/cmd/entities/hosts/hosts.go b/cmd/entities/hosts/hosts.go index a769294..6b1b81b 100644 --- a/cmd/entities/hosts/hosts.go +++ b/cmd/entities/hosts/hosts.go @@ -56,6 +56,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command { newGetDSNetworkCmd, newAddDSNetworkCmd, newDeleteDSNetworkCmd, + newListDSCmd, }, }, { @@ -69,6 +70,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command { }, extraCmds: []func(*base.CmdContext) *cobra.Command{ newUpdateKBMCmd, + newListKBMCmd, }, }, { @@ -85,6 +87,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command { newAddSBMCmd, newUpdateSBMCmd, newSBMReleaseCmd, + newListSBMCmd, }, }, } @@ -102,7 +105,7 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command { } // hosts list cmd - cmd.AddCommand(newListCmd(cmdContext, nil)) + cmd.AddCommand(newListCmd(cmdContext)) for _, ht := range hostTypeCmds { cmd.AddCommand(newHostTypeCmd(cmdContext, ht)) @@ -121,7 +124,6 @@ func newHostTypeCmd(cmdContext *base.CmdContext, hostTypeCmd HostTypeCmd) *cobra Run: base.UsageRun, } - hostCmd.AddCommand(newListCmd(cmdContext, &hostTypeCmd)) hostCmd.AddCommand(newGetCmd(cmdContext, &hostTypeCmd)) if hostTypeCmd.managers.powerMgr != nil { @@ -146,7 +148,6 @@ func getHostsEntities() (map[string]entities.EntityInterface, error) { return nil, err } result["hosts"] = hostsEntity - result["list"] = hostsEntity dsEntity, err := entities.Registry.GetEntityFromValue(serverscom.DedicatedServer{}) if err != nil { diff --git a/cmd/entities/hosts/hosts_test.go b/cmd/entities/hosts/hosts_test.go index 009dce5..dd46693 100644 --- a/cmd/entities/hosts/hosts_test.go +++ b/cmd/entities/hosts/hosts_test.go @@ -14,25 +14,45 @@ import ( ) var ( - testId = "testId" - testNetworkId = "testNetId" - fixtureBasePath = filepath.Join("..", "..", "..", "testdata", "entities", "hosts") - fixedTime = time.Date(2025, 1, 1, 12, 0, 0, 0, time.UTC) - testHost = serverscom.Host{ - ID: testId, - Title: "example.aa", - Status: "active", - Created: fixedTime, - Updated: fixedTime, + testId = "testId" + testNetworkId = "testNetId" + fixtureBasePath = filepath.Join("..", "..", "..", "testdata", "entities", "hosts") + fixedTime = time.Date(2025, 1, 1, 12, 0, 0, 0, time.UTC) + testPublicIP = "1.2.3.4" + testLocationCode = "test" + testHost = serverscom.Host{ + ID: testId, + Title: "example.aa", + Status: "active", + PublicIPv4Address: &testPublicIP, + LocationCode: testLocationCode, + Created: fixedTime, + Updated: fixedTime, + } + testConfigDetails = serverscom.ConfigurationDetails{ + RAMSize: 2, + ServerModelID: testutils.PtrInt64(1), + ServerModelName: testutils.PtrString("server-model-123"), + PublicUplinkID: testutils.PtrInt64(2), + PublicUplinkName: testutils.PtrString("Public 1 Gbps without redundancy"), + PrivateUplinkID: testutils.PtrInt64(3), + PrivateUplinkName: testutils.PtrString("Private 1 Gbps without redundancy"), + BandwidthID: testutils.PtrInt64(4), + BandwidthName: testutils.PtrString("20000 GB"), + OperatingSystemID: testutils.PtrInt64(5), + OperatingSystemFullName: testutils.PtrString("CentOS 7 x86_64"), } testDS = serverscom.DedicatedServer{ - ID: testId, - RackID: testId, - Type: "dedicated_server", - Title: "example.aa", - Status: "active", - Created: fixedTime, - Updated: fixedTime, + ID: testId, + RackID: testId, + Type: "dedicated_server", + Title: "example.aa", + Status: "active", + LocationCode: testLocationCode, + PublicIPv4Address: &testPublicIP, + ConfigurationDetails: testConfigDetails, + Created: fixedTime, + Updated: fixedTime, } testKBM = serverscom.KubernetesBaremetalNode{ ID: testId, @@ -43,17 +63,23 @@ var ( Type: "kubernetes_baremetal_node", Title: "example.aa", Status: "active", + LocationCode: testLocationCode, + PublicIPv4Address: &testPublicIP, + ConfigurationDetails: testConfigDetails, Created: fixedTime, Updated: fixedTime, } testSBM = serverscom.SBMServer{ - ID: testId, - RackID: testId, - Type: "sbm_server", - Title: "example.aa", - Status: "active", - Created: fixedTime, - Updated: fixedTime, + ID: testId, + RackID: testId, + Type: "sbm_server", + Title: "example.aa", + Status: "active", + LocationCode: testLocationCode, + PublicIPv4Address: &testPublicIP, + ConfigurationDetails: testConfigDetails, + Created: fixedTime, + Updated: fixedTime, } netTitle = "Some Net" cidr = "100.0.8.0/29" @@ -71,6 +97,129 @@ var ( } ) +func TestListHostsCmd(t *testing.T) { + testServer1 := testHost + testServer1.Type = "dedicated_server" + testServer2 := testServer1 + testServer2.ID = "testId2" + testServer2.Type = "sbm_server" + testServer2.Title = "example.bb" + + testCases := []struct { + name string + output string + args []string + expectedOutput []byte + expectError bool + configureMock func(*mocks.MockCollection[serverscom.Host]) + }{ + { + name: "list all hosts", + output: "json", + args: []string{"-A"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_hosts.json")), + configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + mock.EXPECT(). + Collect(gomock.Any()). + Return([]serverscom.Host{ + testServer1, + testServer2, + }, nil) + }, + }, + { + name: "list hosts with template", + args: []string{"--template", "{{range .}}Title: {{.Title}} Type: {{.Type}}\n{{end}}"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_hosts_template.txt")), + configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.Host{ + testServer1, + testServer2, + }, nil) + }, + }, + { + name: "list hosts with pageView", + args: []string{"--page-view"}, + expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_hosts_pageview.txt")), + configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + mock.EXPECT(). + List(gomock.Any()). + Return([]serverscom.Host{ + testServer1, + testServer2, + }, nil) + }, + }, + { + name: "list hosts with error", + expectError: true, + configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + mock.EXPECT(). + List(gomock.Any()). + Return(nil, errors.New("some error")) + }, + }, + } + + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + + hostsServiceHandler := mocks.NewMockHostsService(mockCtrl) + collectionHandler := mocks.NewMockCollection[serverscom.Host](mockCtrl) + + hostsServiceHandler.EXPECT(). + Collection(). + Return(collectionHandler). + AnyTimes() + + collectionHandler.EXPECT(). + SetParam(gomock.Any(), gomock.Any()). + Return(collectionHandler). + AnyTimes() + + scClient := serverscom.NewClientWithEndpoint("", "") + scClient.Hosts = hostsServiceHandler + + 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) + hostsCmd := NewCmd(testCmdContext) + + args := []string{"hosts", "list"} + if len(tc.args) > 0 { + args = append(args, tc.args...) + } + if tc.output != "" { + args = append(args, "--output", tc.output) + } + + builder := testutils.NewTestCommandBuilder(). + WithCommand(hostsCmd). + 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 TestAddDSCmd(t *testing.T) { expectedInput := serverscom.DedicatedServerCreateInput{ ServerModelID: 1234, @@ -544,7 +693,7 @@ func TestGetSBMCmd(t *testing.T) { } func TestListDSCmd(t *testing.T) { - testServer1 := testHost + testServer1 := testDS testServer1.Type = "dedicated_server" testServer2 := testServer1 testServer2.ID = "testId2" @@ -556,17 +705,17 @@ func TestListDSCmd(t *testing.T) { args []string expectedOutput []byte expectError bool - configureMock func(*mocks.MockCollection[serverscom.Host]) + configureMock func(*mocks.MockCollection[serverscom.DedicatedServer]) }{ { name: "list all dedicated servers", output: "json", args: []string{"-A"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_ds_all.json")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.DedicatedServer]) { mock.EXPECT(). Collect(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.DedicatedServer{ testServer1, testServer2, }, nil) @@ -576,10 +725,10 @@ func TestListDSCmd(t *testing.T) { name: "list dedicated servers", output: "json", expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_ds.json")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.DedicatedServer]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.DedicatedServer{ testServer1, }, nil) }, @@ -588,10 +737,10 @@ func TestListDSCmd(t *testing.T) { name: "list dedicated servers with template", args: []string{"--template", "{{range .}}Title: {{.Title}} Type: {{.Type}}\n{{end}}"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_ds_template.txt")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.DedicatedServer]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.DedicatedServer{ testServer1, testServer2, }, nil) @@ -601,10 +750,10 @@ func TestListDSCmd(t *testing.T) { name: "list dedicated servers with pageView", args: []string{"--page-view"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_ds_pageview.txt")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.DedicatedServer]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.DedicatedServer{ testServer1, testServer2, }, nil) @@ -613,7 +762,7 @@ func TestListDSCmd(t *testing.T) { { name: "list dedicated servers with error", expectError: true, - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.DedicatedServer]) { mock.EXPECT(). List(gomock.Any()). Return(nil, errors.New("some error")) @@ -625,10 +774,10 @@ func TestListDSCmd(t *testing.T) { defer mockCtrl.Finish() hostsServiceHandler := mocks.NewMockHostsService(mockCtrl) - collectionHandler := mocks.NewMockCollection[serverscom.Host](mockCtrl) + collectionHandler := mocks.NewMockCollection[serverscom.DedicatedServer](mockCtrl) hostsServiceHandler.EXPECT(). - Collection(). + ListDedicatedServers(). Return(collectionHandler). AnyTimes() @@ -678,7 +827,7 @@ func TestListDSCmd(t *testing.T) { } func TestListKBMCmd(t *testing.T) { - testServer1 := testHost + testServer1 := testKBM testServer1.Type = "kubernetes_baremetal_node" testServer2 := testServer1 testServer2.ID = "testId2" @@ -690,17 +839,17 @@ func TestListKBMCmd(t *testing.T) { args []string expectedOutput []byte expectError bool - configureMock func(*mocks.MockCollection[serverscom.Host]) + configureMock func(*mocks.MockCollection[serverscom.KubernetesBaremetalNode]) }{ { name: "list all KMB nodes", output: "json", args: []string{"-A"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_kbm_all.json")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.KubernetesBaremetalNode]) { mock.EXPECT(). Collect(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.KubernetesBaremetalNode{ testServer1, testServer2, }, nil) @@ -710,10 +859,10 @@ func TestListKBMCmd(t *testing.T) { name: "list KBM nodes", output: "json", expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_kbm.json")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.KubernetesBaremetalNode]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.KubernetesBaremetalNode{ testServer1, }, nil) }, @@ -722,10 +871,10 @@ func TestListKBMCmd(t *testing.T) { name: "list KBM nodes with template", args: []string{"--template", "{{range .}}Title: {{.Title}} Type: {{.Type}}\n{{end}}"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_kbm_template.txt")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.KubernetesBaremetalNode]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.KubernetesBaremetalNode{ testServer1, testServer2, }, nil) @@ -735,10 +884,10 @@ func TestListKBMCmd(t *testing.T) { name: "list KBM nodes with pageView", args: []string{"--page-view"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_kbm_pageview.txt")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.KubernetesBaremetalNode]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.KubernetesBaremetalNode{ testServer1, testServer2, }, nil) @@ -747,7 +896,7 @@ func TestListKBMCmd(t *testing.T) { { name: "list KBM nodes with error", expectError: true, - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.KubernetesBaremetalNode]) { mock.EXPECT(). List(gomock.Any()). Return(nil, errors.New("some error")) @@ -759,10 +908,10 @@ func TestListKBMCmd(t *testing.T) { defer mockCtrl.Finish() hostsServiceHandler := mocks.NewMockHostsService(mockCtrl) - collectionHandler := mocks.NewMockCollection[serverscom.Host](mockCtrl) + collectionHandler := mocks.NewMockCollection[serverscom.KubernetesBaremetalNode](mockCtrl) hostsServiceHandler.EXPECT(). - Collection(). + ListKubernetesBaremetalNodes(). Return(collectionHandler). AnyTimes() @@ -812,7 +961,7 @@ func TestListKBMCmd(t *testing.T) { } func TestListSBMCmd(t *testing.T) { - testServer1 := testHost + testServer1 := testSBM testServer1.Type = "sbm_server" testServer2 := testServer1 testServer2.ID = "testId2" @@ -824,17 +973,17 @@ func TestListSBMCmd(t *testing.T) { args []string expectedOutput []byte expectError bool - configureMock func(*mocks.MockCollection[serverscom.Host]) + configureMock func(*mocks.MockCollection[serverscom.SBMServer]) }{ { name: "list all SBM servers", output: "json", args: []string{"-A"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_sbm_all.json")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.SBMServer]) { mock.EXPECT(). Collect(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.SBMServer{ testServer1, testServer2, }, nil) @@ -844,10 +993,10 @@ func TestListSBMCmd(t *testing.T) { name: "list SBM servers", output: "json", expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_sbm.json")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.SBMServer]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.SBMServer{ testServer1, }, nil) }, @@ -856,10 +1005,10 @@ func TestListSBMCmd(t *testing.T) { name: "list SBM servers with template", args: []string{"--template", "{{range .}}Title: {{.Title}} Type: {{.Type}}\n{{end}}"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_sbm_template.txt")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.SBMServer]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.SBMServer{ testServer1, testServer2, }, nil) @@ -869,10 +1018,10 @@ func TestListSBMCmd(t *testing.T) { name: "list SBM servers with pageView", args: []string{"--page-view"}, expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_sbm_pageview.txt")), - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.SBMServer]) { mock.EXPECT(). List(gomock.Any()). - Return([]serverscom.Host{ + Return([]serverscom.SBMServer{ testServer1, testServer2, }, nil) @@ -881,7 +1030,7 @@ func TestListSBMCmd(t *testing.T) { { name: "list SBM servers with error", expectError: true, - configureMock: func(mock *mocks.MockCollection[serverscom.Host]) { + configureMock: func(mock *mocks.MockCollection[serverscom.SBMServer]) { mock.EXPECT(). List(gomock.Any()). Return(nil, errors.New("some error")) @@ -893,10 +1042,10 @@ func TestListSBMCmd(t *testing.T) { defer mockCtrl.Finish() hostsServiceHandler := mocks.NewMockHostsService(mockCtrl) - collectionHandler := mocks.NewMockCollection[serverscom.Host](mockCtrl) + collectionHandler := mocks.NewMockCollection[serverscom.SBMServer](mockCtrl) hostsServiceHandler.EXPECT(). - Collection(). + ListSBMServers(). Return(collectionHandler). AnyTimes() diff --git a/cmd/entities/hosts/list.go b/cmd/entities/hosts/list.go index 5a343fe..710a7ab 100644 --- a/cmd/entities/hosts/list.go +++ b/cmd/entities/hosts/list.go @@ -6,54 +6,78 @@ import ( "github.com/spf13/cobra" ) -type hostListOptions struct { - base.BaseListOptions[serverscom.Host] - rackID string - locationID string -} +func newListCmd(cmdContext *base.CmdContext) *cobra.Command { + factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.Host] { + scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient() + collection := scClient.Hosts.Collection() -func (o *hostListOptions) AddFlags(cmd *cobra.Command) { - o.BaseListOptions.AddFlags(cmd) + return collection + } + + opts := base.NewListOptions( + &base.BaseListOptions[serverscom.Host]{}, + &base.LocationIDOption[serverscom.Host]{}, + &base.RackIDOption[serverscom.Host]{}, + &base.LabelSelectorOption[serverscom.Host]{}, + &base.SearchPatternOption[serverscom.Host]{}, + ) - flags := cmd.Flags() - flags.StringVar(&o.rackID, "rack-id", "", "Filter by rack ID") - flags.StringVar(&o.locationID, "location-id", "", "Filter by location ID") + return base.NewListCmd("list", "hosts", factory, cmdContext, opts...) } -func (o *hostListOptions) ApplyToCollection(collection serverscom.Collection[serverscom.Host]) { - o.BaseListOptions.ApplyToCollection(collection) +func newListDSCmd(cmdContext *base.CmdContext) *cobra.Command { + factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.DedicatedServer] { + scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient() + collection := scClient.Hosts.ListDedicatedServers() - if o.rackID != "" { - collection.SetParam("rack_id", o.rackID) - } - if o.locationID != "" { - collection.SetParam("location_id", o.locationID) + return collection } + + opts := base.NewListOptions( + &base.BaseListOptions[serverscom.DedicatedServer]{}, + &base.LocationIDOption[serverscom.DedicatedServer]{}, + &base.RackIDOption[serverscom.DedicatedServer]{}, + &base.LabelSelectorOption[serverscom.DedicatedServer]{}, + &base.SearchPatternOption[serverscom.DedicatedServer]{}, + ) + + return base.NewListCmd("list", "dedicated servers", factory, cmdContext, opts...) } -func newListCmd(cmdContext *base.CmdContext, hostType *HostTypeCmd) *cobra.Command { - factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.Host] { +func newListKBMCmd(cmdContext *base.CmdContext) *cobra.Command { + factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.KubernetesBaremetalNode] { scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient() - collection := scClient.Hosts.Collection() - - if hostType != nil && hostType.typeFlag != "" { - collection = collection.SetParam("type", hostType.typeFlag) - } + collection := scClient.Hosts.ListKubernetesBaremetalNodes() return collection } opts := base.NewListOptions( - &hostListOptions{}, - &base.HiddenTypeOption[serverscom.Host]{}, - &base.LabelSelectorOption[serverscom.Host]{}, - &base.SearchPatternOption[serverscom.Host]{}, + &base.BaseListOptions[serverscom.KubernetesBaremetalNode]{}, + &base.LocationIDOption[serverscom.KubernetesBaremetalNode]{}, + &base.RackIDOption[serverscom.KubernetesBaremetalNode]{}, + &base.LabelSelectorOption[serverscom.KubernetesBaremetalNode]{}, + &base.SearchPatternOption[serverscom.KubernetesBaremetalNode]{}, ) - entityName := "Hosts" - if hostType != nil { - entityName = hostType.entityName + return base.NewListCmd("list", "dedicated servers", factory, cmdContext, opts...) +} + +func newListSBMCmd(cmdContext *base.CmdContext) *cobra.Command { + factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.SBMServer] { + scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient() + collection := scClient.Hosts.ListSBMServers() + + return collection } - return base.NewListCmd("list", entityName, factory, cmdContext, opts...) + opts := base.NewListOptions( + &base.BaseListOptions[serverscom.SBMServer]{}, + &base.LocationIDOption[serverscom.SBMServer]{}, + &base.RackIDOption[serverscom.SBMServer]{}, + &base.LabelSelectorOption[serverscom.SBMServer]{}, + &base.SearchPatternOption[serverscom.SBMServer]{}, + ) + + return base.NewListCmd("list", "dedicated servers", factory, cmdContext, opts...) } diff --git a/go.mod b/go.mod index b5857f9..c5fe7f1 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/creack/pty v1.1.24 github.com/jmespath/go-jmespath v0.4.0 github.com/onsi/gomega v1.38.0 - github.com/serverscom/serverscom-go-client v1.0.18 + github.com/serverscom/serverscom-go-client v1.0.20 github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.7 github.com/spf13/viper v1.20.1 diff --git a/go.sum b/go.sum index 2df103c..271a58b 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.10.0 h1:FM8Cv6j2KqIhM2ZK7HZjm4mpj9NBktLgowT1aN9q5Cc= github.com/sagikazarmark/locafero v0.10.0/go.mod h1:Ieo3EUsjifvQu4NZwV5sPd4dwvu0OCgEQV7vjc9yDjw= -github.com/serverscom/serverscom-go-client v1.0.18 h1:GsPCStqUFWjzcMepaJDXjFUymx0W5DUNAoOXz2s7MVI= -github.com/serverscom/serverscom-go-client v1.0.18/go.mod h1:/Nf+XygKOxm19Sl2gvMzT55O4X+tWDkj/UM4mjzfKgM= +github.com/serverscom/serverscom-go-client v1.0.20 h1:a7LwhBvJJivyxnxbzDO7i3OVYe904oYHV6lcQwdoXYg= +github.com/serverscom/serverscom-go-client v1.0.20/go.mod h1:/Nf+XygKOxm19Sl2gvMzT55O4X+tWDkj/UM4mjzfKgM= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= diff --git a/internal/mocks/hosts_service.go b/internal/mocks/hosts_service.go index 3897150..80b9f12 100644 --- a/internal/mocks/hosts_service.go +++ b/internal/mocks/hosts_service.go @@ -335,6 +335,48 @@ func (mr *MockHostsServiceMockRecorder) GetSBMServer(ctx, id any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSBMServer", reflect.TypeOf((*MockHostsService)(nil).GetSBMServer), ctx, id) } +// ListDedicatedServers mocks base method. +func (m *MockHostsService) ListDedicatedServers() serverscom.Collection[serverscom.DedicatedServer] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListDedicatedServers") + ret0, _ := ret[0].(serverscom.Collection[serverscom.DedicatedServer]) + return ret0 +} + +// ListDedicatedServers indicates an expected call of ListDedicatedServers. +func (mr *MockHostsServiceMockRecorder) ListDedicatedServers() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDedicatedServers", reflect.TypeOf((*MockHostsService)(nil).ListDedicatedServers)) +} + +// ListKubernetesBaremetalNodes mocks base method. +func (m *MockHostsService) ListKubernetesBaremetalNodes() serverscom.Collection[serverscom.KubernetesBaremetalNode] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListKubernetesBaremetalNodes") + ret0, _ := ret[0].(serverscom.Collection[serverscom.KubernetesBaremetalNode]) + return ret0 +} + +// ListKubernetesBaremetalNodes indicates an expected call of ListKubernetesBaremetalNodes. +func (mr *MockHostsServiceMockRecorder) ListKubernetesBaremetalNodes() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListKubernetesBaremetalNodes", reflect.TypeOf((*MockHostsService)(nil).ListKubernetesBaremetalNodes)) +} + +// ListSBMServers mocks base method. +func (m *MockHostsService) ListSBMServers() serverscom.Collection[serverscom.SBMServer] { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListSBMServers") + ret0, _ := ret[0].(serverscom.Collection[serverscom.SBMServer]) + return ret0 +} + +// ListSBMServers indicates an expected call of ListSBMServers. +func (mr *MockHostsServiceMockRecorder) ListSBMServers() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSBMServers", reflect.TypeOf((*MockHostsService)(nil).ListSBMServers)) +} + // PowerCycleDedicatedServer mocks base method. func (m *MockHostsService) PowerCycleDedicatedServer(ctx context.Context, id string) (*serverscom.DedicatedServer, error) { m.ctrl.T.Helper() diff --git a/internal/output/entities/hosts.go b/internal/output/entities/hosts.go index 21245eb..be3f903 100644 --- a/internal/output/entities/hosts.go +++ b/internal/output/entities/hosts.go @@ -8,17 +8,21 @@ import ( ) var ( - HostType = reflect.TypeOf(serverscom.Host{}) - DedicatedServerType = reflect.TypeOf(serverscom.DedicatedServer{}) - KubernetesBaremetalNodeType = reflect.TypeOf(serverscom.KubernetesBaremetalNode{}) - SBMServerType = reflect.TypeOf(serverscom.SBMServer{}) - HostConnectionType = reflect.TypeOf(serverscom.HostConnection{}) - HostPowerFeedType = reflect.TypeOf(serverscom.HostPowerFeed{}) - HostDriveSlotType = reflect.TypeOf(serverscom.HostDriveSlot{}) - HostPTRRecordType = reflect.TypeOf(serverscom.PTRRecord{}) - HostNetworkType = reflect.TypeOf(serverscom.Network{}) - HostListDefaultFields = []string{"ID", "Type", "Title", "Status"} - NetworkListDefaultFields = []string{"ID", "Title", "Status", "CIDR", "Family", "InterfaceType", "DistributionMethod", "Additional"} + HostType = reflect.TypeOf(serverscom.Host{}) + DedicatedServerType = reflect.TypeOf(serverscom.DedicatedServer{}) + KubernetesBaremetalNodeType = reflect.TypeOf(serverscom.KubernetesBaremetalNode{}) + SBMServerType = reflect.TypeOf(serverscom.SBMServer{}) + HostConnectionType = reflect.TypeOf(serverscom.HostConnection{}) + HostPowerFeedType = reflect.TypeOf(serverscom.HostPowerFeed{}) + HostDriveSlotType = reflect.TypeOf(serverscom.HostDriveSlot{}) + HostPTRRecordType = reflect.TypeOf(serverscom.PTRRecord{}) + HostNetworkType = reflect.TypeOf(serverscom.Network{}) + HostListDefaultFields = []string{"ID", "Type", "Title", "LocationCode", "Status", "PublicIPv4Address"} + DedicatedServerListDefaultFields = []string{"ID", "Title", "RackID", "LocationCode", "Status", "PublicIPv4Address"} + KubernetesBaremetalNodeListDefaultFields = []string{"ID", "KubernetesClusterNodeNumber", "Title", "LocationCode", "Status", "PublicIPv4Address"} + SBMServerListDefaultFields = []string{"ID", "Title", "RackID", "LocationCode", "Status", "PublicIPv4Address"} + + NetworkListDefaultFields = []string{"ID", "Title", "Status", "CIDR", "Family", "InterfaceType", "DistributionMethod", "Additional"} ) func getConfigurationDetailsField() Field { @@ -80,7 +84,7 @@ func RegisterHostDefinition() { {ID: "PowerStatus", Name: "PowerStatus", Path: "PowerStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {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: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, // {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}, @@ -105,13 +109,13 @@ func RegisterDedicatedServerDefinition() { {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}, - {ID: "LocationCode", Name: "LocationCode", Path: "LocationCode", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LocationCode", Name: "LocationCode", Path: "LocationCode", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Status", Name: "Status", Path: "Status", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "OperationalStatus", Name: "OperationalStatus", Path: "OperationalStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PowerStatus", Name: "PowerStatus", Path: "PowerStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {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: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {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}, @@ -120,6 +124,9 @@ func RegisterDedicatedServerDefinition() { {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, getConfigurationDetailsField(), }, + cmdDefaultFields: map[string][]string{ + "list": DedicatedServerListDefaultFields, + }, eType: DedicatedServerType, } if err := Registry.Register(serverEntity); err != nil { @@ -138,13 +145,13 @@ func RegisterKubernetesBaremetalNodeDefinition() { {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}, - {ID: "LocationCode", Name: "LocationCode", Path: "LocationCode", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LocationCode", Name: "LocationCode", Path: "LocationCode", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Status", Name: "Status", Path: "Status", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "OperationalStatus", Name: "OperationalStatus", Path: "OperationalStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PowerStatus", Name: "PowerStatus", Path: "PowerStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {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: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {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}, @@ -153,6 +160,9 @@ func RegisterKubernetesBaremetalNodeDefinition() { {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, getConfigurationDetailsField(), }, + cmdDefaultFields: map[string][]string{ + "list": KubernetesBaremetalNodeListDefaultFields, + }, eType: KubernetesBaremetalNodeType, } if err := Registry.Register(serverEntity); err != nil { @@ -168,13 +178,13 @@ func RegisterSBMServerDefinition() { {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}, - {ID: "LocationCode", Name: "LocationCode", Path: "LocationCode", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, + {ID: "LocationCode", Name: "LocationCode", Path: "LocationCode", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "Status", Name: "Status", Path: "Status", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {ID: "OperationalStatus", Name: "OperationalStatus", Path: "OperationalStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {ID: "PowerStatus", Name: "PowerStatus", Path: "PowerStatus", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler}, {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: "PublicIPv4Address", Name: "PublicIPv4Address", Path: "PublicIPv4Address", ListHandlerFunc: stringHandler, PageViewHandlerFunc: stringHandler, Default: true}, {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}, @@ -183,6 +193,9 @@ func RegisterSBMServerDefinition() { {ID: "Updated", Name: "Updated", Path: "Updated", ListHandlerFunc: timeHandler, PageViewHandlerFunc: timeHandler, Default: true}, getConfigurationDetailsField(), }, + cmdDefaultFields: map[string][]string{ + "list": SBMServerListDefaultFields, + }, eType: SBMServerType, } if err := Registry.Register(serverEntity); err != nil { diff --git a/testdata/entities/hosts/create_ds_resp.json b/testdata/entities/hosts/create_ds_resp.json index 11e39b6..b85dc42 100644 --- a/testdata/entities/hosts/create_ds_resp.json +++ b/testdata/entities/hosts/create_ds_resp.json @@ -5,28 +5,28 @@ "type": "dedicated_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": null, "created_at": "2025-01-01T12:00:00Z", diff --git a/testdata/entities/hosts/create_sbm_resp.json b/testdata/entities/hosts/create_sbm_resp.json index e6724f4..274bbf0 100644 --- a/testdata/entities/hosts/create_sbm_resp.json +++ b/testdata/entities/hosts/create_sbm_resp.json @@ -5,28 +5,28 @@ "type": "sbm_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": null, "created_at": "2025-01-01T12:00:00Z", diff --git a/testdata/entities/hosts/get_ds.json b/testdata/entities/hosts/get_ds.json index ed236e3..ab3d509 100644 --- a/testdata/entities/hosts/get_ds.json +++ b/testdata/entities/hosts/get_ds.json @@ -4,28 +4,28 @@ "type": "dedicated_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": null, "created_at": "2025-01-01T12:00:00Z", diff --git a/testdata/entities/hosts/get_ds.txt b/testdata/entities/hosts/get_ds.txt index ff67a25..7a89f73 100644 --- a/testdata/entities/hosts/get_ds.txt +++ b/testdata/entities/hosts/get_ds.txt @@ -1,2 +1,2 @@ -ID RackID Title Status Created Updated -testId testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z +ID RackID Title LocationCode Status PublicIPv4Address Created Updated +testId testId example.aa test active 1.2.3.4 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 013c84b..c0b84cd 100644 --- a/testdata/entities/hosts/get_ds.yaml +++ b/testdata/entities/hosts/get_ds.yaml @@ -3,28 +3,28 @@ rackid: testId type: dedicated_server title: example.aa locationid: 0 -locationcode: "" +locationcode: test status: active operationalstatus: "" powerstatus: "" configuration: "" privateipv4address: null -publicipv4address: null +publicipv4address: 1.2.3.4 leasestart: "" scheduledrelease: null oobipv4address: "" configurationdetails: - ramsize: 0 - servermodelid: null - servermodelname: null - publicuplinkid: null - publicuplinkname: null - privateuplinkid: null - privateuplinkname: null - bandwidthid: null - bandwidthname: null - operatingsystemid: null - operatingsystemfullname: null + ramsize: 2 + servermodelid: 1 + servermodelname: server-model-123 + publicuplinkid: 2 + publicuplinkname: Public 1 Gbps without redundancy + privateuplinkid: 3 + privateuplinkname: Private 1 Gbps without redundancy + bandwidthid: 4 + bandwidthname: 20000 GB + operatingsystemid: 5 + operatingsystemfullname: CentOS 7 x86_64 labels: {} created: 2025-01-01T12:00:00Z updated: 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/get_kbm.json b/testdata/entities/hosts/get_kbm.json index 9c836d8..f24d9c8 100644 --- a/testdata/entities/hosts/get_kbm.json +++ b/testdata/entities/hosts/get_kbm.json @@ -7,28 +7,28 @@ "type": "kubernetes_baremetal_node", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": null, "created_at": "2025-01-01T12:00:00Z", diff --git a/testdata/entities/hosts/get_kbm.txt b/testdata/entities/hosts/get_kbm.txt index ff67a25..7a89f73 100644 --- a/testdata/entities/hosts/get_kbm.txt +++ b/testdata/entities/hosts/get_kbm.txt @@ -1,2 +1,2 @@ -ID RackID Title Status Created Updated -testId testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z +ID RackID Title LocationCode Status PublicIPv4Address Created Updated +testId testId example.aa test active 1.2.3.4 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 8e49d21..d2fc0be 100644 --- a/testdata/entities/hosts/get_kbm.yaml +++ b/testdata/entities/hosts/get_kbm.yaml @@ -6,28 +6,28 @@ rackid: testId type: kubernetes_baremetal_node title: example.aa locationid: 0 -locationcode: "" +locationcode: test status: active operationalstatus: "" powerstatus: "" configuration: "" privateipv4address: null -publicipv4address: null +publicipv4address: 1.2.3.4 leasestart: "" scheduledrelease: null oobipv4address: "" configurationdetails: - ramsize: 0 - servermodelid: null - servermodelname: null - publicuplinkid: null - publicuplinkname: null - privateuplinkid: null - privateuplinkname: null - bandwidthid: null - bandwidthname: null - operatingsystemid: null - operatingsystemfullname: null + ramsize: 2 + servermodelid: 1 + servermodelname: server-model-123 + publicuplinkid: 2 + publicuplinkname: Public 1 Gbps without redundancy + privateuplinkid: 3 + privateuplinkname: Private 1 Gbps without redundancy + bandwidthid: 4 + bandwidthname: 20000 GB + operatingsystemid: 5 + operatingsystemfullname: CentOS 7 x86_64 labels: {} created: 2025-01-01T12:00:00Z updated: 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/get_sbm.json b/testdata/entities/hosts/get_sbm.json index fd10f4f..1acf992 100644 --- a/testdata/entities/hosts/get_sbm.json +++ b/testdata/entities/hosts/get_sbm.json @@ -4,28 +4,28 @@ "type": "sbm_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": null, "created_at": "2025-01-01T12:00:00Z", diff --git a/testdata/entities/hosts/get_sbm.txt b/testdata/entities/hosts/get_sbm.txt index ff67a25..7a89f73 100644 --- a/testdata/entities/hosts/get_sbm.txt +++ b/testdata/entities/hosts/get_sbm.txt @@ -1,2 +1,2 @@ -ID RackID Title Status Created Updated -testId testId example.aa active 2025-01-01T12:00:00Z 2025-01-01T12:00:00Z +ID RackID Title LocationCode Status PublicIPv4Address Created Updated +testId testId example.aa test active 1.2.3.4 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 10958d6..abad805 100644 --- a/testdata/entities/hosts/get_sbm.yaml +++ b/testdata/entities/hosts/get_sbm.yaml @@ -3,28 +3,28 @@ rackid: testId type: sbm_server title: example.aa locationid: 0 -locationcode: "" +locationcode: test status: active operationalstatus: "" powerstatus: "" configuration: "" privateipv4address: null -publicipv4address: null +publicipv4address: 1.2.3.4 leasestart: "" scheduledrelease: null oobipv4address: "" configurationdetails: - ramsize: 0 - servermodelid: null - servermodelname: null - publicuplinkid: null - publicuplinkname: null - privateuplinkid: null - privateuplinkname: null - bandwidthid: null - bandwidthname: null - operatingsystemid: null - operatingsystemfullname: null + ramsize: 2 + servermodelid: 1 + servermodelname: server-model-123 + publicuplinkid: 2 + publicuplinkname: Public 1 Gbps without redundancy + privateuplinkid: 3 + privateuplinkname: Private 1 Gbps without redundancy + bandwidthid: 4 + bandwidthname: 20000 GB + operatingsystemid: 5 + operatingsystemfullname: CentOS 7 x86_64 labels: {} created: 2025-01-01T12:00:00Z updated: 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/list_ds.json b/testdata/entities/hosts/list_ds.json index b317831..b85dc42 100644 --- a/testdata/entities/hosts/list_ds.json +++ b/testdata/entities/hosts/list_ds.json @@ -1,17 +1,34 @@ [ { "id": "testId", + "rack_id": "testId", "type": "dedicated_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" } diff --git a/testdata/entities/hosts/list_ds_all.json b/testdata/entities/hosts/list_ds_all.json index 0c35252..7e2d949 100644 --- a/testdata/entities/hosts/list_ds_all.json +++ b/testdata/entities/hosts/list_ds_all.json @@ -1,33 +1,67 @@ [ { "id": "testId", + "rack_id": "testId", "type": "dedicated_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" }, { "id": "testId2", + "rack_id": "testId", "type": "dedicated_server", "title": "example.bb", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" } diff --git a/testdata/entities/hosts/list_ds_pageview.txt b/testdata/entities/hosts/list_ds_pageview.txt index 47ef9c3..38d448e 100644 --- a/testdata/entities/hosts/list_ds_pageview.txt +++ b/testdata/entities/hosts/list_ds_pageview.txt @@ -1,29 +1,61 @@ ID: testId +RackID: testId Type: dedicated_server Title: example.aa LocationID: 0 -LocationCode: +LocationCode: test Status: active OperationalStatus: PowerStatus: Configuration: PrivateIPv4Address: -PublicIPv4Address: +PublicIPv4Address: 1.2.3.4 +LeaseStart: ScheduledRelease: +OobIPv4Address: +Labels: Created: 2025-01-01T12:00:00Z Updated: 2025-01-01T12:00:00Z +ConfigurationDetails: + RAMSize: 2 + ServerModelID: 1 + ServerModelName: server-model-123 + PublicUplinkID: 2 + PublicUplinkName: Public 1 Gbps without redundancy + PrivateUplinkID: 3 + PrivateUplinkName: Private 1 Gbps without redundancy + BandwidthID: 4 + BandwidthName: 20000 GB + OperatingSystemID: 5 + OperatingSystemFullName: CentOS 7 x86_64 --- ID: testId2 +RackID: testId Type: dedicated_server Title: example.bb LocationID: 0 -LocationCode: +LocationCode: test Status: active OperationalStatus: PowerStatus: Configuration: PrivateIPv4Address: -PublicIPv4Address: +PublicIPv4Address: 1.2.3.4 +LeaseStart: ScheduledRelease: +OobIPv4Address: +Labels: Created: 2025-01-01T12:00:00Z Updated: 2025-01-01T12:00:00Z +ConfigurationDetails: + RAMSize: 2 + ServerModelID: 1 + ServerModelName: server-model-123 + PublicUplinkID: 2 + PublicUplinkName: Public 1 Gbps without redundancy + PrivateUplinkID: 3 + PrivateUplinkName: Private 1 Gbps without redundancy + BandwidthID: 4 + BandwidthName: 20000 GB + OperatingSystemID: 5 + OperatingSystemFullName: CentOS 7 x86_64 diff --git a/testdata/entities/hosts/list_hosts.json b/testdata/entities/hosts/list_hosts.json new file mode 100644 index 0000000..4f08206 --- /dev/null +++ b/testdata/entities/hosts/list_hosts.json @@ -0,0 +1,34 @@ +[ + { + "id": "testId", + "type": "dedicated_server", + "title": "example.aa", + "location_id": 0, + "location_code": "test", + "status": "active", + "operational_status": "", + "power_status": "", + "configuration": "", + "private_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "scheduled_release_at": null, + "created_at": "2025-01-01T12:00:00Z", + "updated_at": "2025-01-01T12:00:00Z" + }, + { + "id": "testId2", + "type": "sbm_server", + "title": "example.bb", + "location_id": 0, + "location_code": "test", + "status": "active", + "operational_status": "", + "power_status": "", + "configuration": "", + "private_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "scheduled_release_at": null, + "created_at": "2025-01-01T12:00:00Z", + "updated_at": "2025-01-01T12:00:00Z" + } +] \ No newline at end of file diff --git a/testdata/entities/hosts/list_hosts_pageview.txt b/testdata/entities/hosts/list_hosts_pageview.txt new file mode 100644 index 0000000..a70e9ae --- /dev/null +++ b/testdata/entities/hosts/list_hosts_pageview.txt @@ -0,0 +1,29 @@ +ID: testId +Type: dedicated_server +Title: example.aa +LocationID: 0 +LocationCode: test +Status: active +OperationalStatus: +PowerStatus: +Configuration: +PrivateIPv4Address: +PublicIPv4Address: 1.2.3.4 +ScheduledRelease: +Created: 2025-01-01T12:00:00Z +Updated: 2025-01-01T12:00:00Z +--- +ID: testId2 +Type: sbm_server +Title: example.bb +LocationID: 0 +LocationCode: test +Status: active +OperationalStatus: +PowerStatus: +Configuration: +PrivateIPv4Address: +PublicIPv4Address: 1.2.3.4 +ScheduledRelease: +Created: 2025-01-01T12:00:00Z +Updated: 2025-01-01T12:00:00Z diff --git a/testdata/entities/hosts/list_hosts_template.txt b/testdata/entities/hosts/list_hosts_template.txt new file mode 100644 index 0000000..7da8272 --- /dev/null +++ b/testdata/entities/hosts/list_hosts_template.txt @@ -0,0 +1,2 @@ +Title: example.aa Type: dedicated_server +Title: example.bb Type: sbm_server diff --git a/testdata/entities/hosts/list_kbm.json b/testdata/entities/hosts/list_kbm.json index a6acb40..22dee12 100644 --- a/testdata/entities/hosts/list_kbm.json +++ b/testdata/entities/hosts/list_kbm.json @@ -1,17 +1,37 @@ [ { "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, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" } diff --git a/testdata/entities/hosts/list_kbm_all.json b/testdata/entities/hosts/list_kbm_all.json index 9f6412c..381f282 100644 --- a/testdata/entities/hosts/list_kbm_all.json +++ b/testdata/entities/hosts/list_kbm_all.json @@ -1,33 +1,73 @@ [ { "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, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" }, { "id": "testId2", + "kubernetes_cluster_id": "testId", + "kubernetes_cluster_node_id": "testId", + "kubernetes_cluster_node_number": 1, + "rack_id": "testId", "type": "kubernetes_baremetal_node", "title": "example.bb", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" } diff --git a/testdata/entities/hosts/list_kbm_pageview.txt b/testdata/entities/hosts/list_kbm_pageview.txt index c3f45dd..ecb35a2 100644 --- a/testdata/entities/hosts/list_kbm_pageview.txt +++ b/testdata/entities/hosts/list_kbm_pageview.txt @@ -1,29 +1,67 @@ -ID: testId -Type: kubernetes_baremetal_node -Title: example.aa -LocationID: 0 -LocationCode: -Status: active -OperationalStatus: -PowerStatus: -Configuration: -PrivateIPv4Address: -PublicIPv4Address: -ScheduledRelease: -Created: 2025-01-01T12:00:00Z -Updated: 2025-01-01T12:00:00Z +ID: testId +KubernetesClusterId: +KubernetesClusterNodeId: +KubernetesClusterNodeNumber: 1 +RackID: testId +Type: kubernetes_baremetal_node +Title: example.aa +LocationID: 0 +LocationCode: test +Status: active +OperationalStatus: +PowerStatus: +Configuration: +PrivateIPv4Address: +PublicIPv4Address: 1.2.3.4 +LeaseStart: +ScheduledRelease: +OobIPv4Address: +Labels: +Created: 2025-01-01T12:00:00Z +Updated: 2025-01-01T12:00:00Z +ConfigurationDetails: + RAMSize: 2 + ServerModelID: 1 + ServerModelName: server-model-123 + PublicUplinkID: 2 + PublicUplinkName: Public 1 Gbps without redundancy + PrivateUplinkID: 3 + PrivateUplinkName: Private 1 Gbps without redundancy + BandwidthID: 4 + BandwidthName: 20000 GB + OperatingSystemID: 5 + OperatingSystemFullName: CentOS 7 x86_64 --- -ID: testId2 -Type: kubernetes_baremetal_node -Title: example.bb -LocationID: 0 -LocationCode: -Status: active -OperationalStatus: -PowerStatus: -Configuration: -PrivateIPv4Address: -PublicIPv4Address: -ScheduledRelease: -Created: 2025-01-01T12:00:00Z -Updated: 2025-01-01T12:00:00Z +ID: testId2 +KubernetesClusterId: +KubernetesClusterNodeId: +KubernetesClusterNodeNumber: 1 +RackID: testId +Type: kubernetes_baremetal_node +Title: example.bb +LocationID: 0 +LocationCode: test +Status: active +OperationalStatus: +PowerStatus: +Configuration: +PrivateIPv4Address: +PublicIPv4Address: 1.2.3.4 +LeaseStart: +ScheduledRelease: +OobIPv4Address: +Labels: +Created: 2025-01-01T12:00:00Z +Updated: 2025-01-01T12:00:00Z +ConfigurationDetails: + RAMSize: 2 + ServerModelID: 1 + ServerModelName: server-model-123 + PublicUplinkID: 2 + PublicUplinkName: Public 1 Gbps without redundancy + PrivateUplinkID: 3 + PrivateUplinkName: Private 1 Gbps without redundancy + BandwidthID: 4 + BandwidthName: 20000 GB + OperatingSystemID: 5 + OperatingSystemFullName: CentOS 7 x86_64 diff --git a/testdata/entities/hosts/list_sbm.json b/testdata/entities/hosts/list_sbm.json index 2c00520..274bbf0 100644 --- a/testdata/entities/hosts/list_sbm.json +++ b/testdata/entities/hosts/list_sbm.json @@ -1,17 +1,34 @@ [ { "id": "testId", + "rack_id": "testId", "type": "sbm_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" } diff --git a/testdata/entities/hosts/list_sbm_all.json b/testdata/entities/hosts/list_sbm_all.json index c9de834..8abd21c 100644 --- a/testdata/entities/hosts/list_sbm_all.json +++ b/testdata/entities/hosts/list_sbm_all.json @@ -1,33 +1,67 @@ [ { "id": "testId", + "rack_id": "testId", "type": "sbm_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" }, { "id": "testId2", + "rack_id": "testId", "type": "sbm_server", "title": "example.bb", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", + "lease_start_at": "", "scheduled_release_at": null, + "oob_ipv4_address": "", + "configuration_details": { + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" + }, + "labels": null, "created_at": "2025-01-01T12:00:00Z", "updated_at": "2025-01-01T12:00:00Z" } diff --git a/testdata/entities/hosts/list_sbm_pageview.txt b/testdata/entities/hosts/list_sbm_pageview.txt index 4fd0050..106761f 100644 --- a/testdata/entities/hosts/list_sbm_pageview.txt +++ b/testdata/entities/hosts/list_sbm_pageview.txt @@ -1,29 +1,61 @@ ID: testId +RackID: testId Type: sbm_server Title: example.aa LocationID: 0 -LocationCode: +LocationCode: test Status: active OperationalStatus: PowerStatus: Configuration: PrivateIPv4Address: -PublicIPv4Address: +PublicIPv4Address: 1.2.3.4 +LeaseStart: ScheduledRelease: +OobIPv4Address: +Labels: Created: 2025-01-01T12:00:00Z Updated: 2025-01-01T12:00:00Z +ConfigurationDetails: + RAMSize: 2 + ServerModelID: 1 + ServerModelName: server-model-123 + PublicUplinkID: 2 + PublicUplinkName: Public 1 Gbps without redundancy + PrivateUplinkID: 3 + PrivateUplinkName: Private 1 Gbps without redundancy + BandwidthID: 4 + BandwidthName: 20000 GB + OperatingSystemID: 5 + OperatingSystemFullName: CentOS 7 x86_64 --- ID: testId2 +RackID: testId Type: sbm_server Title: example.bb LocationID: 0 -LocationCode: +LocationCode: test Status: active OperationalStatus: PowerStatus: Configuration: PrivateIPv4Address: -PublicIPv4Address: +PublicIPv4Address: 1.2.3.4 +LeaseStart: ScheduledRelease: +OobIPv4Address: +Labels: Created: 2025-01-01T12:00:00Z Updated: 2025-01-01T12:00:00Z +ConfigurationDetails: + RAMSize: 2 + ServerModelID: 1 + ServerModelName: server-model-123 + PublicUplinkID: 2 + PublicUplinkName: Public 1 Gbps without redundancy + PrivateUplinkID: 3 + PrivateUplinkName: Private 1 Gbps without redundancy + BandwidthID: 4 + BandwidthName: 20000 GB + OperatingSystemID: 5 + OperatingSystemFullName: CentOS 7 x86_64 diff --git a/testdata/entities/hosts/release_ds_resp.json b/testdata/entities/hosts/release_ds_resp.json index 531ade2..c10f62b 100644 --- a/testdata/entities/hosts/release_ds_resp.json +++ b/testdata/entities/hosts/release_ds_resp.json @@ -4,28 +4,28 @@ "type": "dedicated_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": "2025-01-01T12:00:00Z", "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": null, "created_at": "2025-01-01T12:00:00Z", diff --git a/testdata/entities/hosts/update_ds_resp.json b/testdata/entities/hosts/update_ds_resp.json index c76aced..baa0191 100644 --- a/testdata/entities/hosts/update_ds_resp.json +++ b/testdata/entities/hosts/update_ds_resp.json @@ -4,28 +4,28 @@ "type": "dedicated_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": { "new": "label" diff --git a/testdata/entities/hosts/update_kbm_resp.json b/testdata/entities/hosts/update_kbm_resp.json index 153bc4e..5010e3d 100644 --- a/testdata/entities/hosts/update_kbm_resp.json +++ b/testdata/entities/hosts/update_kbm_resp.json @@ -7,28 +7,28 @@ "type": "kubernetes_baremetal_node", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": { "new": "label" diff --git a/testdata/entities/hosts/update_sbm_resp.json b/testdata/entities/hosts/update_sbm_resp.json index 7edd9d1..e63b086 100644 --- a/testdata/entities/hosts/update_sbm_resp.json +++ b/testdata/entities/hosts/update_sbm_resp.json @@ -4,28 +4,28 @@ "type": "sbm_server", "title": "example.aa", "location_id": 0, - "location_code": "", + "location_code": "test", "status": "active", "operational_status": "", "power_status": "", "configuration": "", "private_ipv4_address": null, - "public_ipv4_address": null, + "public_ipv4_address": "1.2.3.4", "lease_start_at": "", "scheduled_release_at": null, "oob_ipv4_address": "", "configuration_details": { - "ram_size": 0, - "server_model_id": null, - "server_model_name": null, - "public_uplink_id": null, - "public_uplink_name": null, - "private_uplink_id": null, - "private_uplink_name": null, - "bandwidth_id": null, - "bandwidth_name": null, - "operating_system_id": null, - "operating_system_full_name": null + "ram_size": 2, + "server_model_id": 1, + "server_model_name": "server-model-123", + "public_uplink_id": 2, + "public_uplink_name": "Public 1 Gbps without redundancy", + "private_uplink_id": 3, + "private_uplink_name": "Private 1 Gbps without redundancy", + "bandwidth_id": 4, + "bandwidth_name": "20000 GB", + "operating_system_id": 5, + "operating_system_full_name": "CentOS 7 x86_64" }, "labels": { "new": "label"