Skip to content

Commit a01d8cb

Browse files
feat: managed object storage (#265)
1 parent 1042b25 commit a01d8cb

30 files changed

Lines changed: 8402 additions & 0 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
1515
### Added
1616
- network: `dhcp_routes` field to IP network for additional DHCP classless static routes to be delivered if the DHCP is enabled
1717
- network: `static_routes` field to router for defining static routes
18+
- Managed Object Storage support
1819

1920
## [6.6.0]
2021

upcloud/managed_object_storage.go

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package upcloud
2+
3+
import (
4+
"time"
5+
)
6+
7+
const (
8+
// ManagedObjectStorageConfiguredStatusStarted indicates that service is running
9+
ManagedObjectStorageConfiguredStatusStarted ManagedObjectStorageConfiguredStatus = "started"
10+
// ManagedObjectStorageConfiguredStatusStopped indicates that service is stopped
11+
ManagedObjectStorageConfiguredStatusStopped ManagedObjectStorageConfiguredStatus = "stopped"
12+
)
13+
14+
const (
15+
// ManagedObjectStorageOperationalStateDeleteDNS indicates that DNS records are being removed
16+
ManagedObjectStorageOperationalStateDeleteDNS ManagedObjectStorageOperationalState = "delete-dns"
17+
// ManagedObjectStorageOperationalStateDeleteNetwork indicates that network is being reconfigured
18+
ManagedObjectStorageOperationalStateDeleteNetwork ManagedObjectStorageOperationalState = "delete-network"
19+
// ManagedObjectStorageOperationalStateDeleteService indicates that service is being deleted
20+
ManagedObjectStorageOperationalStateDeleteService ManagedObjectStorageOperationalState = "delete-service"
21+
// ManagedObjectStorageOperationalStateDeleteUser indicates that users are being deleted
22+
ManagedObjectStorageOperationalStateDeleteUser ManagedObjectStorageOperationalState = "delete-user"
23+
// ManagedObjectStorageOperationalStatePending indicates newly created service or that started reconfiguration
24+
ManagedObjectStorageOperationalStatePending ManagedObjectStorageOperationalState = "started"
25+
// ManagedObjectStorageOperationalStateRunning indicates that service is up and running
26+
ManagedObjectStorageOperationalStateRunning ManagedObjectStorageOperationalState = "running"
27+
// ManagedObjectStorageOperationalStateSetupCheckup indicates that service configuration and state are being verified
28+
ManagedObjectStorageOperationalStateSetupCheckup ManagedObjectStorageOperationalState = "setup-checkup"
29+
// ManagedObjectStorageOperationalStateSetupDNS indicates that DNS records are being updated
30+
ManagedObjectStorageOperationalStateSetupDNS ManagedObjectStorageOperationalState = "setup-dns"
31+
// ManagedObjectStorageOperationalStateSetupNetwork indicates that network is being configured
32+
ManagedObjectStorageOperationalStateSetupNetwork ManagedObjectStorageOperationalState = "setup-network"
33+
// ManagedObjectStorageOperationalStateSetupService indicates that service is being configured
34+
ManagedObjectStorageOperationalStateSetupService ManagedObjectStorageOperationalState = "setup-service"
35+
// ManagedObjectStorageOperationalStateSetupUser indicates that users are being configured
36+
ManagedObjectStorageOperationalStateSetupUser ManagedObjectStorageOperationalState = "setup-user"
37+
// ManagedObjectStorageOperationalStateStopped indicates that service is down
38+
ManagedObjectStorageOperationalStateStopped ManagedObjectStorageOperationalState = "stopped"
39+
)
40+
41+
const (
42+
// ManagedObjectStorageUserOperationalStatePending indicates a newly attached user
43+
ManagedObjectStorageUserOperationalStatePending ManagedObjectStorageUserOperationalState = "pending"
44+
// ManagedObjectStorageUserOperationalStateReady indicates that the user is configured and ready for access keys issuing
45+
ManagedObjectStorageUserOperationalStateReady ManagedObjectStorageUserOperationalState = "ready"
46+
)
47+
48+
type (
49+
// ManagedObjectStorageConfiguredStatus indicates the service's current intended status. Managed by the customer
50+
ManagedObjectStorageConfiguredStatus string
51+
// ManagedObjectStorageOperationalState indicates the service's current operational, effective state. Managed by the system
52+
ManagedObjectStorageOperationalState string
53+
// ManagedObjectStorageUserOperationalState indicates the user's current operational, effective state. Managed by the system
54+
ManagedObjectStorageUserOperationalState string
55+
)
56+
57+
// ManagedObjectStorage represents a Managed Object Storage service
58+
type ManagedObjectStorage struct {
59+
ConfiguredStatus ManagedObjectStorageConfiguredStatus `json:"configured_status"`
60+
CreatedAt time.Time `json:"created_at"`
61+
Endpoints []ManagedObjectStorageEndpoint `json:"endpoints"`
62+
Labels []Label `json:"labels"`
63+
Networks []ManagedObjectStorageNetwork `json:"networks"`
64+
OperationalState ManagedObjectStorageOperationalState `json:"operational_state"`
65+
Region string `json:"region"`
66+
UpdatedAt time.Time `json:"updated_at"`
67+
Users []ManagedObjectStorageUser `json:"users"`
68+
UUID string `json:"uuid"`
69+
}
70+
71+
// ManagedObjectStorageEndpoint represents an endpoint for accessing the Managed Object Storage service
72+
type ManagedObjectStorageEndpoint struct {
73+
DomainName string `json:"domain_name"`
74+
Type string `json:"type"`
75+
}
76+
77+
// ManagedObjectStorageNetwork represents a network from where object storage can be used. Private networks must reside in object storage region
78+
type ManagedObjectStorageNetwork struct {
79+
Family string `json:"family"`
80+
Name string `json:"name"`
81+
Type string `json:"type"`
82+
UUID *string `json:"uuid,omitempty"`
83+
}
84+
85+
// ManagedObjectStorageUser represents a user for the Managed Object Storage service
86+
type ManagedObjectStorageUser struct {
87+
AccessKeys []ManagedObjectStorageUserAccessKey `json:"access_keys"`
88+
CreatedAt time.Time `json:"created_at"`
89+
OperationalState ManagedObjectStorageUserOperationalState `json:"operational_state"`
90+
UpdatedAt time.Time `json:"updated_at"`
91+
Username string `json:"username"`
92+
}
93+
94+
// ManagedObjectStorageRegion represents a region where Managed Object Storage service can be hosted
95+
type ManagedObjectStorageRegion struct {
96+
Name string `json:"name"`
97+
PrimaryZone string `json:"primary_zone"`
98+
Zones []ManagedObjectStorageRegionZone `json:"zones"`
99+
}
100+
101+
// ManagedObjectStorageRegionZone represents a zone within the Managed Object Storage service region
102+
type ManagedObjectStorageRegionZone struct {
103+
Name string `json:"name"`
104+
}
105+
106+
// ManagedObjectStorageUserAccessKey represents Access Key details for a Managed Object Storage service user
107+
type ManagedObjectStorageUserAccessKey struct {
108+
AccessKeyId string `json:"access_key_id"`
109+
CreatedAt time.Time `json:"created_at"`
110+
Enabled bool `json:"enabled"`
111+
LastUsedAt time.Time `json:"last_used_at"`
112+
Name string `json:"name"`
113+
SecretAccessKey *string `json:"secret_access_key,omitempty"`
114+
UpdatedAt time.Time `json:"updated_at"`
115+
}
116+
117+
// ManagedObjectStorageBucketMetrics represents metrics for a Managed Object Storage service bucket
118+
type ManagedObjectStorageBucketMetrics struct {
119+
Name string `json:"name"`
120+
TotalObjects int `json:"total_objects"`
121+
TotalSizeBytes int `json:"total_size_bytes"`
122+
}
123+
124+
// ManagedObjectStorageMetrics represents metrics for a Managed Object Storage service
125+
type ManagedObjectStorageMetrics struct {
126+
TotalObjects int `json:"total_objects"`
127+
TotalSizeBytes int `json:"total_size_bytes"`
128+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package upcloud
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestManagedObjectStorage(t *testing.T) {
8+
t.Parallel()
9+
testJSON(t,
10+
&ManagedObjectStorage{},
11+
&ManagedObjectStorage{
12+
ConfiguredStatus: ManagedObjectStorageConfiguredStatusStarted,
13+
CreatedAt: timeParse("2023-05-07T15:55:24.655776Z"),
14+
Endpoints: []ManagedObjectStorageEndpoint{
15+
{
16+
DomainName: "7mf5k.upbucket.com",
17+
Type: "public",
18+
},
19+
{
20+
DomainName: "7mf5k-private.upbucket.com",
21+
Type: "private",
22+
},
23+
},
24+
Labels: []Label{{
25+
Key: "managedBy",
26+
Value: "upcloud-go-sdk-unit-test",
27+
}},
28+
Networks: []ManagedObjectStorageNetwork{
29+
{
30+
Family: "IPv4",
31+
Name: "example-public-network",
32+
Type: "public",
33+
},
34+
{
35+
Family: "IPv4",
36+
Name: "example-private-network",
37+
Type: "private",
38+
UUID: StringPtr("03aa7245-2ff9-49c8-9f0e-7ca0270d71a4"),
39+
},
40+
},
41+
OperationalState: ManagedObjectStorageOperationalStateRunning,
42+
Region: "europe-1",
43+
UpdatedAt: timeParse("2023-05-07T21:38:15.757405Z"),
44+
Users: []ManagedObjectStorageUser{
45+
{
46+
AccessKeys: []ManagedObjectStorageUserAccessKey{
47+
{
48+
AccessKeyId: "AKIA63F41D01345BB477",
49+
CreatedAt: timeParse("2023-05-07T20:52:19.705405Z"),
50+
Enabled: true,
51+
LastUsedAt: timeParse("2023-05-07T20:52:17Z"),
52+
Name: "example-access-key",
53+
SecretAccessKey: nil,
54+
UpdatedAt: timeParse("2023-05-07T21:06:18.81511Z"),
55+
},
56+
},
57+
CreatedAt: timeParse("2023-05-07T15:55:24.655776Z"),
58+
OperationalState: ManagedObjectStorageUserOperationalStateReady,
59+
UpdatedAt: timeParse("2023-05-07T16:48:14.744079Z"),
60+
Username: "example-user",
61+
},
62+
},
63+
UUID: "1200ecde-db95-4d1c-9133-6508f3232567",
64+
},
65+
`
66+
{
67+
"configured_status": "started",
68+
"created_at": "2023-05-07T15:55:24.655776Z",
69+
"endpoints": [
70+
{
71+
"domain_name": "7mf5k.upbucket.com",
72+
"type": "public"
73+
},
74+
{
75+
"domain_name": "7mf5k-private.upbucket.com",
76+
"type": "private"
77+
}
78+
],
79+
"labels": [
80+
{
81+
"key": "managedBy",
82+
"value": "upcloud-go-sdk-unit-test"
83+
}
84+
],
85+
"networks": [
86+
{
87+
"family": "IPv4",
88+
"name": "example-public-network",
89+
"type": "public"
90+
},
91+
{
92+
"family": "IPv4",
93+
"name": "example-private-network",
94+
"type": "private",
95+
"uuid": "03aa7245-2ff9-49c8-9f0e-7ca0270d71a4"
96+
}
97+
],
98+
"operational_state": "running",
99+
"region": "europe-1",
100+
"updated_at": "2023-05-07T21:38:15.757405Z",
101+
"users": [
102+
{
103+
"access_keys": [
104+
{
105+
"access_key_id": "AKIA63F41D01345BB477",
106+
"created_at": "2023-05-07T20:52:19.705405Z",
107+
"enabled": true,
108+
"last_used_at": "2023-05-07T20:52:17Z",
109+
"name": "example-access-key",
110+
"updated_at": "2023-05-07T21:06:18.81511Z"
111+
}
112+
],
113+
"created_at": "2023-05-07T15:55:24.655776Z",
114+
"operational_state": "ready",
115+
"updated_at": "2023-05-07T16:48:14.744079Z",
116+
"username": "example-user"
117+
}
118+
],
119+
"uuid": "1200ecde-db95-4d1c-9133-6508f3232567"
120+
}
121+
`,
122+
)
123+
}

0 commit comments

Comments
 (0)