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 diverse device uuid in Create Single Device #30

Closed
wants to merge 3 commits into from
Closed
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
97 changes: 50 additions & 47 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,57 +230,60 @@ func (e UpdateError) Error() string {

// Account describes Network Edge customer account details
type Account struct {
Name *string
Number *string
Status *string
UCMID *string
Name *string
Number *string
Status *string
UCMID *string
ProjectID *string
}

// 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
15 changes: 8 additions & 7 deletions internal/api/account.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package api

//AccountResponse describes response to Network Edge
//billing account query
// AccountResponse describes response to Network Edge
// billing account query
type AccountResponse struct {
Accounts []Account `json:"accounts,omitempty"`
}

//Account describes Network Edge billing account
// Account describes Network Edge billing account
type Account struct {
Name *string `json:"accountName,omitempty"`
Number *string `json:"accountNumber,omitempty"`
UCMID *string `json:"accountUcmId,omitempty"`
Status *string `json:"accountStatus,omitempty"`
Name *string `json:"accountName,omitempty"`
Number *string `json:"accountNumber,omitempty"`
UCMID *string `json:"accountUcmId,omitempty"`
Status *string `json:"accountStatus,omitempty"`
ProjectID *string `json:"projectId,omitempty"`
}
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
11 changes: 6 additions & 5 deletions rest_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/equinix/ne-go/internal/api"
)

//GetAccounts retrieves accounts and their details for a given metro code using Network Edge API
// GetAccounts retrieves accounts and their details for a given metro code using Network Edge API
func (c RestClient) GetAccounts(metroCode string) ([]Account, error) {
path := "/ne/v1/accounts/" + url.PathEscape(metroCode)
respBody := api.AccountResponse{}
Expand All @@ -23,10 +23,11 @@ func mapAccountsAPIToDomain(apiAccounts []api.Account) []Account {
transformed := make([]Account, len(apiAccounts))
for i := range apiAccounts {
transformed[i] = Account{
Name: apiAccounts[i].Name,
Number: apiAccounts[i].Number,
UCMID: apiAccounts[i].UCMID,
Status: apiAccounts[i].Status,
Name: apiAccounts[i].Name,
Number: apiAccounts[i].Number,
UCMID: apiAccounts[i].UCMID,
Status: apiAccounts[i].Status,
ProjectID: apiAccounts[i].ProjectID,
}
}
return transformed
Expand Down
1 change: 1 addition & 0 deletions rest_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ func verifyAccount(t *testing.T, apiAccount api.Account, account Account) {
assert.Equal(t, apiAccount.Number, account.Number, "Account Number matches")
assert.Equal(t, apiAccount.Status, account.Status, "Account Status matches")
assert.Equal(t, apiAccount.UCMID, account.UCMID, "Account UCMID matches")
assert.Equal(t, apiAccount.ProjectID, account.ProjectID, "ProjectID matches")
}
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
Loading
Loading