Skip to content

Commit

Permalink
Added support to add secondary device to existing primary device
Browse files Browse the repository at this point in the history
  • Loading branch information
kpdhulipala committed Mar 11, 2024
1 parent 8d7cd37 commit e421f9b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ type Device struct {
ProjectID *string
DiverseFromDeviceUUID *string
DiverseFromDeviceName *string
PrimaryDeviceUUID *string
}

// DeviceInterface describes Network Edge device interface
Expand Down
2 changes: 2 additions & 0 deletions internal/api/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Device struct {
ProjectID *string `json:"projectId,omitempty"`
DiverseFromDeviceUUID *string `json:"diverseFromDeviceUuid,omitempty"`
DiverseFromDeviceName *string `json:"diverseFromDeviceName,omitempty"`
PrimaryDeviceUUID *string `json:"primaryDeviceUuid,omitempty"`
}

// DeviceRequest describes network edge device creation request
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"`
PrimaryDeviceUUID *string `json:"primaryDeviceUuid,omitempty"`
}

// SecondaryDeviceRequest describes secondary device part of device creation request
Expand Down
2 changes: 2 additions & 0 deletions rest_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ func mapDeviceAPIToDomain(apiDevice api.Device) *Device {
device.ClusterDetails = mapDeviceClusterDetailsAPIToDomain(apiDevice.ClusterDetails)
device.DiverseFromDeviceUUID = apiDevice.DiverseFromDeviceUUID
device.DiverseFromDeviceName = apiDevice.DiverseFromDeviceName
device.PrimaryDeviceUUID = apiDevice.PrimaryDeviceUUID
return &device
}

Expand Down Expand Up @@ -408,6 +409,7 @@ func createDeviceRequest(device Device) api.DeviceRequest {
req.UserPublicKey = mapDeviceUserPublicKeyDomainToAPI(device.UserPublicKey)
req.ClusterDetails = mapDeviceClusterDetailsDomainToAPI(device.ClusterDetails)
req.DiverseFromDeviceUUID = device.DiverseFromDeviceUUID
req.PrimaryDeviceUUID = device.PrimaryDeviceUUID
return req
}

Expand Down
2 changes: 2 additions & 0 deletions rest_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var testDevice = Device{
TermLength: Int(24),
ProjectID: String("68ccfd49-39b1-478e-957a-67c72f719d7a"),
DiverseFromDeviceUUID: String("ed7891bd-15b4-4f72-ac56-d96cfdacddcc"),
PrimaryDeviceUUID: String("8b028560-4a91-4b52-87ba-9fae0fcb538c"),
Throughput: Int(1),
ThroughputUnit: String("Gbps"),
Name: String("PaloAltoSRmy"),
Expand Down Expand Up @@ -505,6 +506,7 @@ func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest) {
assert.Equal(t, &termLengthStr, req.TermLength, "TermLength matches")
assert.Equal(t, device.ProjectID, req.ProjectID, "Project Id matches")
assert.Equal(t, device.DiverseFromDeviceUUID, req.DiverseFromDeviceUUID, "Diverse from Device UUID matches")
assert.Equal(t, device.PrimaryDeviceUUID, req.PrimaryDeviceUUID, "Primary Device UUID matches")
if *device.IsBYOL {
assert.Equal(t, DeviceLicenseModeBYOL, StringValue(req.LicenseMode), "LicenseMode matches")
} else {
Expand Down

0 comments on commit e421f9b

Please sign in to comment.