@@ -16,7 +16,9 @@ type Keyspace struct {
16
16
Sharded bool `json:"sharded"`
17
17
Replicas uint64 `json:"replicas"`
18
18
ExtraReplicas uint64 `json:"extra_replicas"`
19
+ ResizePending bool `json:"resize_pending"`
19
20
Resizing bool `json:"resizing"`
21
+ Ready bool `json:"ready"`
20
22
ClusterSize ClusterSize `json:"cluster_rate_name"`
21
23
CreatedAt time.Time `json:"created_at"`
22
24
UpdatedAt time.Time `json:"updated_at"`
@@ -34,6 +36,16 @@ type ListBranchKeyspacesRequest struct {
34
36
Branch string `json:"-"`
35
37
}
36
38
39
+ type CreateBranchKeyspaceRequest struct {
40
+ Organization string `json:"-"`
41
+ Database string `json:"-"`
42
+ Branch string `json:"-"`
43
+ Name string `json:"name"`
44
+ ClusterSize ClusterSize `json:"cluster_size"`
45
+ ExtraReplicas int `json:"replicas"`
46
+ Shards int `json:"shards"`
47
+ }
48
+
37
49
type GetBranchKeyspaceRequest struct {
38
50
Organization string `json:"-"`
39
51
Database string `json:"-"`
@@ -62,6 +74,7 @@ type branchKeyspacesResponse struct {
62
74
63
75
// BranchKeyspaceService is an interface for interacting with the keyspace endpoints of the PlanetScale API
64
76
type BranchKeyspacesService interface {
77
+ Create (context.Context , * CreateBranchKeyspaceRequest ) (* Keyspace , error )
65
78
List (context.Context , * ListBranchKeyspacesRequest ) ([]* Keyspace , error )
66
79
Get (context.Context , * GetBranchKeyspaceRequest ) (* Keyspace , error )
67
80
VSchema (context.Context , * GetKeyspaceVSchemaRequest ) (* VSchema , error )
@@ -108,6 +121,21 @@ func (s *branchKeyspacesService) Get(ctx context.Context, getReq *GetBranchKeysp
108
121
return keyspace , nil
109
122
}
110
123
124
+ // Create creates a keyspace for a branch
125
+ func (s * branchKeyspacesService ) Create (ctx context.Context , createReq * CreateBranchKeyspaceRequest ) (* Keyspace , error ) {
126
+ req , err := s .client .newRequest (http .MethodPost , databaseBranchKeyspacesAPIPath (createReq .Organization , createReq .Database , createReq .Branch ), createReq )
127
+ if err != nil {
128
+ return nil , errors .Wrap (err , "error creating http request" )
129
+ }
130
+
131
+ keyspace := & Keyspace {}
132
+ if err := s .client .do (ctx , req , keyspace ); err != nil {
133
+ return nil , err
134
+ }
135
+
136
+ return keyspace , nil
137
+ }
138
+
111
139
// VSchema returns the VSchema for a keyspace in a branch
112
140
func (s * branchKeyspacesService ) VSchema (ctx context.Context , getReq * GetKeyspaceVSchemaRequest ) (* VSchema , error ) {
113
141
path := fmt .Sprintf ("%s/vschema" , databaseBranchKeyspaceAPIPath (getReq .Organization , getReq .Database , getReq .Branch , getReq .Keyspace ))
0 commit comments