Skip to content

Commit

Permalink
Added support to pass bandwidth tier for license for C8000V autonomou…
Browse files Browse the repository at this point in the history
…s and C8000V-SDWAN(controller mode) device types (#35)
  • Loading branch information
kpdhulipala authored Sep 11, 2024
1 parent 324c2b3 commit 8149bdf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ type Device struct {
ProjectID *string
DiverseFromDeviceUUID *string
DiverseFromDeviceName *string
Tier *int
}

// DeviceInterface describes Network Edge device interface
Expand Down
3 changes: 3 additions & 0 deletions internal/api/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Device struct {
OrderReference *string `json:"orderReference,omitempty"`
InterfaceCount *int `json:"interfaceCount,omitempty"`
Core *DeviceCoreInformation `json:"core,omitempty"`
Tier *DeviceCoreInformation `json:"tier,omitempty"`
DeviceManagementType *string `json:"deviceManagementType,omitempty"`
SshInterfaceID *string `json:"sshInterfaceId,omitempty"`
Interfaces []DeviceInterface `json:"interfaces,omitempty"`
Expand Down Expand Up @@ -80,6 +81,7 @@ type DeviceRequest struct {
Connectivity *string `json:"connectivity,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
DiverseFromDeviceUUID *string `json:"diverseFromDeviceUuid,omitempty"`
Tier *int `json:"tier,omitempty"`
}

// SecondaryDeviceRequest describes secondary device part of device creation request
Expand Down Expand Up @@ -133,6 +135,7 @@ type DeviceCoreInformation struct {
Core *int `json:"core,omitempty"`
Memory *int `json:"memory,omitempty"`
Unit *string `json:"unit,omitempty"`
Tier *int `json:"tier,omitempty"`
}

// DeviceRequestResponse describes response for device creation request
Expand Down
4 changes: 4 additions & 0 deletions rest_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ func mapDeviceAPIToDomain(apiDevice api.Device) *Device {
if apiDevice.Core != nil {
device.CoreCount = apiDevice.Core.Core
}
if apiDevice.Core != nil {
device.Tier = apiDevice.Core.Tier
}
if apiDevice.DeviceManagementType != nil {
if *apiDevice.DeviceManagementType == DeviceManagementTypeSelf {
device.IsSelfManaged = Bool(true)
Expand Down Expand Up @@ -364,6 +367,7 @@ func mapDeviceClusterNodeDetailDomainToAPI(clusterNodeDetail *ClusterNodeDetail)
func createDeviceRequest(device Device) api.DeviceRequest {
req := api.DeviceRequest{}
req.Throughput = device.Throughput
req.Tier = device.Tier
req.ThroughputUnit = device.ThroughputUnit
req.MetroCode = device.MetroCode
req.DeviceTypeCode = device.TypeCode
Expand Down
4 changes: 4 additions & 0 deletions rest_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var testDevice = Device{
PackageCode: String("VM100"),
TermLength: Int(24),
ProjectID: String("68ccfd49-39b1-478e-957a-67c72f719d7a"),
Tier: Int(1),
DiverseFromDeviceUUID: String("ed7891bd-15b4-4f72-ac56-d96cfdacddcc"),
Throughput: Int(1),
ThroughputUnit: String("Gbps"),
Expand Down Expand Up @@ -469,6 +470,8 @@ func verifyDevice(t *testing.T, device Device, resp api.Device) {
assert.Equal(t, resp.OrderReference, device.OrderReference, "OrderReference matches")
assert.Equal(t, resp.InterfaceCount, device.InterfaceCount, "InterfaceCount matches")
assert.Equal(t, resp.Core.Core, device.CoreCount, "Core.Core matches")
assert.Equal(t, resp.Core.Tier, device.Tier, "Core.Tier matches")

if *resp.DeviceManagementType == DeviceManagementTypeEquinix {
assert.False(t, *device.IsSelfManaged, "DeviceManagementType matches")
} else {
Expand Down Expand Up @@ -498,6 +501,7 @@ func verifyDeviceInterface(t *testing.T, inf DeviceInterface, apiInf api.DeviceI

func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest) {
assert.Equal(t, device.Throughput, req.Throughput, "Throughput matches")
assert.Equal(t, device.Tier, req.Tier, "Tier matches")
assert.Equal(t, device.ThroughputUnit, req.ThroughputUnit, "ThroughputUnit matches")
assert.Equal(t, device.MetroCode, req.MetroCode, "MetroCode matches")
assert.Equal(t, device.TypeCode, req.DeviceTypeCode, "TypeCode matches")
Expand Down

0 comments on commit 8149bdf

Please sign in to comment.