File: apitypes.go

package info (click to toggle)
golang-github-vmware-photon-controller-go-sdk 0.0~PROMOTED-738%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 556 kB
  • sloc: sh: 33; makefile: 4
file content (761 lines) | stat: -rw-r--r-- 25,431 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
// Copyright (c) 2016 VMware, Inc. All Rights Reserved.
//
// This product is licensed to you under the Apache License, Version 2.0 (the "License").
// You may not use this product except in compliance with the License.
//
// This product may include a number of subcomponents with separate copyright notices and
// license terms. Your use of these subcomponents is subject to the terms and conditions
// of the subcomponent's license, as noted in the LICENSE file.

package photon

import (
	"fmt"
)

type Entity struct {
	ID   string `json:"id"`
	Kind string `json:"kind"`
}

// Implement a generic sdk error
type SdkError struct {
	Message string
}

func (e SdkError) Error() string {
	return fmt.Sprintf("photon: %v", e.Message)
}

// Represents an error from the Photon API.
type ApiError struct {
	Code           string                 `json:"code"`
	Data           map[string]interface{} `json:"data"`
	Message        string                 `json:"message"`
	HttpStatusCode int                    `json:"-"` // Not part of API contract
}

// Implement Go error interface for ApiError
func (e ApiError) Error() string {
	return fmt.Sprintf(
		"photon: { HTTP status: '%v', code: '%v', message: '%v', data: '%v' }",
		e.HttpStatusCode,
		e.Code,
		e.Message,
		e.Data)
}

// Used to represent a generic HTTP error, i.e. an unexpected HTTP 500.
type HttpError struct {
	StatusCode int
	Message    string
}

// Implementation of error interface for HttpError
func (e HttpError) Error() string {
	return fmt.Sprintf("photon: HTTP %d: %v", e.StatusCode, e.Message)
}

// Represents an Photon task that has entered into an error state.
// Photon task errors can be caught and type-checked against with
// the usual Go idiom.
type TaskError struct {
	ID   string `json:"id"`
	Step Step   `json:"step,omitempty"`
}

// Implement Go error interface for TaskError.
func (e TaskError) Error() string {
	return fmt.Sprintf("photon: Task '%s' is in error state: {@step==%s}", e.ID, GetStep(e.Step))
}

// An error representing a timeout while waiting for a task to complete.
type TaskTimeoutError struct {
	ID string
}

// Implement Go error interface for TaskTimeoutError.
func (e TaskTimeoutError) Error() string {
	return fmt.Sprintf("photon: Timed out waiting for task '%s'. "+
		"Task may not be in error state, examine task for full details.", e.ID)
}

// Represents an operation (Step) within a Task.
type Step struct {
	ID                 string                 `json:"id"`
	Operation          string                 `json:"operation,omitempty"`
	State              string                 `json:"state"`
	StartedTime        int64                  `json:"startedTime"`
	EndTime            int64                  `json:"endTime,omitempty"`
	QueuedTime         int64                  `json:"queuedTime"`
	Sequence           int                    `json:"sequence,omitempty"`
	ResourceProperties map[string]interface{} `json:"resourceProperties,omitempty"`
	Errors             []ApiError             `json:"errors,omitempty"`
	Warnings           []ApiError             `json:"warnings,omitempty"`
	Options            map[string]interface{} `json:"options,omitempty"`
	SelfLink           string                 `json:"selfLink,omitempty"`
}

// Implement Go error interface for Step.
func GetStep(s Step) string {
	return fmt.Sprintf("{\"sequence\"=>\"%d\",\"state\"=>\"%s\",\"errors\"=>%s,\"warnings\"=>%s,\"operation\"=>\"%s\","+
		"\"startedTime\"=>\"%d\",\"queuedTime\"=>\"%d\",\"endTime\"=>\"%d\",\"options\"=>%s}",
		s.Sequence, s.State, s.Errors, s.Warnings, s.Operation, s.StartedTime, s.QueuedTime,
		s.EndTime, s.Options)

}

// Represents an asynchronous task.
type Task struct {
	ID                 string      `json:"id"`
	Operation          string      `json:"operation,omitempty"`
	State              string      `json:"state"`
	StartedTime        int64       `json:"startedTime"`
	EndTime            int64       `json:"endTime,omitempty"`
	QueuedTime         int64       `json:"queuedTime"`
	Entity             Entity      `json:"entity,omitempty"`
	SelfLink           string      `json:"selfLink,omitempty"`
	Steps              []Step      `json:"steps,omitempty"`
	ResourceProperties interface{} `json:"resourceProperties,omitempty"`
}

