Not a question but wanted to share 2 very simple GO templates I did while learning the syntax and using CLI tool for customer org builds and integration work I do.
If not appropriate for forum, please delete.
I found using GC to get Id's to Names a constant need and using the API explorer to "find" my Name or ID slow or required multiple steps to find info (copy/paste into N++ etc)
I see CLI APIs return simple json or entities array so I created template for each. Extremely simple and my first dabble with them!
Both these extract top level Id and Name into a valid json format, to aid finding pairs quickly.
Go template where no entities on response;
[
{{ $numRows := len . }}
{{ range $index, $element := . }}{{if $index}},{{end}}
{
"id": "{{.id}}",
"name":"{{.name}}"
}
{{- end }}
]
And one where entities is returned from the CLI command;
{{/* .entities top level access from json. Many API calls return an array of entities */}}
{{/* the if index bit on end of range makes the output add comma to rows, and not the last row to generate valid json response */}}
[
{{ $numRows := len . }}
{{ range $index, $element := .entities }}{{if $index}},{{end}}
{
"id": "{{.id}}",
"name":"{{.name}}"
}
{{- end }}
]
Example of use, to get the workflows and grab the id and name to quickly find the Id to add to a trigger creation!
gc flows list --varType workflow --transform GO_entities.txt -p sg
Again, if not appropriate just delete post
Regards
Simon