Closed bjan-sag closed 8 months ago
@bjan-sag You're seeing this output because go-c8y-cli
is trying to be smart and guess where the "interesting parts" of the API response is, by default this is array items.
To disable this "auto detection" just use the global --raw
flag.
This should do what you want:
c8y api GET '/service/sslmanagement/health' --raw
Ah, this works - thanks! I tried other views, and output=json
alone doesn't help either. I find this default behavior very surprising.
Would be great if this smart behavior was opt-in instead of default, but that's personal preference :)
Ah, this works - thanks! I tried other views, and
output=json
alone doesn't help either. I find this default behavior very surprising. Would be great if this smart behavior was opt-in instead of default, but that's personal preference :)
For the api
command being "less smart" might actually be a more sensible default...but for the other commands it is definitely better to trim down what is shown (e.g. show array items of .managedObjects[]
instead of the base object).
But I suspect looking at creating your own extension could be interesting to you...
For example, this api endpoint definition (to create a new subcommand group and command)
file: myextextion/api/microservices.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/reubenmiller/go-c8y-cli/feat/extensions-manager/tools/schema/extensionCommands.json
---
version: v1
group:
name: microservices
description: Cumulocity IoT Microservices health
commands:
- name: health
description: Get a microservice health status
method: GET
path: /service/{id}/health
collectionProperty: "-"
pathParameters:
- name: id
type: microservicename
description: Microservice
Then you can call the command using (with tab completion)
c8y myextension microservices health --id cloud-remote-access
You can even add your own custom views to it:
$ c8y devmgmt ms health --id cloud-remote-access
| status | livenessStatus | heapUsed |
|------------|----------------|----------------|
| UP | UP | 151554000 |
Or if you just want a light weight alternative, just use an alias which sets the --raw
value by default for the c8y api
call:
c8y alias set apir 'api --raw'
c8y apir /service/cloud-remote-access/health
For the api command being "less smart" might actually be a more sensible default...but for the other commands it is definitely better to trim down what is shown (e.g. show array items of .managedObjects[] instead of the base object).
I agree - you need a balance here to keep the tool ergonomic.
Thanks for providing the examples, they're really cool. I'll set up an alias for now :)
When trying to get health of the sslmanagement service, I get a malformed response:
With debug:
Meanwhile curl works fine:
Version info: