Skip to content

Commit

Permalink
create device without default password(supported for only C8000V Auto…
Browse files Browse the repository at this point in the history
…nomous and Fortinet firewall devices)
  • Loading branch information
kpdhulipala committed Dec 3, 2024
1 parent 8149bdf commit 8d459ae
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 147 deletions.
93 changes: 47 additions & 46 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,52 +241,53 @@ 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
DiverseFromDeviceUUID *string
DiverseFromDeviceName *string
Tier *int
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
Tier *int
IsGenerateDefaultPassword *bool
}

// DeviceInterface describes Network Edge device interface
Expand Down
154 changes: 78 additions & 76 deletions internal/api/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,88 @@ 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"`
Tier *DeviceCoreInformation `json:"tier,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"`
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"`
Tier *DeviceCoreInformation `json:"tier,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"`
IsGenerateDefaultPassword *bool `json:"generateDefaultPassword,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"`
DiverseFromDeviceUUID *string `json:"diverseFromDeviceUuid,omitempty"`
Tier *int `json:"tier,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"`
Tier *int `json:"tier,omitempty"`
IsGenerateDefaultPassword *bool `json:"generateDefaultPassword,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 @@ -269,6 +269,7 @@ func mapDeviceAPIToDomain(apiDevice api.Device) *Device {
device.ClusterDetails = mapDeviceClusterDetailsAPIToDomain(apiDevice.ClusterDetails)
device.DiverseFromDeviceUUID = apiDevice.DiverseFromDeviceUUID
device.DiverseFromDeviceName = apiDevice.DiverseFromDeviceName
device.IsGenerateDefaultPassword = apiDevice.IsGenerateDefaultPassword
return &device
}

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

Expand Down
Loading

0 comments on commit 8d459ae

Please sign in to comment.