Skip to content

Commit f8c3506

Browse files
feat(instance): add endpoints UpdateImage, UpdateSnapshot, UpdateSecurityGroup and UpdateSecurityGroupRules (#1942)
Co-authored-by: Jules Casteran <[email protected]>
1 parent c5bd7ba commit f8c3506

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

api/instance/v1/instance_sdk.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ var (
4242
type Arch string
4343

4444
const (
45-
ArchX86_64 = Arch("x86_64")
46-
ArchArm = Arch("arm")
47-
ArchArm64 = Arch("arm64")
45+
ArchUnknownArch = Arch("unknown_arch")
46+
ArchX86_64 = Arch("x86_64")
47+
ArchArm = Arch("arm")
48+
ArchArm64 = Arch("arm64")
4849
)
4950

5051
func (enum Arch) String() string {
5152
if enum == "" {
5253
// return default value if empty
53-
return "x86_64"
54+
return "unknown_arch"
5455
}
5556
return string(enum)
5657
}
@@ -481,7 +482,6 @@ func (enum *SecurityGroupRuleProtocol) UnmarshalJSON(data []byte) error {
481482
type SecurityGroupState string
482483

483484
const (
484-
SecurityGroupStateUnknownState = SecurityGroupState("unknown_state")
485485
SecurityGroupStateAvailable = SecurityGroupState("available")
486486
SecurityGroupStateSyncing = SecurityGroupState("syncing")
487487
SecurityGroupStateSyncingError = SecurityGroupState("syncing_error")
@@ -490,7 +490,7 @@ const (
490490
func (enum SecurityGroupState) String() string {
491491
if enum == "" {
492492
// return default value if empty
493-
return "unknown_state"
493+
return "available"
494494
}
495495
return string(enum)
496496
}
@@ -979,7 +979,7 @@ type Bootscript struct {
979979
Title string `json:"title"`
980980

981981
// Arch: bootscript architecture.
982-
// Default value: x86_64
982+
// Default value: unknown_arch
983983
Arch Arch `json:"arch"`
984984

985985
// Zone: zone in which the bootscript is located.
@@ -1066,7 +1066,7 @@ type Image struct {
10661066

10671067
Name string `json:"name"`
10681068

1069-
// Arch: default value: x86_64
1069+
// Arch: default value: unknown_arch
10701070
Arch Arch `json:"arch"`
10711071

10721072
CreationDate *time.Time `json:"creation_date"`
@@ -1392,7 +1392,7 @@ type Server struct {
13921392
StateDetail string `json:"state_detail"`
13931393

13941394
// Arch: instance architecture.
1395-
// Default value: x86_64
1395+
// Default value: unknown_arch
13961396
Arch Arch `json:"arch"`
13971397

13981398
// PlacementGroup: instance placement group.
@@ -1507,7 +1507,7 @@ type SecurityGroup struct {
15071507
Stateful bool `json:"stateful"`
15081508

15091509
// State: security group state.
1510-
// Default value: unknown_state
1510+
// Default value: available
15111511
State SecurityGroupState `json:"state"`
15121512

15131513
// Zone: zone in which the security group is located.
@@ -1720,7 +1720,7 @@ type ServerType struct {
17201720
RAM uint64 `json:"ram"`
17211721

17221722
// Arch: CPU architecture.
1723-
// Default value: x86_64
1723+
// Default value: unknown_arch
17241724
Arch Arch `json:"arch"`
17251725

17261726
// Baremetal: true if it is a baremetal Instance.
@@ -1887,7 +1887,7 @@ type CreateImageRequest struct {
18871887
RootVolume string `json:"root_volume,omitempty"`
18881888

18891889
// Arch: architecture of the image.
1890-
// Default value: x86_64
1890+
// Default value: unknown_arch
18911891
Arch Arch `json:"arch,omitempty"`
18921892

18931893
// Deprecated: DefaultBootscript: default bootscript of the image.
@@ -3267,7 +3267,7 @@ type SetImageRequest struct {
32673267

32683268
Name string `json:"name"`
32693269

3270-
// Arch: default value: x86_64
3270+
// Arch: default value: unknown_arch
32713271
Arch Arch `json:"arch"`
32723272

32733273
CreationDate *time.Time `json:"creation_date,omitempty"`
@@ -3395,7 +3395,7 @@ type UpdateImageRequest struct {
33953395
Name *string `json:"name,omitempty"`
33963396

33973397
// Arch: architecture of the image.
3398-
// Default value: x86_64
3398+
// Default value: unknown_arch
33993399
Arch Arch `json:"arch,omitempty"`
34003400

34013401
// ExtraVolumes: additional snapshots of the image, with extra_volumeKey being the position of the snapshot in the image.
@@ -3493,7 +3493,7 @@ type UpdateSecurityGroupRequest struct {
34933493

34943494
// InboundDefaultPolicy: default inbound policy.
34953495
// Default value: unknown_policy
3496-
InboundDefaultPolicy *SecurityGroupPolicy `json:"inbound_default_policy,omitempty"`
3496+
InboundDefaultPolicy SecurityGroupPolicy `json:"inbound_default_policy,omitempty"`
34973497

34983498
// Tags: tags of the security group.
34993499
Tags *[]string `json:"tags,omitempty"`
@@ -3506,7 +3506,7 @@ type UpdateSecurityGroupRequest struct {
35063506

35073507
// OutboundDefaultPolicy: default outbound policy.
35083508
// Default value: unknown_policy
3509-
OutboundDefaultPolicy *SecurityGroupPolicy `json:"outbound_default_policy,omitempty"`
3509+
OutboundDefaultPolicy SecurityGroupPolicy `json:"outbound_default_policy,omitempty"`
35103510

35113511
// Stateful: true to set the security group as stateful.
35123512
Stateful *bool `json:"stateful,omitempty"`
@@ -3543,10 +3543,10 @@ type UpdateSecurityGroupRuleRequest struct {
35433543
// IPRange: range of IP addresses these rules apply to.
35443544
IPRange *scw.IPNet `json:"ip_range,omitempty"`
35453545

3546-
// DestPortFrom: beginning of the range of ports this rule applies to (inclusive).
3546+
// DestPortFrom: beginning of the range of ports this rule applies to (inclusive). If 0 is provided, unset the parameter.
35473547
DestPortFrom *uint32 `json:"dest_port_from,omitempty"`
35483548

3549-
// DestPortTo: end of the range of ports this rule applies to (inclusive).
3549+
// DestPortTo: end of the range of ports this rule applies to (inclusive). If 0 is provided, unset the parameter.
35503550
DestPortTo *uint32 `json:"dest_port_to,omitempty"`
35513551

35523552
// Position: position of this rule in the security group rules list.
@@ -3843,7 +3843,7 @@ type setServerRequest struct {
38433843
StateDetail string `json:"state_detail"`
38443844

38453845
// Arch: instance architecture (refers to the CPU architecture used for the Instance, e.g. x86_64, arm64).
3846-
// Default value: x86_64
3846+
// Default value: unknown_arch
38473847
Arch Arch `json:"arch"`
38483848

38493849
// PlacementGroup: instance placement group.

api/instance/v1/security_group_utils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func TestAPI_UpdateSecurityGroup(t *testing.T) {
3636
Name: scw.StringPtr("new_name"),
3737
Description: scw.StringPtr("new_description"),
3838
Stateful: scw.BoolPtr(false),
39-
InboundDefaultPolicy: &drop,
40-
OutboundDefaultPolicy: &accept,
39+
InboundDefaultPolicy: drop,
40+
OutboundDefaultPolicy: accept,
4141
// Keep false here, switch it to true is too dangerous for the one who update the test cassette.
4242
ProjectDefault: scw.BoolPtr(false),
4343
Tags: scw.StringsPtr([]string{"foo", "bar"}),

0 commit comments

Comments
 (0)