@@ -21,14 +21,18 @@ import (
21
21
"errors"
22
22
)
23
23
24
+ // CloudInstancesService provides methods for managing cloud instances via the Utho API.
24
25
type CloudInstancesService service
25
26
27
+ // CloudInstances represents a list of cloud instances returned by the API.
26
28
type CloudInstances struct {
27
29
CloudInstance []CloudInstance `json:"cloud"`
28
30
Meta Meta `json:"meta"`
29
31
Status string `json:"status,omitempty" faker:"oneof:success,error"`
30
32
Message string `json:"message,omitempty" faker:"sentence"`
31
33
}
34
+
35
+ // CloudInstance represents a single cloud instance.
32
36
type CloudInstance struct {
33
37
ID string `json:"cloudid" faker:"oneof: 00000,11111,22222,33333"`
34
38
Hostname string `json:"hostname"`
@@ -84,23 +88,33 @@ type CloudInstance struct {
84
88
Gpus []any `json:"gpus,omitempty"`
85
89
Rescue int `json:"rescue"`
86
90
}
91
+
92
+ // Features represents the features available for a cloud instance.
87
93
type Features struct {
88
94
Backups string `json:"backups" faker:"oneof:0,1"`
89
95
}
96
+
97
+ // Image represents an image available for a cloud instance.
90
98
type Image struct {
91
99
Name string `json:"name"`
92
100
Distribution string `json:"distribution"`
93
101
Version string `json:"version" faker:"semver"`
94
102
Image string `json:"image"`
95
103
Cost string `json:"cost"`
96
104
}
105
+
106
+ // Networks represents the network configuration for a cloud instance.
97
107
type Networks struct {
98
108
Public Public `json:"public"`
99
109
Private Private `json:"private"`
100
110
}
111
+
112
+ // Public represents the public network configuration for a cloud instance.
101
113
type Public struct {
102
114
V4 V4PublicArray `json:"v4"`
103
115
}
116
+
117
+ // V4Public represents a public IPv4 address for a cloud instance.
104
118
type V4Public struct {
105
119
IPAddress string `json:"ip_address,omitempty" faker:"ipv4"`
106
120
Netmask string `json:"netmask,omitempty" faker:"ipv4_netmask"`
@@ -112,9 +126,12 @@ type V4Public struct {
112
126
Mac string `json:"mac,omitempty"`
113
127
}
114
128
129
+ // Private represents the private network configuration for a cloud instance.
115
130
type Private struct {
116
131
V4 []V4Private `json:"v4"`
117
132
}
133
+
134
+ // V4Private represents a private IPv4 address for a cloud instance.
118
135
type V4Private struct {
119
136
Noip int `json:"noip"`
120
137
IPAddress string `json:"ip_address,omitempty" faker:"ipv4"`
@@ -128,6 +145,8 @@ type V4Private struct {
128
145
Mac string `json:"mac,omitempty"`
129
146
Primary string `json:"primary,omitempty" faker:"oneof:1,0"`
130
147
}
148
+
149
+ // Storages represents a collection of storage devices attached to a cloud instance.
131
150
type Storages struct {
132
151
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
133
152
Size int `json:"size"`
@@ -138,6 +157,8 @@ type Storages struct {
138
157
Bus string `json:"bus" faker:"oneof:virtio,sata"`
139
158
Type string `json:"type" faker:"oneof:ssd,hdd"`
140
159
}
160
+
161
+ // Storage represents a single storage device attached to a cloud instance.
141
162
type Storage struct {
142
163
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
143
164
Size int `json:"size"`
@@ -148,41 +169,54 @@ type Storage struct {
148
169
Bus string `json:"bus" faker:"oneof:virtio,sata"`
149
170
Type string `json:"type" faker:"oneof:ssd,hdd"`
150
171
}
172
+
173
+ // Snapshot represents a snapshot of a cloud instance's storage.
151
174
type Snapshot struct {
152
175
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
153
176
Size string `json:"size" faker:"oneof:1GB,50GB,100GB"`
154
177
CreatedAt string `json:"created_at" faker:"date"`
155
178
Note string `json:"note" faker:"sentence"`
156
179
Name string `json:"name"`
157
180
}
181
+
182
+ // CloudInstanceFirewall represents a firewall attached to a cloud instance.
158
183
type CloudInstanceFirewall struct {
159
184
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
160
185
Name string `json:"name"`
161
186
CreatedAt string `json:"created_at" faker:"date"`
162
187
}
188
+
189
+ // Meta contains metadata about a list of resources.
163
190
type Meta struct {
164
191
Total int `json:"total"`
165
192
Totalpages int `json:"totalpages"`
166
193
Currentpage int `json:"currentpage"`
167
194
}
195
+
196
+ // Snapshots represents a collection of snapshots for a cloud instance.
168
197
type Snapshots struct {
169
198
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
170
199
Size string `json:"size" faker:"oneof:1GB,50GB,100GB"`
171
200
CreatedAt string `json:"created_at" faker:"date"`
172
201
Note string `json:"note" faker:"sentence"`
173
202
Name string `json:"name"`
174
203
}
204
+
205
+ // CloudInstanceFirewalls represents a collection of firewalls attached to a cloud instance.
175
206
type CloudInstanceFirewalls struct {
176
207
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
177
208
Name string `json:"name"`
178
209
CreatedAt string `json:"created_at" faker:"date"`
179
210
}
180
211
212
+ // OsImages represents a list of OS images available for cloud instances.
181
213
type OsImages struct {
182
214
OsImages []OsImage `json:"images"`
183
215
Status string `json:"status,omitempty" faker:"oneof:success,error"`
184
216
Message string `json:"message,omitempty" faker:"sentence"`
185
217
}
218
+
219
+ // OsImage represents a single OS image available for cloud instances.
186
220
type OsImage struct {
187
221
Distro string `json:"distro,omitempty"`
188
222
Distribution string `json:"distribution"`
@@ -191,11 +225,14 @@ type OsImage struct {
191
225
Cost float64 `json:"cost"`
192
226
}
193
227
228
+ // Plans represents a list of available plans for cloud instances.
194
229
type Plans struct {
195
230
Plans []Plan `json:"plans"`
196
231
Status string `json:"status,omitempty" faker:"oneof:success,error"`
197
232
Message string `json:"message,omitempty" faker:"sentence"`
198
233
}
234
+
235
+ // Plan represents a single plan for a cloud instance.
199
236
type Plan struct {
200
237
ID string `json:"id" faker:"oneof: 00000,11111,22222,33333"`
201
238
Type string `json:"type" faker:"oneof:ramcpu,disk"`
@@ -209,6 +246,7 @@ type Plan struct {
209
246
Plantype string `json:"plantype" faker:"oneof:cloud,dedicated"`
210
247
}
211
248
249
+ // CreateCloudInstanceParams contains parameters for creating a cloud instance.
212
250
type CreateCloudInstanceParams struct {
213
251
Dcslug string `json:"dcslug"`
214
252
Image string `json:"image"`
@@ -230,10 +268,12 @@ type CreateCloudInstanceParams struct {
230
268
Cloud []CloudHostname `json:"cloud"`
231
269
}
232
270
271
+ // CloudHostname represents the hostname for a cloud instance.
233
272
type CloudHostname struct {
234
273
Hostname string `json:"hostname"`
235
274
}
236
275
276
+ // CreateCloudInstanceResponse represents the response after creating a cloud instance.
237
277
type CreateCloudInstanceResponse struct {
238
278
ID string `json:"cloudid" faker:"oneof: 00000,11111,22222,33333"`
239
279
Password string `json:"password" faker:"password"`
@@ -293,6 +333,7 @@ func (s *CloudInstancesService) List() ([]CloudInstance, error) {
293
333
return cloudInstances .CloudInstance , nil
294
334
}
295
335
336
+ // DeleteCloudInstanceParams contains parameters for deleting a cloud instance.
296
337
type DeleteCloudInstanceParams struct {
297
338
// Please provide confirm string as follow: "I am aware this action will delete data and server permanently"
298
339
Confirm string `json:"confirm"`
@@ -346,6 +387,7 @@ func (s *CloudInstancesService) ListResizePlans(instanceId string) ([]Plan, erro
346
387
return plans .Plans , nil
347
388
}
348
389
390
+ // CreateSnapshotParams contains parameters for creating a snapshot.
349
391
type CreateSnapshotParams struct {
350
392
Name string `json:"name"`
351
393
}
@@ -413,6 +455,7 @@ func (s *CloudInstancesService) DisableBackup(instanceId string) (*BasicResponse
413
455
return & basicResponse , nil
414
456
}
415
457
458
+ // UpdateBillingCycleParams contains parameters for updating the billing cycle of a cloud instance.
416
459
type UpdateBillingCycleParams struct {
417
460
Billingcycle string `json:"billingcycle"`
418
461
}
@@ -497,6 +540,7 @@ func (s *CloudInstancesService) PowerOn(instanceId string) (*BasicResponse, erro
497
540
return & basicResponse , nil
498
541
}
499
542
543
+ // RebuildCloudInstanceParams contains parameters for rebuilding a cloud instance.
500
544
type RebuildCloudInstanceParams struct {
501
545
Image string `json:"image"`
502
546
// Please provide confirm string as follow: "I am aware this action will delete data permanently and build a fresh server"
@@ -519,6 +563,7 @@ func (s *CloudInstancesService) Rebuild(instanceId string, rebuildCloudInstanceP
519
563
return & basicResponse , nil
520
564
}
521
565
566
+ // ResetPasswordResponse represents the response after resetting a cloud instance password.
522
567
type ResetPasswordResponse struct {
523
568
Password string `json:"password" faker:"password"`
524
569
Status string `json:"status,omitempty" faker:"oneof:success,error"`
@@ -541,6 +586,7 @@ func (s *CloudInstancesService) ResetPassword(instanceId string) (*ResetPassword
541
586
return & resetPasswordResponse , nil
542
587
}
543
588
589
+ // ResizeCloudInstanceParams contains parameters for resizing a cloud instance.
544
590
type ResizeCloudInstanceParams struct {
545
591
Type string `json:"type"`
546
592
Plan string `json:"plan"`
@@ -578,6 +624,7 @@ func (s *CloudInstancesService) RestoreSnapshot(instanceId, snapshotId string) (
578
624
return & basicResponse , nil
579
625
}
580
626
627
+ // UpdateStorageParams contains parameters for updating a storage device attached to a cloud instance.
581
628
type UpdateStorageParams struct {
582
629
Bus string `json:"bus"`
583
630
Type string `json:"type"`
@@ -615,6 +662,7 @@ func (s *CloudInstancesService) AssignPublicIP(cloudid string) (*BasicResponse,
615
662
return & basicResponse , nil
616
663
}
617
664
665
+ // UpdateRDNSParams contains parameters for updating the RDNS of a cloud instance.
618
666
type UpdateRDNSParams struct {
619
667
Rdns string `json:"rdns"`
620
668
}
@@ -667,6 +715,7 @@ func (s *CloudInstancesService) DisableRescue(cloudid string) (*BasicResponse, e
667
715
return & basicResponse , nil
668
716
}
669
717
718
+ // MountISOParams contains parameters for mounting an ISO to a cloud instance.
670
719
type MountISOParams struct {
671
720
Iso string `json:"iso"`
672
721
}
@@ -704,6 +753,7 @@ func (s *CloudInstancesService) UnmountISO(cloudid string) (*BasicResponse, erro
704
753
}
705
754
706
755
// Custom type to handle unmarshaling of V4Public
756
+ // V4PublicArray is a custom type to handle unmarshaling of V4Public.
707
757
type V4PublicArray []V4Public
708
758
709
759
func (v * V4PublicArray ) UnmarshalJSON (data []byte ) error {
0 commit comments