File: volume.go

package info (click to toggle)
golang-github-hetznercloud-hcloud-go 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,072 kB
  • sloc: sh: 5; makefile: 2
file content (110 lines) | stat: -rw-r--r-- 3,686 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
package schema

import "time"

// Volume defines the schema of a volume.
type Volume struct {
	ID          int64             `json:"id"`
	Name        string            `json:"name"`
	Server      *int64            `json:"server"`
	Status      string            `json:"status"`
	Location    Location          `json:"location"`
	Size        int               `json:"size"`
	Protection  VolumeProtection  `json:"protection"`
	Labels      map[string]string `json:"labels"`
	LinuxDevice string            `json:"linux_device"`
	Created     time.Time         `json:"created"`
}

// VolumeCreateRequest defines the schema of the request
// to create a volume.
type VolumeCreateRequest struct {
	Name      string             `json:"name"`
	Size      int                `json:"size"`
	Server    *int64             `json:"server,omitempty"`
	Location  interface{}        `json:"location,omitempty"` // int, string, or nil
	Labels    *map[string]string `json:"labels,omitempty"`
	Automount *bool              `json:"automount,omitempty"`
	Format    *string            `json:"format,omitempty"`
}

// VolumeCreateResponse defines the schema of the response
// when creating a volume.
type VolumeCreateResponse struct {
	Volume      Volume   `json:"volume"`
	Action      *Action  `json:"action"`
	NextActions []Action `json:"next_actions"`
}

// VolumeListResponse defines the schema of the response
// when listing volumes.
type VolumeListResponse struct {
	Volumes []Volume `json:"volumes"`
}

// VolumeGetResponse defines the schema of the response
// when retrieving a single volume.
type VolumeGetResponse struct {
	Volume Volume `json:"volume"`
}

// VolumeUpdateRequest defines the schema of the request to update a volume.
type VolumeUpdateRequest struct {
	Name   string             `json:"name,omitempty"`
	Labels *map[string]string `json:"labels,omitempty"`
}

// VolumeUpdateResponse defines the schema of the response when updating a volume.
type VolumeUpdateResponse struct {
	Volume Volume `json:"volume"`
}

// VolumeProtection defines the schema of a volume's resource protection.
type VolumeProtection struct {
	Delete bool `json:"delete"`
}

// VolumeActionChangeProtectionRequest defines the schema of the request to
// change the resource protection of a volume.
type VolumeActionChangeProtectionRequest struct {
	Delete *bool `json:"delete,omitempty"`
}

// VolumeActionChangeProtectionResponse defines the schema of the response when
// changing the resource protection of a volume.
type VolumeActionChangeProtectionResponse struct {
	Action Action `json:"action"`
}

// VolumeActionAttachVolumeRequest defines the schema of the request to
// attach a volume to a server.
type VolumeActionAttachVolumeRequest struct {
	Server    int64 `json:"server"`
	Automount *bool `json:"automount,omitempty"`
}

// VolumeActionAttachVolumeResponse defines the schema of the response when
// attaching a volume to a server.
type VolumeActionAttachVolumeResponse struct {
	Action Action `json:"action"`
}

// VolumeActionDetachVolumeRequest defines the schema of the request to
// create an detach volume action.
type VolumeActionDetachVolumeRequest struct{}

// VolumeActionDetachVolumeResponse defines the schema of the response when
// creating an detach volume action.
type VolumeActionDetachVolumeResponse struct {
	Action Action `json:"action"`
}

// VolumeActionResizeVolumeRequest defines the schema of the request to resize a volume.
type VolumeActionResizeVolumeRequest struct {
	Size int `json:"size"`
}

// VolumeActionResizeVolumeResponse defines the schema of the response when resizing a volume.
type VolumeActionResizeVolumeResponse struct {
	Action Action `json:"action"`
}