@@ -134,6 +134,9 @@ type Workspaces interface {
134
134
135
135
// ListTagBindings lists all tag bindings associated with the workspace.
136
136
ListTagBindings (ctx context.Context , workspaceID string ) ([]* TagBinding , error )
137
+
138
+ // AddTagBindings adds or modifies the value of existing tag binding keys for a workspace.
139
+ AddTagBindings (ctx context.Context , workspaceID string , options WorkspaceAddTagBindingsOptions ) ([]* TagBinding , error )
137
140
}
138
141
139
142
// workspaces implements Workspaces.
@@ -147,6 +150,12 @@ type WorkspaceList struct {
147
150
Items []* Workspace
148
151
}
149
152
153
+ // WorkspaceAddTagBindingsOptions represents the options for adding tag bindings
154
+ // to a workspace.
155
+ type WorkspaceAddTagBindingsOptions struct {
156
+ TagBindings []* TagBinding
157
+ }
158
+
150
159
// LockedByChoice is a choice type struct that represents the possible values
151
160
// within a polymorphic relation. If a value is available, exactly one field
152
161
// will be non-nil.
@@ -760,6 +769,31 @@ func (s *workspaces) ListTagBindings(ctx context.Context, workspaceID string) ([
760
769
return list .Items , nil
761
770
}
762
771
772
+ // AddTagBindings adds or modifies the value of existing tag binding keys for a workspace.
773
+ func (s * workspaces ) AddTagBindings (ctx context.Context , workspaceID string , options WorkspaceAddTagBindingsOptions ) ([]* TagBinding , error ) {
774
+ if ! validStringID (& workspaceID ) {
775
+ return nil , ErrInvalidWorkspaceID
776
+ }
777
+
778
+ if err := options .valid (); err != nil {
779
+ return nil , err
780
+ }
781
+
782
+ u := fmt .Sprintf ("workspaces/%s/tag-bindings" , url .PathEscape (workspaceID ))
783
+ req , err := s .client .NewRequest ("PATCH" , u , options .TagBindings )
784
+ if err != nil {
785
+ return nil , err
786
+ }
787
+
788
+ var response = struct {
789
+ * Pagination
790
+ Items []* TagBinding
791
+ }{}
792
+ err = req .Do (ctx , & response )
793
+
794
+ return response .Items , err
795
+ }
796
+
763
797
// Create is used to create a new workspace.
764
798
func (s * workspaces ) Create (ctx context.Context , organization string , options WorkspaceCreateOptions ) (* Workspace , error ) {
765
799
if ! validStringID (& organization ) {
@@ -1465,6 +1499,14 @@ func (s *workspaces) DeleteDataRetentionPolicy(ctx context.Context, workspaceID
1465
1499
return req .Do (ctx , nil )
1466
1500
}
1467
1501
1502
+ func (o WorkspaceAddTagBindingsOptions ) valid () error {
1503
+ if len (o .TagBindings ) == 0 {
1504
+ return ErrRequiredTagBindings
1505
+ }
1506
+
1507
+ return nil
1508
+ }
1509
+
1468
1510
func (o WorkspaceCreateOptions ) valid () error {
1469
1511
if ! validString (o .Name ) {
1470
1512
return ErrRequiredName
0 commit comments