// Represents multiple tasks returned by the API.
type TaskList struct {
	Items []Task `json:"items"`
}

// Options for GetTasks API.
type TaskGetOptions struct {
	State      string `urlParam:"state"`
	Kind       string `urlParam:"kind"`
	EntityID   string `urlParam:"entityId"`
	EntityKind string `urlParam:"entityKind"`
}

type BaseCompact struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

type QuotaLineItem struct {
	Unit  string  `json:"unit"`
	Value float64 `json:"value"`
	Key   string  `json:"key"`
}

// The QuotaLineItem with limit and usage in one place.
type QuotaStatusLineItem struct {
	Unit  string  `json:"unit"`
	Limit float64 `json:"limit"`
	Usage float64 `json:"usage"`
}

// Creation spec for locality.
type LocalitySpec struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
}

// Creation spec for disks.
type DiskCreateSpec struct {
	Flavor     string         `json:"flavor"`
	Kind       string         `json:"kind"`
	CapacityGB int            `json:"capacityGb"`
	Affinities []LocalitySpec `json:"affinities,omitempty"`
	Name       string         `json:"name"`
	Tags       []string       `json:"tags,omitempty"`
}

// Represents a persistent disk.
type PersistentDisk struct {
	Flavor     string          `json:"flavor"`
	Cost       []QuotaLineItem `json:"cost"`
	Kind       string          `json:"kind"`
	Datastore  string          `json:"datastore,omitempty"`
	CapacityGB int             `json:"capacityGb,omitempty"`
	Name       string          `json:"name"`
	State      string          `json:"state"`
	ID         string          `json:"id"`
	VMs        []string        `json:"vms"`
	Tags       []string        `json:"tags,omitempty"`
	SelfLink   string          `json:"selfLink,omitempty"`
}

// Represents multiple persistent disks returned by the API.
type DiskList struct {
	Items []PersistentDisk `json:"items"`
}

// Creation spec for projects.
type ProjectCreateSpec struct {
	Name                       string   `json:"name"`
	SecurityGroups             []string `json:"securityGroups,omitempty"`
	DefaultRouterPrivateIpCidr string   `json:"defaultRouterPrivateIpCidr,omitempty"`
	ResourceQuota              Quota    `json:"quota,omitempty"`
}

// Represents multiple projects returned by the API.
type ProjectList struct {
	Items []ProjectCompact `json:"items"`
}

// Compact representation of projects.
type ProjectCompact struct {
	Kind           string          `json:"kind"`
	Name           string          `json:"name"`
	ID             string          `json:"id"`
	Tags           []string        `json:"tags"`
	SelfLink       string          `json:"selfLink"`
	SecurityGroups []SecurityGroup `json:"securityGroups"`
	ResourceQuota  Quota           `json:"quota,omitempty"`
}

// Represents an image.
type Image struct {
	Size                int64          `json:"size"`
	Kind                string         `json:"kind"`
	Name                string         `json:"name"`
	State               string         `json:"state"`
	ID                  string         `json:"id"`
	Tags                []string       `json:"tags"`
	Scope               ImageScope     `json:"scope"`
	SelfLink            string         `json:"selfLink"`
	Settings            []ImageSetting `json:"settings"`
	ReplicationType     string         `json:"replicationType"`
	ReplicationProgress string         `json:"replicationProgress"`
	SeedingProgress     string         `json:"seedingProgress"`
}

// Represents an image scope.
type ImageScope struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
}

// Represents an image setting.
type ImageSetting struct {
	Name         string `json:"name"`
	DefaultValue string `json:"defaultValue"`
}

// Creation spec for images.
type ImageCreateOptions struct {
	ReplicationType string
}

// Represents multiple images returned by the API.
type Images struct {
	Items []Image `json:"items"`
}

// Represents a component with status.
type Component struct {
	Component string
	Message   string
	Status    string
}

// Represents status of the photon system.
type Status struct {
	Status     string
	Components []Component
}

