MCPcopy
hub / github.com/larksuite/cli / dryRunBaseCreate

Function dryRunBaseCreate

shortcuts/base/base_ops.go:37–69  ·  view source on GitHub ↗
(_ context.Context, runtime *common.RuntimeContext)

Source from the content-addressed store, hash-verified

35}
36
37func 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
71func validateBaseCreate(runtime *common.RuntimeContext) error {
72 return nil

Callers 1

TestDryRunBaseOpsFunction · 0.85

Calls 13

DescMethod · 0.95
POSTMethod · 0.95
GETMethod · 0.95
DELETEMethod · 0.95
PATCHMethod · 0.95
buildBaseCreateBodyFunction · 0.85
dryRunTableCreateBodyFunction · 0.85
baseCreateFirstTableNameFunction · 0.85
BodyMethod · 0.80
StrMethod · 0.65
SetMethod · 0.65
IsBotMethod · 0.45

Tested by 1

TestDryRunBaseOpsFunction · 0.68