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

Added support to send optional diverse device uuid in Create Single device #31

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
88 changes: 45 additions & 43 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,49 +239,51 @@ type Account struct {

// Device describes Network Edge device
type Device struct {
UUID *string
Name *string
TypeCode *string
Status *string
LicenseStatus *string
MetroCode *string
IBX *string
Region *string
Throughput *int
ThroughputUnit *string
HostName *string
PackageCode *string
Version *string
IsBYOL *bool
LicenseToken *string
LicenseFile *string
CloudInitFile *string
LicenseFileID *string
CloudInitFileID *string
ACLTemplateUUID *string
MgmtAclTemplateUuid *string
SSHIPAddress *string
SSHIPFqdn *string
AccountNumber *string
Notifications []string
PurchaseOrderNumber *string
RedundancyType *string
RedundantUUID *string
TermLength *int
AdditionalBandwidth *int
OrderReference *string
InterfaceCount *int
CoreCount *int
IsSelfManaged *bool
Connectivity *string
WanInterfaceId *string
Interfaces []DeviceInterface
VendorConfiguration map[string]string
UserPublicKey *DeviceUserPublicKey
ASN *int
ZoneCode *string
ClusterDetails *ClusterDetails
ProjectID *string
UUID *string
Name *string
TypeCode *string
Status *string
LicenseStatus *string
MetroCode *string
IBX *string
Region *string
Throughput *int
ThroughputUnit *string
HostName *string
PackageCode *string
Version *string
IsBYOL *bool
LicenseToken *string
LicenseFile *string
CloudInitFile *string
LicenseFileID *string
CloudInitFileID *string
ACLTemplateUUID *string
MgmtAclTemplateUuid *string
SSHIPAddress *string
SSHIPFqdn *string
AccountNumber *string
Notifications []string
PurchaseOrderNumber *string
RedundancyType *string
RedundantUUID *string
TermLength *int
AdditionalBandwidth *int
OrderReference *string
InterfaceCount *int
CoreCount *int
IsSelfManaged *bool
Connectivity *string
WanInterfaceId *string
Interfaces []DeviceInterface
VendorConfiguration map[string]string
UserPublicKey *DeviceUserPublicKey
ASN *int
ZoneCode *string
ClusterDetails *ClusterDetails
ProjectID *string
DiverseFromDeviceUUID *string
DiverseFromDeviceName *string
}

// DeviceInterface describes Network Edge device interface
Expand Down
145 changes: 74 additions & 71 deletions internal/api/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,84 @@ package api

// Device describes network edge device
type Device struct {
UUID *string `json:"uuid,omitempty"`
Name *string `json:"name,omitempty"`
DeviceTypeCode *string `json:"deviceTypeCode,omitempty"`
Status *string `json:"status,omitempty"`
LicenseStatus *string `json:"licenseStatus,omitempty"`
MetroCode *string `json:"metroCode,omitempty"`
IBX *string `json:"ibx,omitempty"`
Region *string `json:"region,omitempty"`
Throughput *int `json:"throughput,omitempty,string"`
ThroughputUnit *string `json:"throughputUnit,omitempty"`
HostName *string `json:"hostName,omitempty"`
PackageCode *string `json:"packageCode,omitempty"`
Version *string `json:"version,omitempty"`
LicenseToken *string `json:"licenseToken,omitempty"`
LicenseType *string `json:"licenseType,omitempty"`
LicenseFileID *string `json:"licenseFileId,omitempty"`
CloudInitFileID *string `json:"CloudInitFileId,omitempty"`
ACLTemplateUUID *string `json:"aclTemplateUuid,omitempty"`
MgmtAclTemplateUUID *string `json:"mgmtAclTemplateUuid,omitempty"`
SSHIPAddress *string `json:"sshIpAddress,omitempty"`
SSHIPFqdn *string `json:"sshIpFqdn,omitempty"`
AccountNumber *string `json:"accountNumber,omitempty"`
Notifications []string `json:"notifications,omitempty"`
PurchaseOrderNumber *string `json:"purchaseOrderNumber,omitempty"`
RedundancyType *string `json:"redundancyType,omitempty"`
RedundantUUID *string `json:"redundantUuid,omitempty"`
TermLength *int `json:"termLength,omitempty"`
AdditionalBandwidth *int `json:"additionalBandwidth,omitempty"`
OrderReference *string `json:"orderReference,omitempty"`
InterfaceCount *int `json:"interfaceCount,omitempty"`
Core *DeviceCoreInformation `json:"core,omitempty"`
DeviceManagementType *string `json:"deviceManagementType,omitempty"`
SshInterfaceID *string `json:"sshInterfaceId,omitempty"`
Interfaces []DeviceInterface `json:"interfaces,omitempty"`
VendorConfig map[string]string `json:"vendorConfig,omitempty"`
UserPublicKey *DeviceUserPublicKey `json:"userPublicKey,omitempty"`
ASN *int `json:"asn,omitempty"`
ZoneCode *string `json:"zoneCode,omitempty"`
ClusterDetails *ClusterDetails `json:"clusterDetails,omitempty"`
Connectivity *string `json:"connectivity,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
UUID *string `json:"uuid,omitempty"`
Name *string `json:"name,omitempty"`
DeviceTypeCode *string `json:"deviceTypeCode,omitempty"`
Status *string `json:"status,omitempty"`
LicenseStatus *string `json:"licenseStatus,omitempty"`
MetroCode *string `json:"metroCode,omitempty"`
IBX *string `json:"ibx,omitempty"`
Region *string `json:"region,omitempty"`
Throughput *int `json:"throughput,omitempty,string"`
ThroughputUnit *string `json:"throughputUnit,omitempty"`
HostName *string `json:"hostName,omitempty"`
PackageCode *string `json:"packageCode,omitempty"`
Version *string `json:"version,omitempty"`
LicenseToken *string `json:"licenseToken,omitempty"`
LicenseType *string `json:"licenseType,omitempty"`
LicenseFileID *string `json:"licenseFileId,omitempty"`
CloudInitFileID *string `json:"CloudInitFileId,omitempty"`
ACLTemplateUUID *string `json:"aclTemplateUuid,omitempty"`
MgmtAclTemplateUUID *string `json:"mgmtAclTemplateUuid,omitempty"`
SSHIPAddress *string `json:"sshIpAddress,omitempty"`
SSHIPFqdn *string `json:"sshIpFqdn,omitempty"`
AccountNumber *string `json:"accountNumber,omitempty"`
Notifications []string `json:"notifications,omitempty"`
PurchaseOrderNumber *string `json:"purchaseOrderNumber,omitempty"`
RedundancyType *string `json:"redundancyType,omitempty"`
RedundantUUID *string `json:"redundantUuid,omitempty"`
TermLength *int `json:"termLength,omitempty"`
AdditionalBandwidth *int `json:"additionalBandwidth,omitempty"`
OrderReference *string `json:"orderReference,omitempty"`
InterfaceCount *int `json:"interfaceCount,omitempty"`
Core *DeviceCoreInformation `json:"core,omitempty"`
DeviceManagementType *string `json:"deviceManagementType,omitempty"`
SshInterfaceID *string `json:"sshInterfaceId,omitempty"`
Interfaces []DeviceInterface `json:"interfaces,omitempty"`
VendorConfig map[string]string `json:"vendorConfig,omitempty"`
UserPublicKey *DeviceUserPublicKey `json:"userPublicKey,omitempty"`
ASN *int `json:"asn,omitempty"`
ZoneCode *string `json:"zoneCode,omitempty"`
ClusterDetails *ClusterDetails `json:"clusterDetails,omitempty"`
Connectivity *string `json:"connectivity,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
DiverseFromDeviceUUID *string `json:"diverseFromDeviceUuid,omitempty"`
DiverseFromDeviceName *string `json:"diverseFromDeviceName,omitempty"`
}

// DeviceRequest describes network edge device creation request
type DeviceRequest struct {
Throughput *int `json:"throughput,omitempty,string"`
ThroughputUnit *string `json:"throughputUnit,omitempty"`
MetroCode *string `json:"metroCode,omitempty"`
DeviceTypeCode *string `json:"deviceTypeCode,omitempty"`
TermLength *string `json:"termLength,omitempty"`
LicenseMode *string `json:"licenseMode,omitempty"`
LicenseToken *string `json:"licenseToken,omitempty"`
LicenseFileID *string `json:"licenseFileId,omitempty"`
CloudInitFileID *string `json:"cloudInitFileId,omitempty"`
PackageCode *string `json:"packageCode,omitempty"`
VirtualDeviceName *string `json:"virtualDeviceName,omitempty"`
Notifications []string `json:"notifications,omitempty"`
HostNamePrefix *string `json:"hostNamePrefix,omitempty"`
OrderReference *string `json:"orderReference,omitempty"`
PurchaseOrderNumber *string `json:"purchaseOrderNumber,omitempty"`
AccountNumber *string `json:"accountNumber,omitempty"`
Version *string `json:"version,omitempty"`
InterfaceCount *int `json:"interfaceCount,omitempty"`
DeviceManagementType *string `json:"deviceManagementType,omitempty"`
SshInterfaceId *string `json:"sshInterfaceId,omitempty"`
Core *int `json:"core,omitempty"`
AdditionalBandwidth *int `json:"additionalBandwidth,omitempty,string"`
ACLTemplateUUID *string `json:"aclTemplateUuid,omitempty"`
MgmtAclTemplateUUID *string `json:"mgmtAclTemplateUuid,omitempty"`
VendorConfig map[string]string `json:"vendorConfig,omitempty"`
UserPublicKey *DeviceUserPublicKeyRequest `json:"userPublicKey,omitempty"`
Secondary *SecondaryDeviceRequest `json:"secondary,omitempty"`
ClusterDetails *ClusterDetailsRequest `json:"clusterDetails,omitempty"`
Connectivity *string `json:"connectivity,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
Throughput *int `json:"throughput,omitempty,string"`
ThroughputUnit *string `json:"throughputUnit,omitempty"`
MetroCode *string `json:"metroCode,omitempty"`
DeviceTypeCode *string `json:"deviceTypeCode,omitempty"`
TermLength *string `json:"termLength,omitempty"`
LicenseMode *string `json:"licenseMode,omitempty"`
LicenseToken *string `json:"licenseToken,omitempty"`
LicenseFileID *string `json:"licenseFileId,omitempty"`
CloudInitFileID *string `json:"cloudInitFileId,omitempty"`
PackageCode *string `json:"packageCode,omitempty"`
VirtualDeviceName *string `json:"virtualDeviceName,omitempty"`
Notifications []string `json:"notifications,omitempty"`
HostNamePrefix *string `json:"hostNamePrefix,omitempty"`
OrderReference *string `json:"orderReference,omitempty"`
PurchaseOrderNumber *string `json:"purchaseOrderNumber,omitempty"`
AccountNumber *string `json:"accountNumber,omitempty"`
Version *string `json:"version,omitempty"`
InterfaceCount *int `json:"interfaceCount,omitempty"`
DeviceManagementType *string `json:"deviceManagementType,omitempty"`
SshInterfaceId *string `json:"sshInterfaceId,omitempty"`
Core *int `json:"core,omitempty"`
AdditionalBandwidth *int `json:"additionalBandwidth,omitempty,string"`
ACLTemplateUUID *string `json:"aclTemplateUuid,omitempty"`
MgmtAclTemplateUUID *string `json:"mgmtAclTemplateUuid,omitempty"`
VendorConfig map[string]string `json:"vendorConfig,omitempty"`
UserPublicKey *DeviceUserPublicKeyRequest `json:"userPublicKey,omitempty"`
Secondary *SecondaryDeviceRequest `json:"secondary,omitempty"`
ClusterDetails *ClusterDetailsRequest `json:"clusterDetails,omitempty"`
Connectivity *string `json:"connectivity,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
DiverseFromDeviceUUID *string `json:"diverseFromDeviceUuid,omitempty"`
}

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

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

Expand Down
48 changes: 25 additions & 23 deletions rest_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,30 @@ import (
)

var testDevice = Device{
AdditionalBandwidth: Int(100),
TypeCode: String("PA-VM"),
HostName: String("myhostSRmy"),
IsBYOL: Bool(true),
LicenseToken: String("somelicensetokenaaaaazzzzz"),
LicenseFileID: String("8d180057-8309-4c59-b645-f630f010ad43"),
CloudInitFileID: String("9318885d-4b8c-48a5-9aa4-24387834ebae"),
MetroCode: String("SV"),
Notifications: []string{"test1@example.com", "test2@example.com"},
PackageCode: String("VM100"),
TermLength: Int(24),
ProjectID: String("68ccfd49-39b1-478e-957a-67c72f719d7a"),
Throughput: Int(1),
ThroughputUnit: String("Gbps"),
Name: String("PaloAltoSRmy"),
ACLTemplateUUID: String("4792d9ab-b8aa-49cc-8fe2-b56ced6c9c2f"),
AccountNumber: String("1777643"),
OrderReference: String("orderRef"),
PurchaseOrderNumber: String("PO123456789"),
InterfaceCount: Int(10),
CoreCount: Int(2),
Version: String("10.09.05"),
IsSelfManaged: Bool(true),
AdditionalBandwidth: Int(100),
TypeCode: String("PA-VM"),
HostName: String("myhostSRmy"),
IsBYOL: Bool(true),
LicenseToken: String("somelicensetokenaaaaazzzzz"),
LicenseFileID: String("8d180057-8309-4c59-b645-f630f010ad43"),
CloudInitFileID: String("9318885d-4b8c-48a5-9aa4-24387834ebae"),
MetroCode: String("SV"),
Notifications: []string{"test1@example.com", "test2@example.com"},
PackageCode: String("VM100"),
TermLength: Int(24),
ProjectID: String("68ccfd49-39b1-478e-957a-67c72f719d7a"),
DiverseFromDeviceUUID: String("ed7891bd-15b4-4f72-ac56-d96cfdacddcc"),
Throughput: Int(1),
ThroughputUnit: String("Gbps"),
Name: String("PaloAltoSRmy"),
ACLTemplateUUID: String("4792d9ab-b8aa-49cc-8fe2-b56ced6c9c2f"),
AccountNumber: String("1777643"),
OrderReference: String("orderRef"),
PurchaseOrderNumber: String("PO123456789"),
InterfaceCount: Int(10),
CoreCount: Int(2),
Version: String("10.09.05"),
IsSelfManaged: Bool(true),
VendorConfiguration: map[string]string{
"serialNumber": "12312312",
"controller1": "1.1.1.1",
Expand Down Expand Up @@ -503,6 +504,7 @@ func verifyDeviceRequest(t *testing.T, device Device, req api.DeviceRequest) {
termLengthStr := strconv.Itoa(*device.TermLength)
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")
if *device.IsBYOL {
assert.Equal(t, DeviceLicenseModeBYOL, StringValue(req.LicenseMode), "LicenseMode matches")
} else {
Expand Down
Loading