// Represents a single tenant.
type Tenant struct {
	Projects       []BaseCompact   `json:"projects"`
	Kind           string          `json:"kind"`
	Name           string          `json:"name"`
	ID             string          `json:"id"`
	SelfLink       string          `json:"selfLink"`
	Tags           []string        `json:"tags"`
	SecurityGroups []SecurityGroup `json:"securityGroups"`
	ResourceQuota  Quota           `json:"quota,omitempty"`
}

// Represents multiple tenants returned by the API.
type Tenants struct {
	Items []Tenant `json:"items"`
}

// Creation spec for tenants.
type TenantCreateSpec struct {
	Name           string   `json:"name"`
	SecurityGroups []string `json:"securityGroups,omitempty"`
	ResourceQuota  Quota    `json:"quota,omitempty"`
}

// Represents the quota
type Quota struct {
	QuotaLineItems map[string]QuotaStatusLineItem `json:"quotaItems"`
}

// QuotaSpec is used when set/update/excluding QuotaLineItems from existing Quota
type QuotaSpec map[string]QuotaStatusLineItem

// Creation spec for VMs.
type VmCreateSpec struct {
	Flavor        string            `json:"flavor"`
	SourceImageID string            `json:"sourceImageId"`
	AttachedDisks []AttachedDisk    `json:"attachedDisks"`
	Affinities    []LocalitySpec    `json:"affinities,omitempty"`
	Name          string            `json:"name"`
	Tags          []string          `json:"tags,omitempty"`
	Subnets       []string          `json:"subnets,omitempty"`
	Environment   map[string]string `json:"environment,omitempty"`
}

// Represents possible operations for VMs. Valid values include:
// START_VM, STOP_VM, RESTART_VM, SUSPEND_VM, RESUME_VM
type VmOperation struct {
	Operation string                 `json:"operation"`
	Arguments map[string]interface{} `json:"arguments,omitempty"`
}

// Represents metadata that can be set on a VM.
type VmMetadata struct {
	Metadata map[string]string `json:"metadata"`
}

// Represents tags that can be set on a VM.
type VmTag struct {
	Tag string `json:"value"`
}

// Represents a single attached disk.
type AttachedDisk struct {
	Flavor     string `json:"flavor"`
	Kind       string `json:"kind"`
	CapacityGB int    `json:"capacityGb,omitempty"`
	Name       string `json:"name"`
	State      string `json:"state"`
	ID         string `json:"id,omitempty"`
	BootDisk   bool   `json:"bootDisk"`
}

// Represents a single VM.
type VM struct {
	SourceImageID string            `json:"sourceImageId,omitempty"`
	Cost          []QuotaLineItem   `json:"cost"`
	Kind          string            `json:"kind"`
	AttachedDisks []AttachedDisk    `json:"attachedDisks"`
	Datastore     string            `json:"datastore,omitempty"`
	AttachedISOs  []ISO             `json:"attachedIsos,omitempty"`
	Tags          []string          `json:"tags,omitempty"`
	Metadata      map[string]string `json:"metadata,omitempty"`
	SelfLink      string            `json:"selfLink,omitempty"`
	Flavor        string            `json:"flavor"`
	Host          string            `json:"host,omitempty"`
	Name          string            `json:"name"`
	State         string            `json:"state"`
	ID            string            `json:"id"`
	FloatingIp    string            `json:"floatingIp"`
}

// Represents multiple VMs returned by the API.
type VMs struct {
	Items []VM `json:"items"`
}

// Represents an ISO.
type ISO struct {
	Size int64  `json:"size,omitempty"`
	Kind string `json:"kind,omitempty"`
	Name string `json:"name"`
	ID   string `json:"id"`
}

// Represents operations for disks.
type VmDiskOperation struct {
	DiskID    string                 `json:"diskId"`
	Arguments map[string]interface{} `json:"arguments,omitempty"`
}

// Represents a floating IP operation related to a VM.
type VmFloatingIpSpec struct {
	NetworkId string `json:"networkId"`
}

// Creation spec for flavors.
type FlavorCreateSpec struct {
	Cost []QuotaLineItem `json:"cost"`
	Kind string          `json:"kind"`
	Name string          `json:"name"`
}

// Represents a single flavor.
type Flavor struct {
	Cost     []QuotaLineItem `json:"cost"`
	Kind     string          `json:"kind"`
	Name     string          `json:"name"`
	ID       string          `json:"id"`
	Tags     []string        `json:"tags"`
	SelfLink string          `json:"selfLink"`
	State    string          `json:"state"`
}

