GAM Python Library Help

1,456 views
Skip to first unread message

Dametrius King

unread,
Mar 11, 2021, 12:59:18 PM3/11/21
to GAM for Google Workspace
Hello everyone,

Does anybody have any documentation on how to use the gam package in Python? I tried using the help() function and was even more confused.

Thanks for your help,
Dametrius King

Dale Courtney

unread,
Mar 12, 2021, 11:25:41 AM3/12/21
to GAM for G Suite
I'm curious about this as well. 

best,
Dale


--
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/37172648-3401-4431-b2aa-862b69e24193n%40googlegroups.com.

Ross Scroggs

unread,
Mar 12, 2021, 11:27:07 AM3/12/21
to google-ap...@googlegroups.com
Dale,

Here's a trivial example.

#!/usr/bin/env python3                                                                                                                                                                                                                                    

# -*- coding: utf-8 -*-                                                                                                                                                                                                                                   

""" Sample Python script to call GAM"""


import multiprocessing

import sys


import gam


if __name__ == '__main__':

# One time initialization                                                                                                                                                                                                                                 

  if sys.platform == 'darwin':

    multiprocessing.set_start_method('fork')

  gam.initializeLogging()

#                                                                                                                                                                                                                                                         

  gam.CallGAMCommand(['gam', 'version'])

  # Issue command, output goes to stdout/stderr                                                                                                                                                                                                           

  rc = gam.CallGAMCommand(['gam', 'info', 'domain'])

  # Issue command, redirect stdout/stderr                                                                                                                                                                                                                 

  rc = gam.CallGAMCommand(['gam', 'redirect', 'stdout', 'domain.txt', 'redirect', 'stderr', 'stdout', 'info', 'domain'])


Ross




--

Jay Lee

unread,
Mar 12, 2021, 12:37:42 PM3/12/21
to google-ap...@googlegroups.com
The example Ross gave is good. There's a longstanding feature request to make GAM a Python library that others can import and use but it's not GAM's primary purpose to do so and is unlikely to be implemented anytime soon. For most developer use cases they should probably be utilizing the same google-auth and google-api-python-client libraries GAM uses anyhow.

Jay Lee


Dale Courtney

unread,
Mar 12, 2021, 12:44:16 PM3/12/21
to GAM for G Suite
Jay, 

Thanks for that tip. Good to know. I've been using Python's os.system() to call the gam commands in Mac terminal. It works, but it's pretty slow.  

best,
Dale


Reply all
Reply to author
Forward
0 new messages