Autopagenate option and gotmpl

I was previously advised in another topic to add an autopagenate option if the gotmplate conversion fails, but is setting autopagenate mandatory to use transform?
I would like to csv out the results of 'gc telephony providers edges phones get [id]' to check the phone resist status etc.
Looking at the help, the 'gc telephony providers edges phones get [id]' command has the --transform/--transformstr option, but the '-a' option does not seem to work.

Although the commands are different for get and list, they use the same TRANSFORM, so I do not see a problem with syntax.

I can't think of any other reasons for failure, Does anybody have any idea about this problem?

[working as expected]
gc telephony providers edges phones list -a --transformstr="{{- range . -}}{{.name}}{{.id}}{{.state}}{{- end -}}"

[not working]
gc telephony providers edges phones get [id] --transformstr="{{- range . -}}{{.name}}{{.id}}{{.state}}{{- end -}}"

[error message]
Error applying parsed template to data object: template: tmpl:1:17: executing "tmpl" at <.name>: can't evaluate field name in type interface {}

*To isolate the problem cause, the transformstr is simpler than it actually is.

Hi Higashino-san,

The gc telephony providers edges phones list -a and gc telephony providers edges phones get [id] CLI commands return slightly different JSON structures. The get command returns a single object while the list will return an array of objects.

In your get example your transform is trying to iterate (e.g. through the range template) over an object, instead of the object. You might want to remove the range command from the transformstr on the get command.

Thank you,
John Carnell
Director, Developer Engagement

Hi John,

That is a very elementary mistake.
This issue has been resolved.

Sorry for wasting your time on the topic.

Regards,

Hi Higashino-san,

No worries. I am actually glad when its small mistakes because people can quickly move forward to the next thing. :slight_smile:

Thanks,
John

1 Like