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

Function buildWikiNodeCreateDryRun

shortcuts/wiki/wiki_node_create.go:259–292  ·  view source on GitHub ↗
(spec wikiNodeCreateSpec)

Source from the content-addressed store, hash-verified

257}
258
259func buildWikiNodeCreateDryRun(spec wikiNodeCreateSpec) *common.DryRunAPI {
260 dry := common.NewDryRunAPI()
261 step := 1
262
263 switch {
264 case needsMyLibraryLookup(spec) && spec.ParentNodeToken != "":
265 dry.Desc("3-step orchestration: resolve my_library -> resolve parent node -> create wiki node")
266 case needsMyLibraryLookup(spec):
267 dry.Desc("2-step orchestration: resolve my_library -> create wiki node")
268 case spec.ParentNodeToken != "":
269 dry.Desc("2-step orchestration: resolve parent node -> create wiki node")
270 default:
271 dry.Desc("1-step request: create wiki node")
272 }
273
274 if needsMyLibraryLookup(spec) {
275 dry.GET("/open-apis/wiki/v2/spaces/my_library").
276 Desc(fmt.Sprintf("[%d] Resolve my_library space ID", step))
277 step++
278 }
279
280 if spec.ParentNodeToken != "" {
281 dry.GET("/open-apis/wiki/v2/spaces/get_node").
282 Desc(fmt.Sprintf("[%d] Resolve parent node space", step)).
283 Params(map[string]interface{}{"token": spec.ParentNodeToken})
284 step++
285 }
286
287 dry.POST(fmt.Sprintf("/open-apis/wiki/v2/spaces/%s/nodes", dryRunWikiNodeCreateSpaceID(spec))).
288 Desc(fmt.Sprintf("[%d] Create wiki node", step)).
289 Body(spec.RequestBody())
290
291 return dry
292}
293
294func dryRunWikiNodeCreateSpaceID(spec wikiNodeCreateSpec) string {
295 if spec.SpaceID != "" && spec.SpaceID != wikiMyLibrarySpaceID {

Callers 1

Calls 8

DescMethod · 0.95
GETMethod · 0.95
POSTMethod · 0.95
needsMyLibraryLookupFunction · 0.85
BodyMethod · 0.80
ParamsMethod · 0.45
RequestBodyMethod · 0.45

Tested by

no test coverage detected