// Represents multiple flavors returned by the API.
type FlavorList struct {
	Items []Flavor `json:"items"`
}

// Creation spec for hosts.
type HostCreateSpec struct {
	Username string            `json:"username"`
	Password string            `json:"password"`
	Zone     string            `json:"zone,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
	Address  string            `json:"address"`
	Tags     []string          `json:"usageTags"`
}

// Represents a host
type Host struct {
	Username   string            `json:"username"`
	Password   string            `json:"password"`
	Address    string            `json:"address"`
	Kind       string            `json:"kind"`
	ID         string            `json:"id"`
	Zone       string            `json:"zone,omitempty"`
	Tags       []string          `json:"usageTags"`
	Metadata   map[string]string `json:"metadata,omitempty"`
	SelfLink   string            `json:"selfLink"`
	State      string            `json:"state"`
	EsxVersion string            `json:"esxVersion"`
}

// Represents multiple hosts returned by the API.
type Hosts struct {
	Items []Host `json:"items"`
}

type Datastore struct {
	Kind     string   `json:"kind"`
	Type     string   `json:"type"`
	Tags     []string `json:"tags,omitempty"`
	ID       string   `json:"id"`
	SelfLink string   `json:"selfLink"`
}

type Datastores struct {
	Items []Datastore `json:"items"`
}

type SystemUsage struct {
	NumberHosts      int `json:"numberHosts"`
	NumberVMs        int `json:"numberVMs"`
	NumberTenants    int `json:"numberTenants"`
	NumberProjects   int `json:"numberProjects"`
	NumberDatastores int `json:"numberDatastores"`
	NumberServices   int `json:"numberServices"`
}

// Represents stats information
type StatsInfo struct {
	Enabled       bool   `json:"enabled,omitempty"`
	StoreEndpoint string `json:"storeEndpoint,omitempty"`
	StorePort     int    `json:"storePort,omitempty"`
}

// Represents authentication information
type AuthInfo struct {
	Password       string   `json:"password,omitempty"`
	Endpoint       string   `json:"endpoint,omitempty"`
	Domain         string   `json:"domain,omitempty"`
	Port           int      `json:"port,omitempty"`
	SecurityGroups []string `json:"securityGroups,omitempty"`
	Username       string   `json:"username,omitempty"`
}

// Represents ip range
type IpRange struct {
	Start string `json:"start,omitempty"`
	End   string `json:"end,omitempty"`
}

// Represents creation spec for network configuration.
type NetworkConfigurationCreateSpec struct {
	Enabled         bool     `json:"sdnEnabled,omitempty"`
	Address         string   `json:"networkManagerAddress,omitempty"`
	Username        string   `json:"networkManagerUsername,omitempty"`
	Password        string   `json:"networkManagerPassword,omitempty"`
	NetworkZoneId   string   `json:"networkZoneId,omitempty"`
	TopRouterId     string   `json:"networkTopRouterId,omitempty"`
	EdgeIpPoolId    string   `json:"networkEdgeIpPoolId,omitempty"`
	HostUplinkPnic  string   `json:"networkHostUplinkPnic,omitempty"`
	IpRange         string   `json:"ipRange,omitempty"`
	ExternalIpRange *IpRange `json:"externalIpRange,omitempty"`
}

// Represents network configuration.
type NetworkConfiguration struct {
	Enabled         bool     `json:"sdnEnabled,omitempty"`
	Address         string   `json:"networkManagerAddress,omitempty"`
	Username        string   `json:"networkManagerUsername,omitempty"`
	Password        string   `json:"networkManagerPassword,omitempty"`
	NetworkZoneId   string   `json:"networkZoneId,omitempty"`
	TopRouterId     string   `json:"networkTopRouterId,omitempty"`
	EdgeIpPoolId    string   `json:"networkEdgeIpPoolId,omitempty"`
	HostUplinkPnic  string   `json:"networkHostUplinkPnic,omitempty"`
	IpRange         string   `json:"ipRange,omitempty"`
	FloatingIpRange *IpRange `json:"floatingIpRange,omitempty"`
	SnatIp          string   `json:"snatIp,omitempty"`
}

// Represents a router
type Router struct {
	ID            string `json:"id"`
	Kind          string `json:"kind"`
	Name          string `json:"name"`
	PrivateIpCidr string `json:"privateIpCidr"`
	IsDefault     bool   `json:"isDefault"`
}

// Represents multiple routers returned by the API.
type Routers struct {
	Items []Router `json:"items"`
}

type RouterCreateSpec struct {
	Name          string `json:"name"`
	PrivateIpCidr string `json:"privateIpCidr"`
}

// Represents name that can be set for router
type RouterUpdateSpec struct {
	RouterName string `json:"name"`
}

// Creation spec for Service Configuration.
type ServiceConfigurationSpec struct {
	Type    string `json:"type"`
	ImageID string `json:"imageId"`
}

// Represnts a Service configuration.
type ServiceConfiguration struct {
	Kind    string `json:"kind"`
	Type    string `json:"type"`
	ImageID string `json:"imageId"`
}

// Creation spec for services.
type ServiceCreateSpec struct {
	Name               string            `json:"name"`
	Type               string            `json:"type"`
	VMFlavor           string            `json:"vmFlavor,omitempty"`
	MasterVmFlavor     string            `json:"masterVmFlavor,omitempty"`
	WorkerVmFlavor     string            `json:"workerVmFlavor,omitempty"`
	DiskFlavor         string            `json:"diskFlavor,omitempty"`
	SubnetId           string            `json:"subnetId,omitempty"`
	ImageID            string            `json:"imageId,omitempty"`
	WorkerCount        int               `json:"workerCount"`
	BatchSizeWorker    int               `json:"workerBatchExpansionSize,omitempty"`
	ExtendedProperties map[string]string `json:"extendedProperties"`
}

// Represents a service.
type Service struct {
	Kind               string                `json:"kind"`
	Name               string                `json:"name"`
	State              string                `json:"state"`
	ID                 string                `json:"id"`
	Type               string                `json:"type"`
	ImageID            string                `json:"imageId"`
	UpgradeStatus      *ServiceUpgradeStatus `json:"upgradeStatus,omitempty"`
	ProjectID          string                `json:"projectID,omitempty"`
	ClientID           string                `json:"clientId,omitempty"`
	WorkerCount        int                   `json:"workerCount"`
	SelfLink           string                `json:"selfLink,omitempty"`
	ErrorReason        string                `json:"errorReason,omitempty"`
	ExtendedProperties map[string]string     `json:"extendedProperties"`
}

// Represents the status of a service during upgrade.
type ServiceUpgradeStatus struct {
	NewImageID           string `json:"newImageId"`
	UpgradeMessage       string `json:"upgradeMessage,omitempty"`
	TotalNodes           int    `json:"totalNodes,omitempty"`
	NumNodesUpgraded     int    `json:"numNodesUpgraded"`
	UpgradeResultMessage string `json:"upgradeResultMessage,omitempty"`
}

// Represents multiple services returned by the API
type Services struct {
	Items []Service `json:"items"`
}

// Represents service size that can be resized for service
type ServiceResizeOperation struct {
	NewWorkerCount int `json:"newWorkerCount"`
}

// Represents service imageId that can be updated during change version
type ServiceChangeVersionOperation struct {
	NewImageID string `json:"newImageId"`
}

// Represents a security group
type SecurityGroup struct {
	Name      string `json:"name"`
	Inherited bool   `json:"inherited"`
}

// Represents set_security_groups spec
type SecurityGroupsSpec struct {
	Items []string `json:"items"`
}

// Represents availability zone that can be set for host
type HostSetAvailabilityZoneOperation struct {
	AvailabilityZoneId string `json:"availabilityZoneId"`
}

// Represents single zone.
type Zone struct {
	Kind     string `json:"kind"`
	Name     string `json:"name"`
	State    string `json:"state"`
	ID       string `json:"id"`
	SelfLink string `json:"selfLink"`
}

// Represents multiple zones returned by the API.
type Zones struct {
	Items []Zone `json:"items"`
}

// Creation spec for zones.
type ZoneCreateSpec struct {
	Name string `json:"name"`
}

// Represents the list of image datastores.
type ImageDatastores struct {
	Items []string `json:"items"`
}

// Image creation spec.
type ImageCreateSpec struct {
	Name            string `json:"name"`
	ReplicationType string `json:"replicationType"`
}

// Represents deployment info
type Info struct {
	BaseVersion   string `json:"baseVersion"`
	FullVersion   string `json:"fullVersion"`
	GitCommitHash string `json:"gitCommitHash"`
	NetworkType   string `json:"networkType"`
}

// NSX configuration spec
type NsxConfigurationSpec struct {
	NsxAddress             string            `json:"nsxAddress"`
	NsxUsername            string            `json:"nsxUsername"`
	NsxPassword            string            `json:"nsxPassword"`
	DhcpServerAddresses    map[string]string `json:"dhcpServerAddresses"`
	FloatingIpRootRange    IpRange           `json:"floatingIpRootRange"`
	T0RouterId             string            `json:"t0RouterId"`
	EdgeClusterId          string            `json:"edgeClusterId"`
	OverlayTransportZoneId string            `json:"overlayTransportZoneId"`
	TunnelIpPoolId         string            `json:"tunnelIpPoolId"`
	HostUplinkPnic         string            `json:"hostUplinkPnic"`
	HostUplinkVlanId       int               `json:"hostUplinkVlanId"`
	DnsServerAddresses     []string          `json:"dnsServerAddresses"`
}

// Represents a network
type Network struct {
	ID            string `json:"id"`
	Kind          string `json:"kind"`
	Name          string `json:"name"`
	PrivateIpCidr string `json:"privateIpCidr"`
	IsDefault     bool   `json:"isDefault"`
}

// Represents multiple networks returned by the API.
type Networks struct {
	Items []Network `json:"items"`
}

type NetworkCreateSpec struct {
	Name          string `json:"name"`
	PrivateIpCidr string `json:"privateIpCidr"`
}

// Represents name that can be set for network
type NetworkUpdateSpec struct {
	NetworkName string `json:"name"`
}

// Represents port groups.
type PortGroups struct {
	Names []string `json:"names"`
}

// Represents a subnet
type Subnet struct {
	ID                 string            `json:"id"`
	Kind               string            `json:"kind"`
	Name               string            `json:"name"`
	Description        string            `json:"description,omitempty"`
	PrivateIpCidr      string            `json:"privateIpCidr"`
	ReservedIps        map[string]string `json:"reservedIps"`
	State              string            `json:"state"`
	IsDefault          bool              `json:"isDefault"`
	PortGroups         PortGroups        `json:"portGroups"`
	DnsServerAddresses []string          `json:"dnsServerAddresses"`
}

// Represents multiple subnets returned by the API.
type Subnets struct {
	Items []Subnet `json:"items"`
}

// Creation spec for subnets.
type SubnetCreateSpec struct {
	Name               string     `json:"name"`
	Description        string     `json:"description"`
	PrivateIpCidr      string     `json:"privateIpCidr"`
	Type               string     `json:"type"`
	PortGroups         PortGroups `json:"portGroups"`
	DnsServerAddresses []string   `json:"dnsServerAddresses"`
}

// Represents name that can be set for subnet
type SubnetUpdateSpec struct {
	SubnetName string `json:"name"`
}

// Identity and Access Management (IAM)
// IAM role binding
type RoleBinding struct {
	Role     string   `json:"role"`
	Subjects []string `json:"subjects"`
}

type RoleBindingDelta struct {
	Action  string `json:"action"`
	Role    string `json:"role"`
	Subject string `json:"subject"`
}

type SystemInfo struct {
	NTPEndpoint             string                 `json:"ntpEndpoint,omitempty"`
	UseImageDatastoreForVms bool                   `json:"useImageDatastoreForVms,omitempty"`
	Auth                    *AuthInfo              `json:"auth"`
	NetworkConfiguration    *NetworkConfiguration  `json:"networkConfiguration"`
	Kind                    string                 `json:"kind"`
	SyslogEndpoint          string                 `json:"syslogEndpoint,omitempty"`
	Stats                   *StatsInfo             `json:"stats,omitempty"`
	State                   string                 `json:"state"`
	ImageDatastores         []string               `json:"imageDatastores"`
	ServiceConfigurations   []ServiceConfiguration `json:"serviceConfigurations,omitempty"`
	LoadBalancerEnabled     bool                   `json:"loadBalancerEnabled"`
	LoadBalancerAddress     string                 `json:"loadBalancerAddress"`
	BaseVersion             string                 `json:"baseVersion"`
	FullVersion             string                 `json:"fullVersion"`
	GitCommitHash           string                 `json:"gitCommitHash"`
	NetworkType             string                 `json:"networkType"`
}