| 35 | } |
| 36 | |
| 37 | func dryRunBaseCreate(_ context.Context, runtime *common.RuntimeContext) *common.DryRunAPI { |
| 38 | d := common.NewDryRunAPI() |
| 39 | if runtime.IsBot() { |
| 40 | d.Desc("After Base creation succeeds in bot mode, the CLI will also try to grant the current CLI user full_access (可管理权限) on the new Base.") |
| 41 | } |
| 42 | d. |
| 43 | POST("/open-apis/base/v3/bases"). |
| 44 | Body(buildBaseCreateBody(runtime)) |
| 45 | hasFields := strings.TrimSpace(runtime.Str("fields")) != "" |
| 46 | hasTableName := strings.TrimSpace(runtime.Str("table-name")) != "" |
| 47 | if hasFields { |
| 48 | d.GET("/open-apis/base/v3/bases/:created_base_token/tables"). |
| 49 | Params(map[string]interface{}{"offset": 0, "limit": 100}). |
| 50 | Desc("If the create response does not include the default table ID, the CLI lists tables to find it."). |
| 51 | Set("created_base_token", "<created_base_token>") |
| 52 | d.POST("/open-apis/base/v3/bases/:created_base_token/tables"). |
| 53 | Body(dryRunTableCreateBody(runtime, baseCreateFirstTableName(runtime))). |
| 54 | Desc("Create a replacement first table with --fields in the create-table body.") |
| 55 | d.DELETE("/open-apis/base/v3/bases/:created_base_token/tables/:default_table_id"). |
| 56 | Desc("After a 1s wait, delete the default table created with the Base."). |
| 57 | Set("default_table_id", "<default_table_id>") |
| 58 | } else if hasTableName { |
| 59 | d.GET("/open-apis/base/v3/bases/:created_base_token/tables"). |
| 60 | Params(map[string]interface{}{"offset": 0, "limit": 100}). |
| 61 | Desc("If the create response does not include the default table ID, the CLI lists tables to find it."). |
| 62 | Set("created_base_token", "<created_base_token>") |
| 63 | d.PATCH("/open-apis/base/v3/bases/:created_base_token/tables/:default_table_id"). |
| 64 | Body(map[string]interface{}{"name": baseCreateFirstTableName(runtime)}). |
| 65 | Desc("Rename the default first table when only --table-name is provided."). |
| 66 | Set("default_table_id", "<default_table_id>") |
| 67 | } |
| 68 | return d |
| 69 | } |
| 70 | |
| 71 | func validateBaseCreate(runtime *common.RuntimeContext) error { |
| 72 | return nil |