Added option showitemcountonly to gam print domains

This commit is contained in:
Ross Scroggs
2024-07-18 13:19:41 -07:00
parent 752b502399
commit f1e599d535
8 changed files with 52 additions and 15 deletions

View File

@@ -38,7 +38,9 @@ For `info`, if `<DomainName>` is omitted, information about the primary domain w
By default, Gam displays the information as an indented list of keys and values. By default, Gam displays the information as an indented list of keys and values.
* `formatjson` - Display the fields in JSON format. * `formatjson` - Display the fields in JSON format.
``` ```
gam print domains [todrive <ToDriveAttribute>*] [formatjson [quotechar <Character>]] gam print domains
[todrive <ToDriveAttribute>*] [formatjson [quotechar <Character>]]
[showitemcountonly]
``` ```
By default, Gam displays the information as columns of fields. By default, Gam displays the information as columns of fields.
* `formatjson` - Display the fields in JSON format. * `formatjson` - Display the fields in JSON format.
@@ -49,6 +51,12 @@ When using the `formatjson` option, double quotes are used extensively in the da
The `quotechar <Character>` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. The `quotechar <Character>` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output.
`quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. `quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used.
## Display domain counts
Display the number of domains.
```
gam print domains
showitemcountonly
```
## Create and delete domain aliases ## Create and delete domain aliases
``` ```
gam create domainalias|aliasdomain <DomainAlias> <DomainName> gam create domainalias|aliasdomain <DomainAlias> <DomainName>

View File

