Skip to content

Commit b33999b

Browse files
authored
feat(objsto): add name property (#282)
1 parent 91f67cc commit b33999b

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/)
77

88
### Added
99
- Managed Database sub-properties support. E.g., PostgreSQL property `timescaledb` is of type `object` and has `max_background_workers` sub-property.
10+
- Managed Object Storage: add `name` property
1011

1112
### Fixed
1213
- Managed Object Storage: omit empty labels slice when creating managed object storage instance

upcloud/managed_object_storage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type ManagedObjectStorage struct {
6060
CreatedAt time.Time `json:"created_at"`
6161
Endpoints []ManagedObjectStorageEndpoint `json:"endpoints"`
6262
Labels []Label `json:"labels"`
63+
Name string `json:"name,omitempty"`
6364
Networks []ManagedObjectStorageNetwork `json:"networks"`
6465
OperationalState ManagedObjectStorageOperationalState `json:"operational_state"`
6566
Region string `json:"region"`

upcloud/managed_object_storage_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func TestManagedObjectStorage(t *testing.T) {
2525
Key: "managedBy",
2626
Value: "upcloud-go-sdk-unit-test",
2727
}},
28+
Name: "go-sdk-test-objsto",
2829
Networks: []ManagedObjectStorageNetwork{
2930
{
3031
Family: "IPv4",
@@ -82,6 +83,7 @@ func TestManagedObjectStorage(t *testing.T) {
8283
"value": "upcloud-go-sdk-unit-test"
8384
}
8485
],
86+
"name": "go-sdk-test-objsto",
8587
"networks": [
8688
{
8789
"family": "IPv4",

upcloud/request/managed_object_storage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func (r *GetManagedObjectStorageRegionRequest) RequestURL() string {
3838
type CreateManagedObjectStorageRequest struct {
3939
ConfiguredStatus upcloud.ManagedObjectStorageConfiguredStatus `json:"configured_status"`
4040
Labels []upcloud.Label `json:"labels,omitempty"`
41+
Name string `json:"name,omitempty"`
4142
Networks []upcloud.ManagedObjectStorageNetwork `json:"networks"`
4243
Region string `json:"region"`
4344
Users []ManagedObjectStorageUser `json:"users"`
@@ -75,6 +76,7 @@ func (r *GetManagedObjectStorageRequest) RequestURL() string {
7576
type ReplaceManagedObjectStorageRequest struct {
7677
ConfiguredStatus upcloud.ManagedObjectStorageConfiguredStatus `json:"configured_status"`
7778
Labels []upcloud.Label `json:"labels,omitempty"`
79+
Name string `json:"name,omitempty"`
7880
Networks []upcloud.ManagedObjectStorageNetwork `json:"networks"`
7981
Users []ManagedObjectStorageUser `json:"users"`
8082
UUID string `json:"-"`
@@ -88,6 +90,7 @@ func (r *ReplaceManagedObjectStorageRequest) RequestURL() string {
8890
type ModifyManagedObjectStorageRequest struct {
8991
ConfiguredStatus *upcloud.ManagedObjectStorageConfiguredStatus `json:"configured_status,omitempty"`
9092
Labels *[]upcloud.Label `json:"labels,omitempty"`
93+
Name *string `json:"name,omitempty"`
9194
Networks *[]upcloud.ManagedObjectStorageNetwork `json:"networks,omitempty"`
9295
Users *[]ManagedObjectStorageUser `json:"users,omitempty"`
9396
UUID string `json:"-"`

upcloud/request/managed_object_storage_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ func TestCreateManagedObjectStorageRequest_MarshalJSON(t *testing.T) {
4040
}`
4141
assert.JSONEq(t, expected, string(d))
4242
})
43+
44+
t.Run("TestWithName", func(t *testing.T) {
45+
req := CreateManagedObjectStorageRequest{
46+
Name: "test-objsto-name",
47+
Region: "europe-1",
48+
}
49+
d, err := json.Marshal(&req)
50+
assert.NoError(t, err)
51+
52+
const expected = `{
53+
"configured_status":"",
54+
"name":"test-objsto-name",
55+
"networks":null,
56+
"region":"europe-1",
57+
"users":null
58+
}`
59+
assert.JSONEq(t, expected, string(d))
60+
})
4361
}
4462

4563
func TestGetManagedObjectStoragesRequest_RequestURL(t *testing.T) {

0 commit comments

Comments
 (0)