Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support to add secondary device to existing primary device #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading