formatjson option not supported across all commands?

480 views
Skip to first unread message

Juan Alberto MORENO

unread,
Apr 13, 2022, 5:46:39 PM4/13/22
to GAM for Google Workspace
Greetings all,

I'm a newbie here, moderately familiar with gamadvxtd3 and python, and probably trying to make things more complex than they should be, so any comments or advice is welcome!

 I've been successfully building my own custom gamadvxtd3 wrapper with python for my needs, and now I'm coming across a situation where I would need some guidance; 

While some commands I need to use do return a json formatted output by specifying 'formatjson' at the end of the command line which can be easily parsed,  is seems like  this not the case for other commands, so I find myself needing to parse indented-text output in a very custom way;

Thus, for example, a command line output for granting access for a given user  to a shared drive:

gam select XXX add drivefileacl XXXX user XXXX role contributor formatjson

does work, but always returns an indented-text output regardless of whether I specify the 'formatjson' option or not;

am I missing something or making a mistake in my command syntax?

is there a reference of commands which do support 'formatjson' ?

Thanks in advance!

JAM 


Maj Marshall Giguere

unread,
Apr 13, 2022, 6:27:02 PM4/13/22
to google-ap...@googlegroups.com
Juan;

Not all gam commands provide JSON output, you have to look at each command individually.  In general JSON is reserved for commands that specifically retrieve data from the Workspace environment, e.g. users.  In this case gam is simply reporting success, albeit verbosely.  Also the I think the select clause in your command is unnecessary:  gam add drivefileacl teamdrive "<shared drive name>" user <UserEmail> role <ROLE>
You can supply the drive ID if you don't have the name: teamdriveid <Shared Drive ID>

If i'm not entirely accurate I'm sure Ross will correct me.

--
Maj Marshall E Giguere
NH Wing Director of IT
Civil Air Patrol, U.S. Air Force Auxiliary




Volunteers serving America's communities, saving lives, and shaping futures.


--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/c96ff638-9c3f-4f10-a828-71c10ee2b9f8n%40googlegroups.com.

Ross Scroggs

unread,
Apr 13, 2022, 6:28:09 PM4/13/22
to google-ap...@googlegroups.com
JAM,

gam create|add drivefileacl <SharedDriveEntityAdmin>
        anyone|(user <UserItem>)|(group <GroupItem>)|(domain <DomainName>)
        (role <DriveFileACLRole>) [withlink|(allowfilediscovery|discoverable [<Boolean>])]
[enforcesingleparent <Boolean>] [movetonewownersroot [<Boolean>]]
        [expiration <Time>] [sendemail] [emailmessage <String>]
        [showtitles] [nodetails|(csv [todrive <ToDriveAttribute>*] [formatjson [quotechar <Character>]])]

formatjson is a suboption of csv so you must say:
gam select XXX add drivefileacl XXXX user XXXX role contributor csv formatjson
Unfortunately, in versions before 6.20.02, this caused a trap so you have to say the following which include the file name in the output:
gam select XXX add drivefileacl XXXX user XXXX role contributor showtitles csv formatjson

In 6.20.02, you can omit showtitles.

Ross


Ross Scroggs

unread,
Apr 13, 2022, 6:40:52 PM4/13/22
to google-ap...@googlegroups.com
Marsh/JAM,

Almost all gam print commands provide formatjson.

Some create commands do as well so you can capture the details:
gam <UserTypeEntity> create teamdrive
gam <UserTypeEntity> create drivefile
gam <UserTypeEntity> create drivefileacl
gam <UserTypeEntity> update drivefileacl
gam <UserTypeEntity> create drivefileshortcut
gam <UserTypeEntity> create form
gam <UserTypeEntity> create classroominvitation

select XXX is choosing his client

Ross

Ross Scroggs

unread,
Apr 13, 2022, 7:03:31 PM4/13/22
to google-ap...@googlegroups.com
Upon closer inspection, the following create commands do not support formatjson.
gam <UserTypeEntity> create drivefileshortcut
gam <UserTypeEntity> create form
gam <UserTypeEntity> create classroominvitation

Ross

Juan Alberto MORENO

unread,
Apr 14, 2022, 5:17:39 AM4/14/22
to GAM for Google Workspace
Hello Marsh/Ross, and thank you so much for your quick and helpful answers!

I did manage to get the expected json using 'showtitles csv', so again thank you very much for the pointer! I do take note of those few commands you mention that do not support the option.

and yes, I use the select XXX to route the commands towards my sandbox vs. operational environment

I am very appreciative of your efforts in providing gam and supporting the community, hope I can give back too at some point!

Best,
JAM  
Reply all
Reply to author
Forward
0 new messages