@@ -10,6 +10,11 @@ Add the `-s` option to the end of the above commands to suppress creating the `g
See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation
### 6.77.17
Added option `showitemcountonly` to `gam print domains` that causes GAM to display the
number of domains on stdout; no CSV file is written.
### 6.77.16 ### 6.77.16
Fixed bug in `gam <UserTypeEntity> print filelist` that caused a trap. Fixed bug in `gam <UserTypeEntity> print filelist` that caused a trap.

View File

@@ -1,7 +1,7 @@
# Updating GAMADV-XTD3 # Updating GAMADV-XTD3
Use these steps to update your version of GAMADV-XTD3. Use these steps to update your version of GAMADV-XTD3.
- [Downloads](Downloads) - [Downloads-Installs](Downloads-Installs)
- [Linux and MacOS and Google Cloud Shell](#linux-and-mac-os-and-google-cloud-shell) - [Linux and MacOS and Google Cloud Shell](#linux-and-mac-os-and-google-cloud-shell)
- [Windows](#windows) - [Windows](#windows)
- [GAM Configuration](gam.cfg) - [GAM Configuration](gam.cfg)

View File

@@ -346,7 +346,7 @@ writes the credentials into the file oauth2.txt.
admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt
admin@server:/Users/admin$ gam version admin@server:/Users/admin$ gam version
WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found
GAMADV-XTD3 6.77.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.17 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -1018,7 +1018,7 @@ writes the credentials into the file oauth2.txt.
C:\>del C:\GAMConfig\oauth2.txt C:\>del C:\GAMConfig\oauth2.txt
C:\>gam version C:\>gam version
WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found
GAMADV-XTD3 6.77.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.17 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
Windows-10-10.0.17134 AMD64 Windows-10-10.0.17134 AMD64

View File

@@ -3,7 +3,7 @@
Print the current version of Gam with details Print the current version of Gam with details
``` ```
gam version gam version
GAMADV-XTD3 6.77.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.17 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00
Print the current version of Gam with details and time offset information Print the current version of Gam with details and time offset information
``` ```
gam version timeoffset gam version timeoffset
GAMADV-XTD3 6.77.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.17 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second
Print the current version of Gam with extended details and SSL information Print the current version of Gam with extended details and SSL information
``` ```
gam version extended gam version extended
GAMADV-XTD3 6.77.16 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource GAMADV-XTD3 6.77.17 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64
@@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3 Path: /Users/Admin/bin/gamadv-xtd3
Version Check: Version Check:
Current: 5.35.08 Current: 5.35.08
Latest: 6.77.16 Latest: 6.77.17
echo $? echo $?
1 1
``` ```
@@ -72,7 +72,7 @@ echo $?
Print the current version number without details Print the current version number without details
``` ```
gam version simple gam version simple
6.77.16 6.77.17
``` ```
In Linux/MacOS you can do: In Linux/MacOS you can do:
``` ```
@@ -82,7 +82,7 @@ echo $VER
Print the current version of Gam and address of this Wiki Print the current version of Gam and address of this Wiki
``` ```
gam help gam help
GAM 6.77.16 - https://github.com/taers232c/GAMADV-XTD3 GAM 6.77.17 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com> Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.4 64-bit final Python 3.12.4 64-bit final
MacOS Sonoma 14.5 x86_64 MacOS Sonoma 14.5 x86_64

View File

@@ -3275,9 +3275,13 @@ gam delete domain <DomainName>
gam info domain [<DomainName>] gam info domain [<DomainName>]
[formatjson] [formatjson]
gam print domains [todrive <ToDriveAttribute>*] gam print domains
[todrive <ToDriveAttribute>*]
[formatjson [quotechar <Character>]] [formatjson [quotechar <Character>]]
gam show domains [formatjson] [showitemcountonly]
gam show domains
[formatjson]
[showitemcountonly]
gam create|add domainalias|aliasdomain <DomainAlias> <DomainName> gam create|add domainalias|aliasdomain <DomainAlias> <DomainName>
gam delete domainalias|aliasdomain <DomainAlias> gam delete domainalias|aliasdomain <DomainAlias>

View File

@@ -2,6 +2,11 @@
Merged GAM-Team version Merged GAM-Team version
6.77.17
Added option `showitemcountonly` to `gam print domains` that causes GAM to display the
number of domains on stdout; no CSV file is written.
6.77.16 6.77.16
Fixed bug in `gam <UserTypeEntity> print filelist` that caused a trap. Fixed bug in `gam <UserTypeEntity> print filelist` that caused a trap.

View File

@@ -16090,18 +16090,33 @@ def doInfoDomain():
DOMAIN_SORT_TITLES = ['domainName', 'parentDomainName', 'creationTime', 'type', 'verified'] DOMAIN_SORT_TITLES = ['domainName', 'parentDomainName', 'creationTime', 'type', 'verified']
# gam print domains [todrive <ToDriveAttribute>*] [formatjson [quotechar <Character>]] # gam print domains [todrive <ToDriveAttribute>*]
# gam show domains [formatjson] # [formatjson [quotechar <Character>]]
# [showitemcountonly]
# gam show domains
# [formatjson]
# [showitemcountonly]
def doPrintShowDomains(): def doPrintShowDomains():
cd = buildGAPIObject(API.DIRECTORY) cd = buildGAPIObject(API.DIRECTORY)
csvPF = CSVPrintFile(['domainName'], DOMAIN_SORT_TITLES) if Act.csvFormat() else None csvPF = CSVPrintFile(['domainName'], DOMAIN_SORT_TITLES) if Act.csvFormat() else None
FJQC = FormatJSONQuoteChar(csvPF) FJQC = FormatJSONQuoteChar(csvPF)
getTodriveFJQCOnly(csvPF, FJQC, True) showItemCountOnly = False
while Cmd.ArgumentsRemaining():
myarg = getArgument()
if csvPF and myarg == 'todrive':
csvPF.GetTodriveParameters()
elif myarg == 'showitemcountonly':
showItemCountOnly = True
else:
FJQC.GetFormatJSONQuoteChar(myarg, True)
try: try:
domains = callGAPIitems(cd.domains(), 'list', 'domains', domains = callGAPIitems(cd.domains(), 'list', 'domains',
throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND, GAPI.FORBIDDEN], throwReasons=[GAPI.BAD_REQUEST, GAPI.NOT_FOUND, GAPI.FORBIDDEN],
customer=GC.Values[GC.CUSTOMER_ID]) customer=GC.Values[GC.CUSTOMER_ID])
count = len(domains) count = len(domains)
if showItemCountOnly:
writeStdout(f'{count}\n')
return
i = 0 i = 0
for domain in domains: for domain in domains:
i += 1 i += 1