@@ -17,6 +17,7 @@ type VtctldService interface {
1717 ListKeyspaces (context.Context , * VtctldListKeyspacesRequest ) (json.RawMessage , error )
1818 GetRoutingRules (context.Context , * VtctldGetRoutingRulesRequest ) (json.RawMessage , error )
1919 GetShard (context.Context , * VtctldGetShardRequest ) (json.RawMessage , error )
20+ SetShardTabletControl (context.Context , * VtctldSetShardTabletControlRequest ) (json.RawMessage , error )
2021 ListTablets (context.Context , * ListBranchTabletsRequest ) ([]* TabletGroup , error )
2122 StartWorkflow (context.Context , * VtctldStartWorkflowRequest ) (json.RawMessage , error )
2223 StopWorkflow (context.Context , * VtctldStopWorkflowRequest ) (json.RawMessage , error )
@@ -60,6 +61,22 @@ type VtctldGetShardRequest struct {
6061 Shard string `json:"-"`
6162}
6263
64+ // VtctldSetShardTabletControlRequest is a request for updating shard tablet
65+ // controls via vtctld.
66+ type VtctldSetShardTabletControlRequest struct {
67+ Organization string `json:"-"`
68+ Database string `json:"-"`
69+ Branch string `json:"-"`
70+
71+ Keyspace string `json:"keyspace"`
72+ Shard string `json:"shard"`
73+ TabletType string `json:"tablet_type"`
74+ Cells []string `json:"cells,omitempty"`
75+ DeniedTables []string `json:"denied_tables,omitempty"`
76+ Remove * bool `json:"remove,omitempty"`
77+ DisableQueryService * bool `json:"disable_query_service,omitempty"`
78+ }
79+
6380// VtctldStartWorkflowRequest is a request for starting a workflow.
6481type VtctldStartWorkflowRequest struct {
6582 Organization string `json:"-"`
@@ -166,6 +183,10 @@ func vtctldShardAPIPath(org, db, branch string) string {
166183 return path .Join (databaseBranchAPIPath (org , db , branch ), "vtctld" , "shard" )
167184}
168185
186+ func vtctldShardTabletControlAPIPath (org , db , branch string ) string {
187+ return path .Join (databaseBranchAPIPath (org , db , branch ), "vtctld" , "shard" , "tablet-control" )
188+ }
189+
169190func (s * vtctldService ) ListWorkflows (ctx context.Context , req * VtctldListWorkflowsRequest ) (json.RawMessage , error ) {
170191 p := vtctldWorkflowsAPIPath (req .Organization , req .Database , req .Branch )
171192 v := url.Values {}
@@ -283,6 +304,20 @@ func (s *vtctldService) GetThrottlerStatus(ctx context.Context, req *VtctldGetTh
283304 return resp .Data , nil
284305}
285306
307+ // SetShardTabletControl updates tablet controls on a shard via vtctld.
308+ func (s * vtctldService ) SetShardTabletControl (ctx context.Context , req * VtctldSetShardTabletControlRequest ) (json.RawMessage , error ) {
309+ p := vtctldShardTabletControlAPIPath (req .Organization , req .Database , req .Branch )
310+ httpReq , err := s .client .newRequest (http .MethodPut , p , req )
311+ if err != nil {
312+ return nil , fmt .Errorf ("error creating http request: %w" , err )
313+ }
314+ resp := & vtctldDataResponse {}
315+ if err := s .client .do (ctx , httpReq , resp ); err != nil {
316+ return nil , err
317+ }
318+ return resp .Data , nil
319+ }
320+
286321// CheckThrottler issues a throttler check against a single tablet.
287322func (s * vtctldService ) CheckThrottler (ctx context.Context , req * VtctldCheckThrottlerRequest ) (json.RawMessage , error ) {
288323 p := path .Join (vtctldThrottlerAPIPath (req .Organization , req .Database , req .Branch ), "check" )
0 commit comments