@@ -5,21 +5,21 @@ import (
55 "net/http"
66 "net/url"
77 "strconv"
8- "time"
98
109 "github.com/tursodatabase/turso-cli/internal/flags"
1110)
1211
1312type DatabasesV3Client client
1413
14+ // CreateDatabaseV3Body mirrors the legacy create request (turso.CreateDBParams):
15+ // forks are expressed through Seed just like v1/v2. The single v3-specific
16+ // addition is GroupID, which carries the group UUID instead of the group name.
1517type CreateDatabaseV3Body struct {
1618 Name string `json:"name"`
1719 GroupID string `json:"group_id,omitempty"`
18- DatabaseType string `json:"database_type,omitempty"`
19- CreationMode string `json:"creation_mode,omitempty"`
20- ParentDBName string `json:"parent_db_name,omitempty"`
21- Timestamp * time.Time `json:"parent_db_timestamp,omitempty"`
20+ Seed * DBSeed `json:"seed,omitempty"`
2221 RemoteEncryption * RemoteEncryption `json:"remote_encryption,omitempty"`
22+ UseTursoDB bool `json:"use_tursodb,omitempty"`
2323}
2424
2525func (d * DatabasesV3Client ) url (orgID , suffix string ) string {
@@ -63,14 +63,18 @@ func (d *DatabasesV3Client) List(orgID string, options DatabaseV3ListOptions) ([
6363 }
6464
6565 type response struct {
66- Databases []Database `json:"databases"`
67- NextCursor string `json:"next_cursor "`
66+ Databases []Database `json:"databases"`
67+ Pagination * Pagination `json:"pagination,omitempty "`
6868 }
6969 resp , err := unmarshal [response ](r )
7070 if err != nil {
7171 return nil , "" , err
7272 }
73- return resp .Databases , resp .NextCursor , nil
73+ next := ""
74+ if resp .Pagination != nil && resp .Pagination .Next != nil {
75+ next = * resp .Pagination .Next
76+ }
77+ return resp .Databases , next , nil
7478}
7579
7680func (d * DatabasesV3Client ) Get (orgID , dbID string ) (Database , error ) {
@@ -105,14 +109,31 @@ func (d *DatabasesV3Client) GetConfig(orgID, dbID string) (DatabaseConfig, error
105109 return DatabaseConfig {}, fmt .Errorf ("failed to get database: %w" , parseResponseError (r ))
106110 }
107111
112+ // v3 has no dedicated /configuration endpoint: the database response
113+ // carries delete protection directly and the allow rules nested under
114+ // allow_rules_config, so we project them onto DatabaseConfig here.
108115 type response struct {
109- Database DatabaseConfig `json:"database"`
116+ Database struct {
117+ DeleteProtection bool `json:"delete_protection"`
118+ AllowRulesConfig struct {
119+ AllowedIPs []string `json:"allowed_ips"`
120+ AllowedAwsVpcIDs []string `json:"allowed_aws_vpc_ids"`
121+ } `json:"allow_rules_config"`
122+ } `json:"database"`
110123 }
111124 resp , err := unmarshal [response ](r )
112125 if err != nil {
113126 return DatabaseConfig {}, err
114127 }
115- return resp .Database , nil
128+ deleteProtection := resp .Database .DeleteProtection
129+ config := DatabaseConfig {DeleteProtection : & deleteProtection }
130+ if ips := resp .Database .AllowRulesConfig .AllowedIPs ; ips != nil {
131+ config .AllowedIPs = & ips
132+ }
133+ if vpcs := resp .Database .AllowRulesConfig .AllowedAwsVpcIDs ; vpcs != nil {
134+ config .AllowedAwsVpcIDs = & vpcs
135+ }
136+ return config , nil
116137}
117138
118139func (d * DatabasesV3Client ) Delete (orgID , dbID string ) error {
0 commit comments