Skip to content

Commit 1f31778

Browse files
feat(instance): add support for tags in resources (#1028)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 00a3d08 commit 1f31778

File tree

1 file changed

+63
-11
lines changed

1 file changed

+63
-11
lines changed

api/instance/v1/instance_sdk.go

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,8 @@ type Image struct {
985985

986986
Project string `json:"project"`
987987

988+
Tags []string `json:"tags"`
989+
988990
Zone scw.Zone `json:"zone"`
989991
}
990992

@@ -1102,7 +1104,9 @@ type PlacementGroup struct {
11021104
Organization string `json:"organization"`
11031105
// Project: the placement group project ID
11041106
Project string `json:"project"`
1105-
// PolicyMode: select the failling mode when the placement cannot be respected, either optional or enforced
1107+
// Tags: the placement group tags
1108+
Tags []string `json:"tags"`
1109+
// PolicyMode: select the failling mode when the placement cannot be respected, either optional or enforced
11061110
//
11071111
// Default value: optional
11081112
PolicyMode PlacementGroupPolicyMode `json:"policy_mode"`
@@ -1162,6 +1166,8 @@ type SecurityGroup struct {
11621166
Organization string `json:"organization"`
11631167
// Project: the security group project ID
11641168
Project string `json:"project"`
1169+
// Tags: the security group tags
1170+
Tags []string `json:"tags"`
11651171
// Deprecated: OrganizationDefault: true if it is your default security group for this organization ID
11661172
OrganizationDefault bool `json:"organization_default"`
11671173
// ProjectDefault: true if it is your default security group for this project ID
@@ -1415,6 +1421,8 @@ type Snapshot struct {
14151421
Organization string `json:"organization"`
14161422
// Project: the snapshot project ID
14171423
Project string `json:"project"`
1424+
// Tags: the snapshot tags
1425+
Tags []string `json:"tags"`
14181426
// VolumeType: the snapshot volume type
14191427
//
14201428
// Default value: l_ssd
@@ -1509,6 +1517,8 @@ type Volume struct {
15091517
Organization string `json:"organization"`
15101518
// Project: the volume project ID
15111519
Project string `json:"project"`
1520+
// Tags: the volume tags
1521+
Tags []string `json:"tags"`
15121522
// Server: the server attached to the volume
15131523
Server *ServerSummary `json:"server"`
15141524
// State: the volume state
@@ -1567,12 +1577,6 @@ type VolumeServerTemplate struct {
15671577
//
15681578
// Default value: l_ssd
15691579
VolumeType VolumeVolumeType `json:"volume_type,omitempty"`
1570-
// Deprecated: Organization: organization ID of the volume
1571-
// Precisely one of Organization, Project must be set.
1572-
Organization *string `json:"organization,omitempty"`
1573-
// Project: project ID of the volume
1574-
// Precisely one of Organization, Project must be set.
1575-
Project *string `json:"project,omitempty"`
15761580
}
15771581

15781582
type VolumeSummary struct {
@@ -1820,7 +1824,7 @@ type ListServersRequest struct {
18201824
//
18211825
// Default value: running
18221826
State *ServerState `json:"-"`
1823-
// Tags: list servers with these exact tags
1827+
// Tags: list servers with these exact tags (to filter with several tags, use commas to separate them)
18241828
Tags []string `json:"-"`
18251829
// PrivateNetwork: list servers in this Private Network
18261830
PrivateNetwork *string `json:"-"`
@@ -2054,7 +2058,7 @@ type setServerRequest struct {
20542058
// AllowedActions: provide as list of allowed actions on the server
20552059
AllowedActions []ServerAction `json:"allowed_actions"`
20562060
// Tags: the server associated tags
2057-
Tags []string `json:"tags"`
2061+
Tags *[]string `json:"tags"`
20582062
// CommercialType: the server commercial type (eg. GP1-M)
20592063
CommercialType string `json:"commercial_type"`
20602064
// CreationDate: the server creation date
@@ -2415,6 +2419,8 @@ type ListImagesRequest struct {
24152419
Arch *string `json:"-"`
24162420

24172421
Project *string `json:"-"`
2422+
2423+
Tags *string `json:"-"`
24182424
}
24192425

24202426
// ListImages: list instance images
@@ -2441,6 +2447,7 @@ func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*Li
24412447
parameter.AddToQuery(query, "public", req.Public)
24422448
parameter.AddToQuery(query, "arch", req.Arch)
24432449
parameter.AddToQuery(query, "project", req.Project)
2450+
parameter.AddToQuery(query, "tags", req.Tags)
24442451

24452452
if fmt.Sprint(req.Zone) == "" {
24462453
return nil, errors.New("field Zone cannot be empty in request")
@@ -2522,6 +2529,8 @@ type CreateImageRequest struct {
25222529
// Project: project ID of the image
25232530
// Precisely one of Organization, Project must be set.
25242531
Project *string `json:"project,omitempty"`
2532+
// Tags: the tags of the image
2533+
Tags []string `json:"tags,omitempty"`
25252534
// Public: true to create a public image
25262535
Public bool `json:"public,omitempty"`
25272536
}
@@ -2605,6 +2614,8 @@ type SetImageRequest struct {
26052614
State ImageState `json:"state"`
26062615

26072616
Project string `json:"project"`
2617+
2618+
Tags *[]string `json:"tags"`
26082619
}
26092620

26102621
// setImage: update image
@@ -2706,6 +2717,8 @@ type ListSnapshotsRequest struct {
27062717
Name *string `json:"-"`
27072718

27082719
Project *string `json:"-"`
2720+
2721+
Tags *string `json:"-"`
27092722
}
27102723

27112724
// ListSnapshots: list snapshots
@@ -2728,6 +2741,7 @@ func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption
27282741
parameter.AddToQuery(query, "page", req.Page)
27292742
parameter.AddToQuery(query, "name", req.Name)
27302743
parameter.AddToQuery(query, "project", req.Project)
2744+
parameter.AddToQuery(query, "tags", req.Tags)
27312745

27322746
if fmt.Sprint(req.Zone) == "" {
27332747
return nil, errors.New("field Zone cannot be empty in request")
@@ -2755,6 +2769,8 @@ type CreateSnapshotRequest struct {
27552769
Name string `json:"name,omitempty"`
27562770
// VolumeID: UUID of the volume
27572771
VolumeID string `json:"volume_id,omitempty"`
2772+
// Tags: the tags of the snapshot
2773+
Tags []string `json:"tags,omitempty"`
27582774
// Deprecated: Organization: organization ID of the snapshot
27592775
// Precisely one of Organization, Project must be set.
27602776
Organization *string `json:"organization,omitempty"`
@@ -2878,6 +2894,8 @@ type setSnapshotRequest struct {
28782894
ModificationDate *time.Time `json:"modification_date"`
28792895

28802896
Project string `json:"project"`
2897+
2898+
Tags *[]string `json:"tags"`
28812899
}
28822900

28832901
// setSnapshot: update snapshot
@@ -2983,6 +3001,8 @@ type ListVolumesRequest struct {
29833001
Organization *string `json:"-"`
29843002
// Project: filter volume by project ID
29853003
Project *string `json:"-"`
3004+
// Tags: filter volumes with these exact tags (to filter with several tags, use commas to separate them)
3005+
Tags []string `json:"-"`
29863006
// Name: filter volume by name (for eg. "vol" will return "myvolume" but not "data")
29873007
Name *string `json:"-"`
29883008
}
@@ -3007,6 +3027,9 @@ func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (*
30073027
parameter.AddToQuery(query, "page", req.Page)
30083028
parameter.AddToQuery(query, "organization", req.Organization)
30093029
parameter.AddToQuery(query, "project", req.Project)
3030+
if len(req.Tags) != 0 {
3031+
parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ","))
3032+
}
30103033
parameter.AddToQuery(query, "name", req.Name)
30113034

30123035
if fmt.Sprint(req.Zone) == "" {
@@ -3039,6 +3062,8 @@ type CreateVolumeRequest struct {
30393062
// Project: the volume project ID
30403063
// Precisely one of Organization, Project must be set.
30413064
Project *string `json:"project,omitempty"`
3065+
// Tags: the volume tags
3066+
Tags []string `json:"tags,omitempty"`
30423067
// VolumeType: the volume type
30433068
//
30443069
// Default value: l_ssd
@@ -3147,6 +3172,8 @@ type UpdateVolumeRequest struct {
31473172
VolumeID string `json:"-"`
31483173
// Name: the volume name
31493174
Name *string `json:"name,omitempty"`
3175+
// Tags: the tags of the volume
3176+
Tags *[]string `json:"tags,omitempty"`
31503177
// Size: the volume disk size
31513178
Size *scw.Size `json:"size,omitempty"`
31523179
}
@@ -3236,6 +3263,8 @@ type ListSecurityGroupsRequest struct {
32363263
Organization *string `json:"-"`
32373264
// Project: the security group project ID
32383265
Project *string `json:"-"`
3266+
// Tags: list security groups with these exact tags (to filter with several tags, use commas to separate them)
3267+
Tags []string `json:"-"`
32393268
// PerPage: a positive integer lower or equal to 100 to select the number of items to return
32403269
//
32413270
// Default value: 50
@@ -3264,6 +3293,9 @@ func (s *API) ListSecurityGroups(req *ListSecurityGroupsRequest, opts ...scw.Req
32643293
parameter.AddToQuery(query, "name", req.Name)
32653294
parameter.AddToQuery(query, "organization", req.Organization)
32663295
parameter.AddToQuery(query, "project", req.Project)
3296+
if len(req.Tags) != 0 {
3297+
parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ","))
3298+
}
32673299
parameter.AddToQuery(query, "per_page", req.PerPage)
32683300
parameter.AddToQuery(query, "page", req.Page)
32693301

@@ -3299,6 +3331,8 @@ type CreateSecurityGroupRequest struct {
32993331
// Project: project ID the security group belong to
33003332
// Precisely one of Organization, Project must be set.
33013333
Project *string `json:"project,omitempty"`
3334+
// Tags: the tags of the security group
3335+
Tags []string `json:"tags,omitempty"`
33023336
// Deprecated: OrganizationDefault: whether this security group becomes the default security group for new instances
33033337
//
33043338
// Default value: false
@@ -3454,6 +3488,8 @@ type setSecurityGroupRequest struct {
34543488
ID string `json:"-"`
34553489
// Name: the name of the security group
34563490
Name string `json:"name"`
3491+
// Tags: the tags of the security group
3492+
Tags *[]string `json:"tags"`
34573493
// CreationDate: the creation date of the security group (will be ignored)
34583494
CreationDate *time.Time `json:"creation_date"`
34593495
// ModificationDate: the modification date of the security group (will be ignored)
@@ -3827,6 +3863,8 @@ type ListPlacementGroupsRequest struct {
38273863
Organization *string `json:"-"`
38283864
// Project: list only placement groups of this project ID
38293865
Project *string `json:"-"`
3866+
// Tags: list placement groups with these exact tags (to filter with several tags, use commas to separate them)
3867+
Tags []string `json:"-"`
38303868
// Name: filter placement groups by name (for eg. "cluster1" will return "cluster100" and "cluster1" but not "foo")
38313869
Name *string `json:"-"`
38323870
}
@@ -3852,6 +3890,9 @@ func (s *API) ListPlacementGroups(req *ListPlacementGroupsRequest, opts ...scw.R
38523890
parameter.AddToQuery(query, "page", req.Page)
38533891
parameter.AddToQuery(query, "organization", req.Organization)
38543892
parameter.AddToQuery(query, "project", req.Project)
3893+
if len(req.Tags) != 0 {
3894+
parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ","))
3895+
}
38553896
parameter.AddToQuery(query, "name", req.Name)
38563897

38573898
if fmt.Sprint(req.Zone) == "" {
@@ -3884,6 +3925,8 @@ type CreatePlacementGroupRequest struct {
38843925
// Project: project ID of the placement group
38853926
// Precisely one of Organization, Project must be set.
38863927
Project *string `json:"project,omitempty"`
3928+
// Tags: the tags of the placement group
3929+
Tags []string `json:"tags,omitempty"`
38873930
// PolicyMode: the operating mode of the placement group
38883931
//
38893932
// Default value: optional
@@ -4001,6 +4044,8 @@ type SetPlacementGroupRequest struct {
40014044
PolicyType PlacementGroupPolicyType `json:"policy_type"`
40024045

40034046
Project string `json:"project"`
4047+
4048+
Tags *[]string `json:"tags"`
40044049
}
40054050

40064051
// SetPlacementGroup: set placement group
@@ -4058,6 +4103,8 @@ type UpdatePlacementGroupRequest struct {
40584103
PlacementGroupID string `json:"-"`
40594104
// Name: name of the placement group
40604105
Name *string `json:"name,omitempty"`
4106+
// Tags: the tags of the placement group
4107+
Tags *[]string `json:"tags,omitempty"`
40614108
// PolicyMode: the operating mode of the placement group
40624109
//
40634110
// Default value: optional
@@ -4293,6 +4340,8 @@ type ListIPsRequest struct {
42934340
Page *int32 `json:"-"`
42944341
// Project: the project ID the IPs are reserved in
42954342
Project *string `json:"-"`
4343+
// Tags: filter IPs with these exact tags (to filter with several tags, use commas to separate them)
4344+
Tags []string `json:"-"`
42964345
}
42974346

42984347
// ListIPs: list all flexible IPs
@@ -4315,6 +4364,9 @@ func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsR
43154364
parameter.AddToQuery(query, "per_page", req.PerPage)
43164365
parameter.AddToQuery(query, "page", req.Page)
43174366
parameter.AddToQuery(query, "project", req.Project)
4367+
if len(req.Tags) != 0 {
4368+
parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ","))
4369+
}
43184370

43194371
if fmt.Sprint(req.Zone) == "" {
43204372
return nil, errors.New("field Zone cannot be empty in request")
@@ -4344,10 +4396,10 @@ type CreateIPRequest struct {
43444396
// Project: the project ID the IP is reserved in
43454397
// Precisely one of Organization, Project must be set.
43464398
Project *string `json:"project,omitempty"`
4399+
// Tags: the tags of the IP
4400+
Tags []string `json:"tags,omitempty"`
43474401
// Server: UUID of the server you want to attach the IP to
43484402
Server *string `json:"server,omitempty"`
4349-
// Tags: an array of keywords you want to tag this IP with
4350-
Tags []string `json:"tags,omitempty"`
43514403
}
43524404

43534405
// CreateIP: reserve a flexible IP

0 commit comments

Comments
 (0)