(spec wikiNodeCreateSpec)
| 257 | } |
| 258 | |
| 259 | func 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 | |
| 294 | func dryRunWikiNodeCreateSpaceID(spec wikiNodeCreateSpec) string { |
| 295 | if spec.SpaceID != "" && spec.SpaceID != wikiMyLibrarySpaceID { |
no test coverage detected