diff --git a/docs/actions.md b/docs/actions.md index e566de7b7c2..fa3ff896f4f 100644 --- a/docs/actions.md +++ b/docs/actions.md @@ -917,12 +917,13 @@ You can list all the actions that you have created using: wsk action list ``` -As you write more actions, this list gets longer and it can be helpful to group related actions into [packages](./packages.md). To filter your list of actions to just the those within a specific pacakge, you can use: +By default, listed actions will be sorted alphabetically, first by namespaces, then [packages](./packages.md), and finally by action name. To filter your list of actions to just the those within a specific pacakge, you can use: ``` wsk action list [PACKAGE NAME] ``` +Side Note: Listing works the same way for actions as it does for [packages](./packages.md), [APIs](./apigateway.md), [triggers and rules](./triggers_rules.md). ## Deleting actions diff --git a/docs/apigateway.md b/docs/apigateway.md index 50dcd61b209..802ea8fcfa6 100644 --- a/docs/apigateway.md +++ b/docs/apigateway.md @@ -123,6 +123,12 @@ wsk api list -f ``` ``` ok: APIs +Action: deleteBooks + API Name: Book Club + Base path: /club + Path: /books + Verb: delete + URL: https://${APIHOST}:9001/api/21ef035/club/books Action: getBooks API Name: Book Club Base path: /club @@ -141,14 +147,10 @@ Action: putBooks Path: /books Verb: put URL: https://${APIHOST}:9001/api/21ef035/club/books -Action: deleteBooks - API Name: Book Club - Base path: /club - Path: /books - Verb: delete - URL: https://${APIHOST}:9001/api/21ef035/club/books ``` +Side Note: APIs will be sorted alphabetically by default, first by Base path, then by Path (relative path), then by Verb. If we need to sort alphabetically by Action name, we can add the `-n` or `--sort-action` flags to do so. + Now just for fun let's add a new book `JavaScript: The Good Parts` with a HTTP __POST__ ``` curl -X POST -d '{"name":"JavaScript: The Good Parts", "isbn":"978-0596517748"}' https://${APIHOST}:9001/api/21ef035/club/books diff --git a/docs/packages.md b/docs/packages.md index 499c2478d57..61137baff3b 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -21,18 +21,18 @@ Several packages are registered with OpenWhisk. You can get a list of packages i $ wsk package list /whisk.system ``` ``` - packages - /whisk.system/cloudant shared - /whisk.system/alarms shared - /whisk.system/watson shared - /whisk.system/websocket shared - /whisk.system/weather shared - /whisk.system/system shared - /whisk.system/utils shared - /whisk.system/slack shared - /whisk.system/samples shared - /whisk.system/github shared - /whisk.system/pushnotifications shared + packages + /whisk.system/alarms shared + /whisk.system/cloudant shared + /whisk.system/github shared + /whisk.system/pushnotifications shared + /whisk.system/samples shared + /whisk.system/slack shared + /whisk.system/system shared + /whisk.system/utils shared + /whisk.system/watson shared + /whisk.system/weather shared + /whisk.system/websocket shared ``` 2. Get a list of entities in the `/whisk.system/cloudant` package. diff --git a/docs/triggers_rules.md b/docs/triggers_rules.md index 7fe83a8461e..ffefd22f6b1 100644 --- a/docs/triggers_rules.md +++ b/docs/triggers_rules.md @@ -56,7 +56,7 @@ As an example, create a trigger to send user location updates, and manually fire ok: created trigger locationUpdate ``` -2. Check that you created the trigger by listing the set of triggers. +2. Check that you created the trigger by listing the set of triggers. (Side note: triggers and rules will be listed alphabetically when using the `list` command.) ``` $ wsk trigger list diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala index 6dc857a8815..afecd8f2da4 100644 --- a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala +++ b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala @@ -74,6 +74,138 @@ class ApiGwEndToEndTests behavior of "Wsk api-experimental" + it should "return a list of alphabetized api-experimental" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + + val actionName1 = "actionName1" + val actionName2 = "actionName2" + val actionName3 = "actionName3" + val base1 = "/BaseTestPath1" + val base2 = "/BaseTestPath2" + val base3 = "/BaseTestPath3" + + try { + //Create Actions for apiexperimentals + val file = TestUtils.getTestActionFilename(s"echo-web-http.js") + println("Create Action: " + actionName1) + assetHelper.withCleaner(wsk.action, actionName1) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName2) + assetHelper.withCleaner(wsk.action, actionName2) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName3) + assetHelper.withCleaner(wsk.action, actionName3) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + //Create apiexperimentals + println("Create api-experimental: Base Path " + base2) + wsk.apiexperimental.create( + basepath = Some(base2), + relpath = Some("/relPath1"), + operation = Some("get"), + action = Some(actionName2) + ) + println("Create api-experimental: Base Path " + base1) + wsk.apiexperimental.create( + basepath = Some(base1), + relpath = Some("/relPath2"), + operation = Some("delete"), + action = Some(actionName1) + ) + println("Create api-experimental: Base Path " + base3) + wsk.apiexperimental.create( + basepath = Some(base3), + relpath = Some("/relPath3"), + operation = Some("head"), + action = Some(actionName3) + ) + val original = wsk.apiexperimental.list().stdout + val originalFull = wsk.apiexperimental.list(full = Some(true)).stdout + val scalaSorted = List(base1 + "/", base2 + "/", base3 + "/") + val regex = "/BaseTestPath[1-3]/".r + val list = (regex.findAllMatchIn(original)).toList + val listFull = (regex.findAllMatchIn(originalFull)).toList + scalaSorted.toString shouldEqual list.toString + scalaSorted.toString shouldEqual listFull.toString + } finally { + //Clean up apiexperimentals + println("Delete api-experimental: Base Path " + base1) + wsk.apiexperimental.delete(base1, expectedExitCode = DONTCARE_EXIT) + println("Delete api-experimental: Base Path " + base2) + wsk.apiexperimental.delete(base2, expectedExitCode = DONTCARE_EXIT) + println("Delete api-experimental: Base Path " + base3) + wsk.apiexperimental.delete(base3, expectedExitCode = DONTCARE_EXIT) + } + } + + it should "return a list of alphabetized api-experimental by action name" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + + val actionName1 = "actionName1" + val actionName2 = "actionName2" + val actionName3 = "actionName3" + val base1 = "/BaseTestPath1" + val base2 = "/BaseTestPath2" + val base3 = "/BaseTestPath3" + + try { + //Create Actions for api-experimentals + val file = TestUtils.getTestActionFilename(s"echo-web-http.js") + println("Create Action: " + actionName1) + assetHelper.withCleaner(wsk.action, actionName1) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName2) + assetHelper.withCleaner(wsk.action, actionName2) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName3) + assetHelper.withCleaner(wsk.action, actionName3) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + //Create api-experimentals + println("Create api-experimental: Base Path " + base2) + wsk.apiexperimental.create( + basepath = Some(base2), + relpath = Some("/relPath1"), + operation = Some("get"), + action = Some(actionName2) + ) + println("Create apiexperimental: Base Path " + base1) + wsk.apiexperimental.create( + basepath = Some(base1), + relpath = Some("/relPath2"), + operation = Some("delete"), + action = Some(actionName1) + ) + println("Create apiexperimental: Base Path " + base3) + wsk.apiexperimental.create( + basepath = Some(base3), + relpath = Some("/relPath3"), + operation = Some("head"), + action = Some(actionName3) + ) + val original = wsk.apiexperimental.list(sortAction = Some(true)).stdout + val originalFull = wsk.apiexperimental.list(full = Some(true), sortAction = Some(true)).stdout + val scalaSorted = List(actionName1, actionName2, actionName3) + val regex = "actionName[1-3]".r + val list = (regex.findAllMatchIn(original)).toList + val listFull = (regex.findAllMatchIn(originalFull)).toList + scalaSorted.toString shouldEqual list.toString + scalaSorted.toString shouldEqual listFull.toString + } finally { + //Clean up apiexperimentals + println("Delete apiexperimental: Base Path " + base1) + wsk.apiexperimental.delete(base1, expectedExitCode = DONTCARE_EXIT) + println("Delete apiexperimental: Base Path " + base2) + wsk.apiexperimental.delete(base2, expectedExitCode = DONTCARE_EXIT) + println("Delete apiexperimental: Base Path " + base3) + wsk.apiexperimental.delete(base3, expectedExitCode = DONTCARE_EXIT) + } + } + it should s"create an API and successfully invoke that API" in { val testName = "APIGWe_HEALTHTEST1" val testbasepath = "/" + testName + "_bp" @@ -144,6 +276,147 @@ class ApiGwEndToEndTests behavior of "Wsk api" + it should "return a list of alphabetized api" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + + val actionName1 = "actionName1" + val actionName2 = "actionName2" + val actionName3 = "actionName3" + val base1 = "/BaseTestPath1" + val base2 = "/BaseTestPath2" + val base3 = "/BaseTestPath3" + + try { + //Create Actions for Apis + val file = TestUtils.getTestActionFilename(s"echo-web-http.js") + println("Create Action: " + actionName1) + assetHelper.withCleaner(wsk.action, actionName1) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName2) + assetHelper.withCleaner(wsk.action, actionName2) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName3) + assetHelper.withCleaner(wsk.action, actionName3) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + //Create Apis + println("Create API: Base Path " + base2) + wsk.api.create( + basepath = Some(base2), + relpath = Some("/relPath1"), + operation = Some("get"), + action = Some(actionName2), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath()) + ) + println("Create API: Base Path " + base1) + wsk.api.create( + basepath = Some(base1), + relpath = Some("/relPath2"), + operation = Some("delete"), + action = Some(actionName1), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath()) + ) + println("Create API: Base Path " + base3) + wsk.api.create( + basepath = Some(base3), + relpath = Some("/relPath3"), + operation = Some("head"), + action = Some(actionName3), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath()) + ) + val original = wsk.api.list(cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())).stdout + val originalFull = wsk.api.list(full = Some(true), cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())).stdout + val scalaSorted = List(base1 + "/", base2 + "/", base3 + "/") + val regex = "/BaseTestPath[1-3]/".r + val list = (regex.findAllMatchIn(original)).toList + val listFull = (regex.findAllMatchIn(originalFull)).toList + scalaSorted.toString shouldEqual list.toString + scalaSorted.toString shouldEqual listFull.toString + } finally { + //Clean up Apis + println("Delete API: Base Path " + base1) + wsk.api.delete(base1, expectedExitCode = DONTCARE_EXIT, cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())) + println("Delete API: Base Path " + base2) + wsk.api.delete(base2, expectedExitCode = DONTCARE_EXIT, cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())) + println("Delete API: Base Path " + base3) + wsk.api.delete(base3, expectedExitCode = DONTCARE_EXIT, cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())) + } + } + + it should "return a list of alphabetized api by action name" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + + val actionName1 = "actionName1" + val actionName2 = "actionName2" + val actionName3 = "actionName3" + val base1 = "/BaseTestPath1" + val base2 = "/BaseTestPath2" + val base3 = "/BaseTestPath3" + + try { + //Create Actions for Apis + val file = TestUtils.getTestActionFilename(s"echo-web-http.js") + println("Create Action: " + actionName1) + assetHelper.withCleaner(wsk.action, actionName1) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName2) + assetHelper.withCleaner(wsk.action, actionName2) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + println("Create Action: " + actionName3) + assetHelper.withCleaner(wsk.action, actionName3) { + (action, name) => action.create(name, artifact = Some(file), expectedExitCode = SUCCESS_EXIT, web = Some("true")) + } + //Create Apis + println("Create API: Base Path " + base2) + wsk.api.create( + basepath = Some(base2), + relpath = Some("/relPath1"), + operation = Some("get"), + action = Some(actionName2), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath()) + ) + println("Create API: Base Path " + base1) + wsk.api.create( + basepath = Some(base1), + relpath = Some("/relPath2"), + operation = Some("delete"), + action = Some(actionName1), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath()) + ) + println("Create API: Base Path " + base3) + wsk.api.create( + basepath = Some(base3), + relpath = Some("/relPath3"), + operation = Some("head"), + action = Some(actionName3), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath()) + ) + val original = wsk.api.list(sortAction = Some(true), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())).stdout + val originalFull = wsk.api.list(full = Some(true), sortAction = Some(true), + cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())).stdout + val scalaSorted = List(actionName1, actionName2, actionName3) + val regex = "actionName[1-3]".r + val list = (regex.findAllMatchIn(original)).toList + val listFull = (regex.findAllMatchIn(originalFull)).toList + scalaSorted.toString shouldEqual list.toString + scalaSorted.toString shouldEqual listFull.toString + } finally { + //Clean up Apis + println("Delete API: Base Path " + base1) + wsk.api.delete(base1, expectedExitCode = DONTCARE_EXIT, cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())) + println("Delete API: Base Path " + base2) + wsk.api.delete(base2, expectedExitCode = DONTCARE_EXIT, cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())) + println("Delete API: Base Path " + base3) + wsk.api.delete(base3, expectedExitCode = DONTCARE_EXIT, cliCfgFile = Some(cliWskPropsFile.getCanonicalPath())) + } + } + + it should s"create an API and successfully invoke that API" in { val testName = "APIGW_HEALTHTEST1" val testbasepath = "/" + testName + "_bp" diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/Wsk.scala index 7720344cbec..e40e52bd9e8 100644 --- a/tests/src/test/scala/common/Wsk.scala +++ b/tests/src/test/scala/common/Wsk.scala @@ -794,6 +794,7 @@ class WskApiExperimental extends RunWskCmd { limit: Option[Int] = None, since: Option[Instant] = None, full: Option[Boolean] = None, + sortAction: Option[Boolean] = None, expectedExitCode: Int = SUCCESS_EXIT)( implicit wp: WskProps): RunResult = { val params = Seq(noun, "list", "--auth", wp.authKey) ++ @@ -802,7 +803,8 @@ class WskApiExperimental extends RunWskCmd { { operation map { o => Seq(o) } getOrElse Seq() } ++ { limit map { l => Seq("--limit", l.toString) } getOrElse Seq() } ++ { since map { i => Seq("--since", i.toEpochMilli.toString) } getOrElse Seq() } ++ - { full map { r => Seq("--full") } getOrElse Seq() } + { full map { r => Seq("--full") } getOrElse Seq() } ++ + { sortAction map{ n => Seq("--sort-action") } getOrElse Seq() } cli(wp.overrides ++ params, expectedExitCode, showCmd = true) } @@ -888,6 +890,7 @@ class WskApi() limit: Option[Int] = None, since: Option[Instant] = None, full: Option[Boolean] = None, + sortAction: Option[Boolean] = None, expectedExitCode: Int = SUCCESS_EXIT, cliCfgFile: Option[String] = None)( implicit wp: WskProps): RunResult = { @@ -897,7 +900,8 @@ class WskApi() { operation map { o => Seq(o) } getOrElse Seq() } ++ { limit map { l => Seq("--limit", l.toString) } getOrElse Seq() } ++ { since map { i => Seq("--since", i.toEpochMilli.toString) } getOrElse Seq() } ++ - { full map { r => Seq("--full") } getOrElse Seq() } + { full map { r => Seq("--full") } getOrElse Seq() } ++ + { sortAction map { n => Seq("--sort-action") } getOrElse Seq() } cli(wp.overrides ++ params, expectedExitCode, showCmd = true, env=Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse(""))) } diff --git a/tests/src/test/scala/system/basic/WskBasicTests.scala b/tests/src/test/scala/system/basic/WskBasicTests.scala index b492c2cd270..9789e8f6baa 100644 --- a/tests/src/test/scala/system/basic/WskBasicTests.scala +++ b/tests/src/test/scala/system/basic/WskBasicTests.scala @@ -47,6 +47,127 @@ class WskBasicTests behavior of "Wsk CLI" + + it should "return a list of alphabetized packages" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + + //Declare 4 actions, create them out of alphabetical order + val nameA = "activationBasicTestingA1" + val nameB = "activationBasicTestingA2" + val nameC = "activationBasicTestingB1" + assetHelper.withCleaner(wsk.pkg, nameB) { + (pkg, nameB) => + pkg.create(nameB) + } + assetHelper.withCleaner(wsk.pkg, nameC) { + (pkg, nameC) => + pkg.create(nameC) + } + assetHelper.withCleaner(wsk.pkg, nameA) { + (pkg, nameA) => + pkg.create(nameA) + } + + val original = wsk.pkg.list().stdout + //Create list with action names in correct order + val scalaSorted = List(nameA, nameB, nameC) + //Filter out everything not previously created + val regex = "activationBasicTesting[A,B][1,2]".r + //Retrieve action names into list as found in original + val list = (regex.findAllMatchIn(original)).toList + scalaSorted.toString shouldEqual list.toString + } + + + it should "return a list of alphabetized rules" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + + val triggerName = "listRulesTrigger" + val actionName = "listRulesAction" + + assetHelper.withCleaner(wsk.trigger, triggerName) { + (trigger, name) => trigger.create(name) + } + assetHelper.withCleaner(wsk.action, actionName) { + (action, name) => action.create(name, defaultAction) + } + //Declare 4 actions, create them out of alphabetical order + val nameA = "activationBasicTestingA1" + val nameB = "activationBasicTestingA2" + val nameC = "activationBasicTestingB1" + assetHelper.withCleaner(wsk.rule, nameB) { + (rule, nameB) => + rule.create(nameB, trigger = triggerName, action = actionName) + } + assetHelper.withCleaner(wsk.rule, nameC) { + (rule, nameC) => + rule.create(nameC, trigger = triggerName, action = actionName) + } + assetHelper.withCleaner(wsk.rule, nameA) { + (rule, nameA) => + rule.create(nameA, trigger = triggerName, action = actionName) + } + + val original = wsk.rule.list().stdout + //Create list with action names in correct order + val scalaSorted = List(nameA, nameB, nameC) + //Filter out everything not previously created + val regex = "activationBasicTesting[A,B][1,2]".r + //Retrieve action names into list as found in original + val list = (regex.findAllMatchIn(original)).toList + scalaSorted.toString shouldEqual list.toString + } + + it should "return a list of alphabetized actions" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + //Declare 4 actions, create them out of alphabetical order + val nameA = "activationBasicTestingA1" + val nameB = "activationBasicTestingA2" + val nameC = "activationBasicTestingB1" + assetHelper.withCleaner(wsk.action, nameB) { + (action, _) => action.create(nameB, Some(TestUtils.getTestActionFilename("empty.js"))) + } + assetHelper.withCleaner(wsk.action, nameC) { + (action, _) => action.create(nameC, Some(TestUtils.getTestActionFilename("empty.js"))) + } + assetHelper.withCleaner(wsk.action, nameA) { + (action, _) => action.create(nameA, Some(TestUtils.getTestActionFilename("empty.js"))) + } + val original = wsk.action.list().stdout + //Create list with action names in correct order + val scalaSorted = List(nameA, nameB, nameC) + //Filter out everything not previously created + val regex = "activationBasicTesting[A,B][1,2]".r + //Retrieve action names into list as found in original + val list = (regex.findAllMatchIn(original)).toList + scalaSorted.toString shouldEqual list.toString +} + +it should "return a list of alphabetized triggers" in withAssetCleaner(wskprops) { +(wp, assetHelper) => + //Declare 4 actions, create them out of alphabetical order + val nameA = "activationBasicTestingA1" + val nameB = "activationBasicTestingA2" + val nameC = "activationBasicTestingB1" + assetHelper.withCleaner(wsk.trigger, nameB) { + (trigger, _) => trigger.create(nameB) + } + assetHelper.withCleaner(wsk.trigger, nameC) { + (trigger, _) => trigger.create(nameC) + } + assetHelper.withCleaner(wsk.trigger, nameA) { + (trigger, _) => trigger.create(nameA) + } + val original = wsk.trigger.list().stdout + //Create list with action names in correct order + val scalaSorted = List(nameA, nameB, nameC) + //Filter out everything not previously created + val regex = "activationBasicTesting[A,B][1,2]".r + //Retrieve action names into list as found in original + val list = (regex.findAllMatchIn(original)).toList + scalaSorted.toString shouldEqual list.toString +} + it should "confirm wsk exists" in { Wsk.exists } diff --git a/tools/cli/go-whisk-cli/commands/action.go b/tools/cli/go-whisk-cli/commands/action.go index a9a161453e8..3eb5a7a7d48 100644 --- a/tools/cli/go-whisk-cli/commands/action.go +++ b/tools/cli/go-whisk-cli/commands/action.go @@ -312,9 +312,12 @@ var actionListCmd = &cobra.Command{ if actions, _, err = client.Actions.List(qualifiedName.entityName, options); err != nil { return actionListError(qualifiedName.entityName, options, err) } - - printList(actions) - + if (len(actions) != 0) { + whisk.Debug(whisk.DbgInfo, "Sending actions to be printed") + printList(actions) + } else { + whisk.Debug(whisk.DbgInfo, "No actions found in action list") + } return nil }, } diff --git a/tools/cli/go-whisk-cli/commands/api.go b/tools/cli/go-whisk-cli/commands/api.go index 5e4f89dcd55..0d308fadde8 100644 --- a/tools/cli/go-whisk-cli/commands/api.go +++ b/tools/cli/go-whisk-cli/commands/api.go @@ -299,7 +299,7 @@ var apiDeleteCmd = &cobra.Command{ if err != nil { whisk.Debug(whisk.DbgError, "client.Apis.Delete(%#v, %#v) error: %s\n", apiDeleteReq, apiDeleteReqOptions, err) errMsg := wski18n.T("Unable to delete API: {{.err}}", map[string]interface{}{"err": err}) - whiskErr := whisk.MakeWskError(errors.New(errMsg), whisk.EXITCODE_ERR_GENERAL, + whiskErr := whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE) return whiskErr } @@ -346,6 +346,9 @@ var apiListCmd = &cobra.Command{ var retApiList *whisk.ApiListResponse var retApi *whisk.ApiGetResponse var retApiArray *whisk.RetApiArray + var flagType string + var sortFilteredList []whisk.ApiFilteredList + var sortFilteredRow []whisk.ApiFilteredRow if whiskErr := checkArgs(args, 0, 3, "Api list", wski18n.T("Optional parameters are: API base path (or API name), API relative path and operation.")); whiskErr != nil { @@ -406,7 +409,10 @@ var apiListCmd = &cobra.Command{ // Cast to a common type to allow for code to print out apilist response or apiget response retApiArray = (*whisk.RetApiArray)(retApi) } - + //Checks for any sort flags being passed + if flags.api.sortAction { + flagType = "a" + } // Display the APIs - applying any specified filtering if (flags.common.full) { fmt.Fprintf(color.Output, @@ -414,9 +420,14 @@ var apiListCmd = &cobra.Command{ map[string]interface{}{ "ok": color.GreenString("ok:"), })) - for i:=0; i 0) { @@ -1181,8 +1227,14 @@ var apiListCmdV2 = &cobra.Command{ "ok": color.GreenString("ok:"), })) fmt.Printf(fmtString, "Action", "Verb", "API Name", "URL") - for i:=0; i