GAM, Google Sheets & Calendars


While web interfaces make things easier, it is often much faster to do things on the command line, especially if you are trying to make changes in bulk. 

My school recently added Google Calendars for all our sports teams. One trick to make this easier is to use Google Sheets (or Excel) to convert spreadsheet data into commands I can paste into the terminal window of my Mac. 

I use GAM-ADV-XTD3 (a more advanced version of GAM) that uses the Google Admin APIs to mange my Google Workspace environment from the command line.

In GAM-ADV-XTD3 you can create a calendar in a user account like so:

gam user athletics-calendars create calendar summary "Sailing - Varsity"

In the example athletics-calendars is the username of account I wish to create the account in and Sailing - Varsity is the calendar name.

If I have a Google sheet with a list of sports I need to create a calendars for, I can simply write a formula (like the one below) to generate the commands to create all those calendars.

=" gam user athletics-calendars create calendar summary """ & A1 &""""

This combines the text of the command with the contents of the cell A1 (which is where the sports team’s name is). To quote a quote is a little tricky but the formula above works. I then fill down for all the sports teams and now I have the commands to create all of the calendars. I can highlight all of the cells with these commands (B1:B17 in the example below) and paste them into terminal to run them.

After a few seconds I now have 17 calendars created!

Some other handy e GAM-ADV-XTD3 calendar related commands:

Give a user access/permission to a calendar:

gam calendar xyzzyasfda@group.calendar.google.com add acls writer user@exampledomain.com

xyzzyasfda@group.calendar.google.com is the Calendar ID that you want to give access to user@exampledomain.com. While writer allows someone to edit a calendar, you need to assign owner in order for them to change sharing settings.

Make a calendar public:

gam calendar xyzzyasfda@group.calendar.google.com add acls reader default

If you want to make a calendar public (so that anyone on the can access it) you use default as the username. Using reader provides read-only access.

List all of the calendar in a users account:

gam user sample_user print calendars showhidden todrive

This lists all of the calendars in sample_user's account in a new Google Sheet (todrive). This can be handy to find the Calendar ID of a specific calendar.

,

Leave a Reply

Your email address will not be published. Required fields are marked *