taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
703 stars 87 forks source link

[QUESTION] How to limit the results returned by gam? #290

Closed jay-eleven closed 2 years ago

jay-eleven commented 2 years ago

Hi Ross!

I'm stumped with something... πŸ˜… Let's say I'm working with a large domain (eg. 100's users, 1000's files, etc...) and I'm trying to configure the precise gam command that will do everything I need. I'll start simple and will add parameters increasing complexity slowly. This means I have to issue multiple gam commands on a large domain, and this may take ages. Ok, not ages, but reading 1000's of files each time is slow.

I know there are multiple xxxx_max_results gam.cfg variables, but these only affect how many results are fetched per API call. The next pageToken is always processed so these variables only affect how many API calls are made, not how many results are returned by GAM.

I've been reading the GAM configuration page, but I can't find a way to tell gam to only process one API call and ignore processing of pageToken. I'm not sure if this is even possible.

So the question is: is there a way to tell gam to ignore pageToken so that I can work with a smaller set of results?

taers232c commented 2 years ago

Jay,

Here's an approach I use. Make a column in your csv file called action; for every row you want to process put an x in the column

gam config csv_input_row_filter "action:regex:x" csv filename.csv gam .....

The downside to this is that every row will be read but only one processed.

gam csv |-|(gsheet ) [charset ] [warnifnodata] [columndelimiter ] [quotechar ] [fields ] (matchfield|skipfield )* [showcmds []] gam

I can add [maxrows ] to limit the number of rows read/processed.

Ross

@.***

On Aug 2, 2022, at 1:05 PM, Jay @.***> wrote:

Hi Ross!

I'm stumped with something... πŸ˜… Let's say I'm working with a large domain (eg. 100's users, 1000's files, etc...) and I'm trying to configure the precise gam command that will do everything I need. I'll start simple and will add parameters increasing complexity slowly. This means I have to issue multiple gam commands on a large domain, and this may take ages. Ok, not ages, but reading 1000's of files each time is slow.

I know there are multiple xxxx_max_results gam.cfg variables, but these only affect how many results are fetched per API call. The next pageToken is always processed so these variables only affect how many API calls are made, not how many results are returned by GAM.

I've been reading the GAM configuration page https://github.com/taers232c/GAMADV-XTD3/wiki/gam.cfg, but I can't find a way to tell gam to only process one API call and ignore processing of pageToken. I'm not sure if this is even possible.

So the question is: is there a way to tell gam to ignore pageToken so that I can work with a smaller set of results?

β€” Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/290, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL2T5MOX7BVFVDGHUJ3VXF5Q7ANCNFSM55MMQXEQ. You are receiving this because you are subscribed to this thread.

jay-eleven commented 2 years ago

I do something similar. Say I want to update mail signatures on a 2000 user domain. First, I want to run my gam command on 10 dummy accounts I use for testing.

  1. extract the dummy users with the corresponding gam blah redirect blah ou dummyusers print users command and redirect output to dummyusers.csv

  2. run gam csv dummyusers.csv blah blah gam blah blah

When I'm sure everything works, then I run the command against all users.

Great, I'm glad I was not overlooking some variable/option.

taers232c commented 2 years ago

Should I go ahead and add the maxrows

@.***

On Aug 2, 2022, at 1:53 PM, Jay @.***> wrote:

I do something similar. Say I want to update mail signatures on a 2000 user domain. First, I want to run my gam command on 10 dummy accounts I use for testing.

extract the dummy users with the corresponding gam blah redirect blah ou dummyusers print users command and redirect output to dummyusers.csv

run gam csv dummyusers.csv blah blah gam blah blah

When I'm sure everything works, then I run the command against all users.

Great, I'm glad I was not overlooking some variable/option.

β€” Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/290#issuecomment-1203203891, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYLZMZMRBW2FJ2ZD7G6LVXGDE7ANCNFSM55MMQXEQ. You are receiving this because you commented.

taers232c commented 2 years ago

Jay,

See: https://github.com/taers232c/GAMADV-XTD3/wiki/GamUpdates https://github.com/taers232c/GAMADV-XTD3/wiki/GamUpdates

Ross

@.***

On Aug 2, 2022, at 1:53 PM, Jay @.***> wrote:

I do something similar. Say I want to update mail signatures on a 2000 user domain. First, I want to run my gam command on 10 dummy accounts I use for testing.

extract the dummy users with the corresponding gam blah redirect blah ou dummyusers print users command and redirect output to dummyusers.csv

run gam csv dummyusers.csv blah blah gam blah blah

When I'm sure everything works, then I run the command against all users.

Great, I'm glad I was not overlooking some variable/option.

β€” Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/290#issuecomment-1203203891, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYLZMZMRBW2FJ2ZD7G6LVXGDE7ANCNFSM55MMQXEQ. You are receiving this because you commented.

jay-eleven commented 2 years ago

Hi Ross!

This is awesome, thanks!!!

taers232c commented 2 years ago

Improved, see: https://github.com/taers232c/GAMADV-XTD3/wiki/GamUpdates

@.***

On Aug 3, 2022, at 2:47 AM, Jay @.***> wrote:

Hi Ross!

This is awesome, thanks!!!

β€” Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/290#issuecomment-1203727930, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL2GJCY7QGWOZXZDN4TVXI54NANCNFSM55MMQXEQ. You are receiving this because you commented.