Compare commits

...

202 Commits
v6.11 ... v6.15

Author SHA1 Message Date
Jay Lee
4a79b3f42c Update var.py 2022-02-04 09:52:38 -05:00
Jay Lee
6e5052f6ab Update build.yml 2022-02-04 09:21:21 -05:00
Jay Lee
fddaeca050 Merge branch 'main' of https://github.com/GAM-team/GAM 2022-02-03 19:13:06 +00:00
Jay Lee
5b53ba33ab add build_beta 2022-02-03 19:12:29 +00:00
Jay Lee
583fb8d6d2 Update build.yml 2022-02-03 14:10:13 -05:00
Jay Lee
9fa51836c7 remove print debug statement 2022-02-03 19:03:50 +00:00
Jay Lee
6432dd1fef Update build.yml 2022-02-03 13:57:51 -05:00
Jay Lee
341d61444c Allow conditions for admin role assignments 2022-02-03 18:45:35 +00:00
Ross Scroggs
40f71cc703 Update setup.cfg (#1474) 2022-02-02 15:02:38 -05:00
Jay Lee
a8155b9a39 Update gam-install.sh 2022-02-02 14:22:45 -05:00
Jay Lee
f5e9aea2ac [no ci] remove old file 2022-02-02 10:39:10 -05:00
Jay Lee
be41f0ba11 [no ci] remove old file 2022-02-02 10:39:02 -05:00
Jay Lee
f92ca02907 [no ci] remove old file 2022-02-02 10:38:54 -05:00
Jay Lee
7ccddd3d33 [no ci] remove old file 2022-02-02 10:38:41 -05:00
Jay Lee
545c4ec30f [no ci] remove old file 2022-02-02 10:38:32 -05:00
Jay Lee
7aa58c8287 [no ci] update wheel 2022-02-02 10:38:07 -05:00
Jay Lee
32bd11dccc Update build.yml 2022-02-02 10:04:31 -05:00
Jay Lee
1c6488312e [no ci] 7z.exe verbose output 2022-02-02 10:00:32 -05:00
Jay Lee
d767e33da5 [no ci] list installed pip packages and versions 2022-02-02 09:52:01 -05:00
Jay Lee
cee82e7408 [no ci] remove debug lines 2022-02-02 09:33:19 -05:00
Jay Lee
8361a47259 rollback cache since setuptools was issue 2022-02-02 09:15:49 -05:00
Jay Lee
1032421fdd Update build.yml 2022-02-02 08:41:41 -05:00
Jay Lee
17e52e2598 Update build.yml 2022-02-02 08:16:12 -05:00
Jay Lee
4265f86c48 Update resource.py 2022-02-02 07:40:22 -05:00
Jay Lee
f82535c497 Update build.yml 2022-02-01 13:43:43 -05:00
Jay Lee
d25b80ee9c Update build.yml 2022-02-01 13:39:25 -05:00
Jay Lee
0c019d07a2 Update build.yml 2022-02-01 13:08:51 -05:00
Jay Lee
dcaa9c56c0 Update build.yml 2022-02-01 13:02:32 -05:00
Jay Lee
87d45840d9 Update build.yml 2022-02-01 12:57:42 -05:00
Jay Lee
8174aae392 Create package_exclusions.txt 2022-02-01 12:49:20 -05:00
Jay Lee
2a916d1d45 Update build.yml 2022-02-01 09:11:34 -05:00
Jay Lee
b628c34b20 Update build.yml 2022-02-01 09:08:07 -05:00
Jay Lee
f161b165b2 Update build.yml 2022-02-01 09:02:32 -05:00
Jay Lee
316ee693e3 Update build.yml 2022-02-01 08:47:12 -05:00
Jay Lee
82bfb99548 Update build.yml 2022-01-31 10:13:10 -05:00
Jay Lee
ed5ccf1faa Update build.yml 2022-01-31 10:08:54 -05:00
Jay Lee
fd3bec8371 Delete windows-install.sh 2022-01-31 10:05:53 -05:00
Jay Lee
9e2bf9cbbe Update build.yml 2022-01-31 08:08:22 -05:00
Jay Lee
ec198e818a Update build.yml 2022-01-26 21:45:59 -05:00
Jay Lee
aeeba5c668 Update build.yml 2022-01-26 20:28:52 -05:00
Jay Lee
0ca5c74ce7 Update build.yml 2022-01-26 20:28:21 -05:00
Jay Lee
b6c1ad5ce7 Update build.yml 2022-01-26 18:51:07 -05:00
Jay Lee
4c64671cb8 Update build.yml 2022-01-26 17:55:56 -05:00
Jay Lee
7773c49112 Update build.yml 2022-01-26 17:08:49 -05:00
Jay Lee
5e451e4fe3 Update build.yml 2022-01-26 16:21:06 -05:00
Jay Lee
0801ef66a0 Update build.yml 2022-01-26 15:07:33 -05:00
Jay Lee
31f0064e53 Update build.yml 2022-01-26 14:24:01 -05:00
Jay Lee
142191caeb Update build.yml 2022-01-26 14:21:23 -05:00
Jay Lee
d5ee92f12a Update build.yml 2022-01-26 13:46:16 -05:00
Jay Lee
2cd36e6244 Update build.yml 2022-01-26 13:38:52 -05:00
Jay Lee
7b4b637ec3 Update build.yml 2022-01-26 13:29:00 -05:00
Jay Lee
ca931d1caa Update build.yml 2022-01-26 13:18:41 -05:00
Jay Lee
e6773a09c0 Update build.yml 2022-01-26 12:34:18 -05:00
Jay Lee
006b0f1c9d Update build.yml 2022-01-25 21:31:38 -05:00
Jay Lee
14c87f427e Update build.yml 2022-01-25 20:11:50 -05:00
Jay Lee
310cc87a5e Update build.yml 2022-01-25 19:25:15 -05:00
Jay Lee
7533eb0540 Update build.yml 2022-01-25 18:45:27 -05:00
Jay Lee
e5d9a84fc8 Update build.yml 2022-01-25 18:23:05 -05:00
Jay Lee
fb2bb0cb09 Update build.yml 2022-01-25 18:00:01 -05:00
Jay Lee
4a7ce7ebfb Update build.yml 2022-01-25 17:16:52 -05:00
Jay Lee
8eaaabe5da Update build.yml 2022-01-25 16:59:13 -05:00
Jay Lee
f78bdf834d [no ci] verbose cp 2022-01-25 16:40:02 -05:00
Jay Lee
86cc187eed [no ci] verbose mkdir 2022-01-25 16:37:52 -05:00
Jay Lee
9ae4ee1430 Update build.yml 2022-01-25 16:35:02 -05:00
Jay Lee
2a71a0f0be Update build.yml 2022-01-25 15:55:28 -05:00
Jay Lee
b3cf0c1bde Update build.yml 2022-01-25 14:46:33 -05:00
Jay Lee
b4e01737c7 Update build.yml 2022-01-25 14:25:54 -05:00
Jay Lee
8243fe8846 Update build.yml 2022-01-25 14:04:24 -05:00
Jay Lee
44b9a3ca8a Update build.yml 2022-01-25 13:31:08 -05:00
Jay Lee
52becd0255 Update build.yml 2022-01-25 13:29:07 -05:00
Jay Lee
4774227a76 Update build.yml 2022-01-25 13:27:41 -05:00
Jay Lee
faaeeb5f72 Update build.yml 2022-01-25 13:23:35 -05:00
Jay Lee
499eb45064 Update build.yml 2022-01-25 12:50:46 -05:00
Jay Lee
86d2dc725b Update build.yml 2022-01-25 12:47:25 -05:00
Jay Lee
39104183e9 Update build.yml 2022-01-25 12:45:33 -05:00
Jay Lee
ce41283a71 Update build.yml 2022-01-25 12:02:54 -05:00
Jay Lee
ad8aaa1738 Create openssl.props 2022-01-25 12:02:15 -05:00
Jay Lee
7ff381cacf Update build.yml 2022-01-25 11:15:52 -05:00
Jay Lee
e522f76db6 Update build.yml 2022-01-25 11:08:35 -05:00
Jay Lee
106e3544a8 Update build.yml 2022-01-25 10:55:42 -05:00
Jay Lee
704fd3bea8 Update build.yml 2022-01-25 10:52:58 -05:00
Jay Lee
c8f13eedbc Update build.yml 2022-01-25 10:46:59 -05:00
Jay Lee
959cf3d483 Update build.yml 2022-01-25 10:30:00 -05:00
Jay Lee
7d59ceb9d1 Update build.yml 2022-01-25 10:21:40 -05:00
Jay Lee
cdcb071826 Update build.yml 2022-01-25 10:17:17 -05:00
Jay Lee
2829c4c26a Update build.yml 2022-01-25 10:13:45 -05:00
Jay Lee
c810874014 Update build.yml 2022-01-25 10:09:54 -05:00
Jay Lee
e1d9aef2d7 Update gam-install.sh 2022-01-24 10:17:37 -05:00
Jay Lee
71e526370c Delete versionhistory-v1.json 2022-01-23 11:12:03 -05:00
Jay Lee
3c7df4974c [no ci] vh discovery doc is now public, remove local 2022-01-23 11:11:44 -05:00
Janosh Riebesell
f5c95d2ba0 Flynt + shellcheck (#1473)
* quote variables in src/gam-install.sh + fix typos

* flynt src (auto f-string conversion)

* quote all shell variables
2022-01-23 11:08:23 -05:00
Jay Lee
a4f09c02e8 Update gam-install.sh 2022-01-21 14:37:08 -05:00
Jay Lee
be8363786c Update build.yml 2022-01-17 16:34:08 -05:00
Janosh Riebesell
7710711def Pre-commit (#1467)
* pre-commit run trailing-whitespace -a

* pre-commit run end-of-file-fixer -a

* pre-commit run double-quote-string-fixer -a

* pre-commit run requirements-txt-fixer -a

* add pyupgrade hook

* remove pre-commit default_language_version 3.7 (since no upwards incompatible hooks)
2022-01-16 14:23:27 -05:00
Jay Lee
7320136079 Update build.yml 2022-01-15 16:19:00 -05:00
Jay Lee
eaced6942a Update var.py 2022-01-15 14:18:04 -05:00
Ross Scroggs
5411724696 Improve gam user show vaultholds (#1472)
* Improve gam user show vaultholds

* Handle user in /

* Handle user in / more efficiently

* Display total holds, don't set rc, allow uid
2022-01-15 12:24:08 -05:00
Jay Lee
ef3c282bfa Update linux-before-install.sh 2022-01-15 12:23:56 -05:00
Jay Lee
1a1cd223d3 Update linux-before-install.sh 2022-01-15 11:54:18 -05:00
Jay Lee
3d55591436 Update linux-before-install.sh 2022-01-15 11:42:52 -05:00
Jay Lee
b5b9cfe2aa Update build.yml 2022-01-15 11:22:31 -05:00
Ross Scroggs
39db76f189 Four changes (#1471)
* Three changes

Document:
gam <UserTypeEntity> show vaultholds|holds
hidden <Boolean> for update teamsrive

Fix showHoldsForUsers

* Standardize update teamdrive input of orgUnitId

* One too many =
2022-01-15 04:01:09 -05:00
Jay Lee
303e32fe5d Update build.yml 2022-01-14 20:18:50 -05:00
Jay Lee
dd4841c82c Update build.yml 2022-01-14 19:58:28 -05:00
Jay Lee
add970c0ae Update var.py 2022-01-14 15:33:43 -05:00
Jay Lee
7df3e70722 Update README.md 2022-01-14 15:32:25 -05:00
Jay Lee
ea4459b89e Update gam-install.sh 2022-01-14 15:31:06 -05:00
Jay Lee
259c952636 Better error on user delete pre-condition. 2022-01-14 13:50:10 -05:00
Jay Lee
15b1ce370c Show holds for users, hide shared drives 2022-01-14 13:35:06 -05:00
Ross Scroggs
f7ab4aef4e Handle missing descriptions in Chrome polilcies (#1468)
Document Chrome Browser field
2022-01-12 18:00:01 -05:00
Jay Lee
a1e6459dc1 GAM 6.13 2022-01-12 09:23:04 -05:00
Jay Lee
31a3dcd2f7 Update gam.spec 2022-01-12 08:50:29 -05:00
Jay Lee
f0120fef63 Update build.yml 2022-01-11 14:54:03 -05:00
Jay Lee
5095e6af14 Update build.yml 2022-01-11 13:25:35 -05:00
Janosh Riebesell
19f21a9453 pyupgrade --py37-plus **/*.py (#1445) 2022-01-11 11:05:02 -05:00
Jay Lee
676908daca Update build.yml 2022-01-11 09:03:43 -05:00
Jay Lee
66a5d0472d Update build.yml 2022-01-11 08:58:29 -05:00
Jay Lee
cc30e307e9 Update build.yml 2022-01-11 08:47:21 -05:00
Jay Lee
57e3eb5c8e Update macos-before-install.sh 2022-01-11 08:45:07 -05:00
Jay Lee
b855f6876c Update build.yml 2022-01-11 08:41:00 -05:00
Jay Lee
8edc06ba41 Update build.yml 2022-01-11 08:33:42 -05:00
Jay Lee
69aa31566b Update build.yml 2022-01-11 08:23:10 -05:00
Jay Lee
19d3483209 Update build.yml 2022-01-10 12:58:46 -05:00
Jay Lee
c1c7e65a3c Update build.yml 2022-01-10 10:19:39 -05:00
Jay Lee
2d0044de95 Update build.yml 2022-01-10 10:13:54 -05:00
Jay Lee
418e3af903 Update build.yml 2022-01-10 07:05:20 -05:00
Jay Lee
c3ddeae3f3 Make TLS 1.3 the default minimum.
Admins can still downgrade to 1.2 if they need to. Most should not need to.
2022-01-02 14:38:27 -05:00
Jay Lee
a9f0e5ba16 Python 3.6 is EOL, require 3.7 2022-01-02 14:33:04 -05:00
Ross Scroggs
8bf8d45ebe Make gam info crostelemetry <SerialNumber> (#1464)
* Make gam info crostelemetry <SerialNumber>

* Handle missing <SerialNumber> for gam info crostelemetry
2021-12-29 14:48:57 -05:00
Ross Scroggs
1777c762b3 Make print crostelemetry consistent print cros (#1463)
* Make print crostelemetry consistent print cros

Strip newline from cpuStatusReport.cpuTemperature.label
Replace list of label/temperatureCelsius pairs with
cpuStatusReport.cpuTemperature.label = temperaureCelsius

* Document print crostelemetry

* Update GamCommands.txt

* More work on print crostelemetry
2021-12-29 12:23:52 -05:00
Jay Lee
0b1337070e Update gam-install.sh 2021-12-28 12:45:37 -05:00
Jay Lee
b158496bea Update build.yml 2021-12-28 11:16:23 -05:00
Jay Lee
a79b23e090 Update build.yml 2021-12-28 10:55:38 -05:00
Jay Lee
bdb56240f0 Update build.yml 2021-12-28 10:20:45 -05:00
Jay Lee
6dddf3eb30 Update build.yml 2021-12-28 10:20:25 -05:00
Jay Lee
7bd8569151 Update build.yml 2021-12-28 09:57:14 -05:00
Jay Lee
b03c9f1e35 Update build.yml 2021-12-28 09:47:54 -05:00
Jay Lee
057b5ff760 Update build.yml 2021-12-23 13:44:04 -05:00
Jay Lee
ba512b4159 Update build.yml 2021-12-23 13:39:00 -05:00
Jay Lee
a298aea2fe Update build.yml 2021-12-23 13:32:42 -05:00
Jay Lee
f433463074 Update build.yml 2021-12-23 13:24:01 -05:00
Jay Lee
afae08d6fe Update build.yml 2021-12-23 13:16:25 -05:00
Jay Lee
7cf2a08aff Update build.yml 2021-12-23 13:04:22 -05:00
Jay Lee
7df6781985 Update build.yml 2021-12-23 12:39:57 -05:00
Jay Lee
ae0f5e62e3 Update build.yml 2021-12-23 12:36:43 -05:00
Jay Lee
14c8356c6b Update build.yml 2021-12-23 12:23:37 -05:00
Jay Lee
45ffd4a793 Update build.yml 2021-12-23 12:16:37 -05:00
Jay Lee
eb8d39025e Update build.yml 2021-12-23 12:11:36 -05:00
Jay Lee
1f739e1c63 Update build.yml 2021-12-23 09:11:12 -05:00
Jay Lee
82111236fb Update build.yml 2021-12-23 08:32:32 -05:00
Jay Lee
813a94f8d6 Update build.yml 2021-12-23 08:28:15 -05:00
Jay Lee
e83b75e2c3 Update build.yml 2021-12-23 08:24:08 -05:00
Jay Lee
ce1e880ed0 Update build.yml 2021-12-23 08:19:11 -05:00
Jay Lee
427672065e Update build.yml 2021-12-23 07:24:25 -05:00
Jay Lee
055c5d5e54 Update build.yml 2021-12-22 20:22:05 -05:00
Jay Lee
4de7794e04 Update build.yml 2021-12-22 20:18:46 -05:00
Jay Lee
79686fd8ce Update build.yml 2021-12-22 20:06:18 -05:00
Jay Lee
cc5df0198b Update build.yml 2021-12-22 19:43:50 -05:00
Jay Lee
abc6e55ba7 Update build.yml 2021-12-22 19:31:03 -05:00
Jay Lee
0c8afb7fd6 Update build.yml 2021-12-22 19:26:36 -05:00
Jay Lee
c0c2cca44e Update build.yml 2021-12-22 19:01:16 -05:00
Jay Lee
faa645cb97 Update build.yml 2021-12-22 18:59:29 -05:00
Jay Lee
725c19aafc Update build.yml 2021-12-22 18:49:19 -05:00
Jay Lee
cc3b4c974d Update build.yml 2021-12-22 18:45:23 -05:00
Jay Lee
6ce64fad72 Update build.yml 2021-12-22 18:39:01 -05:00
Jay Lee
c1af67d4a3 Update build.yml 2021-12-22 18:35:59 -05:00
Jay Lee
802cb15007 Update requirements.txt 2021-12-22 16:46:04 -05:00
Jay Lee
b34bf3e56a Update linux-before-install.sh 2021-12-22 15:58:08 -05:00
Jay Lee
bf37700088 Update build.yml 2021-12-22 15:55:47 -05:00
Jay Lee
4a43ddfc25 Update build.yml 2021-12-22 15:51:03 -05:00
Jay Lee
650a1f5154 Update build.yml 2021-12-22 15:43:24 -05:00
Jay Lee
5eda7e30b0 Update build.yml 2021-12-22 13:10:09 -05:00
Jay Lee
8a26f547e5 Update build.yml 2021-12-22 10:25:41 -05:00
Jay Lee
343088913f Update build.yml 2021-12-22 09:56:08 -05:00
Jay Lee
5a0272fd5b Merge branch 'main' of github.com:jay0lee/GAM 2021-12-22 09:54:29 -05:00
Jay Lee
dc93503625 CrOS Telemetry API 2021-12-22 09:52:48 -05:00
Ross Scroggs
6ea6c0889b Fix show filelist query issue; add driveId to drive file fields (#1461)
* Fix show filelist query issue

If the user says: query "A or B" this becomes "'me' in owners and A or B" which is the same as "('me' in owners and A) or B" which gives incorrect results. The fix makes "'me' in owners and (A or B)"

* Add driveId to list of drive file fields
2021-12-17 11:51:32 -05:00
Jay Lee
99ab72df3f GAM 6.12 2021-12-16 07:41:30 -05:00
Ross Scroggs
99bda1385e languages update; fields for gam info user; cloud identity groups update to v1 (#1459)
* languages update

The API doesn't return languages unless you specifically mention in in fields list

* languages cleanup in print users

* Add fields to gam info user

* No up for languages

* Use v1 for Cloud Identity groups; fix bug in print cigroups member

* It's an error to set preference on custom language
2021-12-16 07:40:08 -05:00
Jay Lee
7ce3b4a8c0 Update build.yml 2021-12-15 12:06:46 -05:00
Jay Lee
495722d0d6 Update build.yml 2021-12-14 20:20:09 -05:00
Jay Lee
aca31be5d7 Update build.yml 2021-12-14 19:53:11 -05:00
Jay Lee
b9b7ae8d99 Merge branch 'main' of github.com:jay0lee/GAM 2021-12-09 15:27:38 -05:00
Jay Lee
0d46c1d13a Set user preferred language 2021-12-09 15:07:57 -05:00
Ross Scroggs
6b63ecdc19 Add limittoou <OrgUnitPath> to print users to allow selection of OU w/o children (#1455) 2021-12-09 10:35:47 -05:00
Jay Lee
f9ca0323a1 Update build.yml 2021-12-07 08:18:03 -05:00
Jay Lee
c50aa4d2e8 Update build.yml 2021-12-06 16:27:53 -05:00
Jay Lee
a72ded9079 wipe cache 2021-11-24 11:17:41 -05:00
Jay Lee
cbabbee075 wipe cache 2021-11-24 11:15:24 -05:00
Jay Lee
f55a344b7a Update build.yml 2021-11-23 10:48:03 -05:00
Jay Lee
d84f8418ff Update build.yml 2021-11-23 10:39:56 -05:00
Jay Lee
30c5e92de6 Update build.yml 2021-11-23 10:15:54 -05:00
Jay Lee
5f618a7f65 Update build.yml 2021-11-23 08:41:50 -05:00
Jay Lee
3e833419db Update README.md 2021-11-23 08:33:53 -05:00
Jay Lee
0d94bae0b5 Update README.md 2021-11-23 08:33:40 -05:00
Jay Lee
f5dec96ffb Update README.md 2021-11-23 08:31:32 -05:00
Jay Lee
e91d12caaf Update macos-install.sh 2021-11-23 08:26:12 -05:00
Jay Lee
fd5a1faa58 Update gam.spec 2021-11-22 16:31:44 -05:00
Jay Lee
90a9212793 Update build.yml 2021-11-22 16:28:10 -05:00
Jay Lee
7e582ac1fc Update build.yml 2021-11-22 16:19:34 -05:00
Jay Lee
65a740569c Update build.yml 2021-11-22 16:16:28 -05:00
Jay Lee
a47ef0e1f5 Update build.yml 2021-11-22 15:41:05 -05:00
53 changed files with 8917 additions and 1377 deletions

View File

@@ -1,113 +0,0 @@
echo "RUNNING: apt update..."
sudo apt-get -qq --yes update > /dev/null
sudo apt-get -qq --yes install swig libpcsclite-dev
if [[ "$TRAVIS_JOB_NAME" == *"Testing" ]]; then
export python="python"
export pip="pip"
echo "Travis setup Python $TRAVIS_PYTHON_VERSION"
echo "running tests with this version"
else
export whereibelong=$(pwd)
echo "We are running on $ImageOS $ImageVersion"
export LD_LIBRARY_PATH=~/ssl/lib:~/python/lib
cpucount=$(nproc --all)
echo "This device has $cpucount CPUs for compiling..."
SSLVER=$(~/ssl/bin/openssl version)
SSLRESULT=$?
PYVER=$(~/python/bin/python3 -V)
PYRESULT=$?
if [ $SSLRESULT -ne 0 ] || [[ "$SSLVER" != "OpenSSL $BUILD_OPENSSL_VERSION "* ]] || [ $PYRESULT -ne 0 ] || [[ "$PYVER" != "Python $BUILD_PYTHON_VERSION"* ]]; then
echo "SSL Result: $SSLRESULT - SSL Ver: $SSLVER - Py Result: $PYRESULT - Py Ver: $PYVER"
if [ $SSLRESULT -ne 0 ]; then
echo "sslresult -ne 0"
fi
if [[ "$SSLVER" != "OpenSSL $BUILD_OPENSSL_VERSION "* ]]; then
echo "sslver not equal to..."
fi
if [ $PYRESULT -ne 0 ]; then
echo "pyresult -ne 0"
fi
if [[ "$PYVER" != "Python $BUILD_PYTHON_VERSION" ]]; then
echo "pyver not equal to..."
fi
cd ~
rm -rf ssl
rm -rf python
mkdir ssl
mkdir python
echo "RUNNING: apt upgrade..."
sudo apt-mark hold openssh-server
sudo apt-get --yes upgrade
sudo apt-get --yes --with-new-pkgs upgrade
echo "Installing build tools..."
sudo apt-get -qq --yes install build-essential
echo "Installing deps for python3"
sudo cp -v /etc/apt/sources.list /tmp
sudo chmod a+rwx /tmp/sources.list
echo "deb-src http://archive.ubuntu.com/ubuntu/ $TRAVIS_DIST main" >> /tmp/sources.list
sudo cp -v /tmp/sources.list /etc/apt
sudo apt-get -qq --yes update > /dev/null
sudo apt-get -qq --yes build-dep python3 > /dev/null
# Compile latest OpenSSL
wget --quiet https://www.openssl.org/source/openssl-$BUILD_OPENSSL_VERSION.tar.gz
echo "Extracting OpenSSL..."
tar xf openssl-$BUILD_OPENSSL_VERSION.tar.gz
cd openssl-$BUILD_OPENSSL_VERSION
echo "Compiling OpenSSL $BUILD_OPENSSL_VERSION..."
./Configure --libdir=lib --prefix=$HOME/ssl
echo "Running make for OpenSSL..."
make -j$cpucount -s
echo "Running make install for OpenSSL..."
make install > /dev/null
cd ~
# Compile latest Python
echo "Downloading Python $BUILD_PYTHON_VERSION..."
curl -O https://www.python.org/ftp/python/$BUILD_PYTHON_VERSION/Python-$BUILD_PYTHON_VERSION.tar.xz
echo "Extracting Python..."
tar xf Python-$BUILD_PYTHON_VERSION.tar.xz
cd Python-$BUILD_PYTHON_VERSION
echo "Compiling Python $BUILD_PYTHON_VERSION..."
safe_flags="--with-openssl=$HOME/ssl --enable-shared --prefix=$HOME/python --with-ensurepip=upgrade"
unsafe_flags="--enable-optimizations --with-lto --with-openssl=~/ssl --with-openssl-rpath=~~/ssl/lib"
if [ ! -e Makefile ]; then
echo "running configure with safe and unsafe"
./configure $safe_flags $unsafe_flags > /dev/null
fi
#make -j$cpucount PROFILE_TASK="-m test.regrtest --pgo -j$(( $cpucount * 2 ))" -s
make -j$cpucount -s
RESULT=$?
echo "First make exited with $RESULT"
if [ $RESULT != 0 ]; then
echo "Trying Python compile again without unsafe flags..."
make clean
./configure $safe_flags > /dev/null
make -j$cpucount -s
echo "Sticking with safe Python for now..."
fi
echo "Installing Python..."
make install > /dev/null
cd ~
fi
python=~/python/bin/python3
pip=~/python/bin/pip3
if ([ "${ImageOS}" == "ubuntu20" ]) && [ "${HOSTTYPE}" == "x86_64" ]; then
echo "Installing deps for StaticX..."
if [ ! -d patchelf-$PATCHELF_VERSION ]; then
echo "Downloading PatchELF $PATCHELF_VERSION"
wget https://github.com/NixOS/patchelf/archive/$PATCHELF_VERSION.tar.gz
tar xf $PATCHELF_VERSION.tar.gz
cd patchelf-$PATCHELF_VERSION/
./bootstrap.sh
./configure
make
sudo make install
fi
$pip install staticx
fi
cd $whereibelong
fi

View File

@@ -1,34 +0,0 @@
export distpath="dist/"
export gampath="${distpath}gam"
rm -rf $gampath
#mkdir -p $gampath
#export gampath=$(readlink -e $gampath)
$pip install wheel
$python -OO -m PyInstaller --clean --noupx --strip --distpath $gampath gam.spec
export gam="${gampath}/gam"
export GAMVERSION=`$gam version simple`
cp LICENSE $gampath
cp GamCommands.txt $gampath
this_glibc_ver=$(ldd --version | awk '/ldd/{print $NF}')
GAM_ARCHIVE="gam-${GAMVERSION}-${GAMOS}-${PLATFORM}-glibc${this_glibc_ver}.tar.xz"
rm $gampath/lastupdatecheck.txt
# tar will cd to dist and tar up gam/
tar -C ${distpath} --create --file $GAM_ARCHIVE --xz gam
echo "PyInstaller GAM info:"
du -h $gam
time $gam version extended
if ([ "${ImageOS}" == "ubuntu20" ]) && [ "${HOSTTYPE}" == "x86_64" ]; then
GAM_LEGACY_ARCHIVE=gam-${GAMVERSION}-${GAMOS}-${PLATFORM}-legacy.tar.xz
$python -OO -m staticx $gam $gam-staticx
#strip $gam-staticx
rm $gampath/gam
mv $gam-staticx $gam
chmod 755 $gam
rm $gampath/lastupdatecheck.txt
tar -C dist/ --create --file $GAM_LEGACY_ARCHIVE --xz gam
echo "Legacy StaticX GAM info:"
du -h $gam
time $gam version extended
fi
echo "GAM packages:"
ls -l gam-*.tar.xz

View File

@@ -1,132 +0,0 @@
mypath=$HOME
whereibelong=$(pwd)
cpucount=$(sysctl -n hw.ncpu)
echo "This device has $cpucount CPUs for compiling..."
#echo "Brew installing xz..."
#brew install xz > /dev/null
#brew upgrade
brew install coreutils
brew install bash
# prefer standard GNU tools like date over MacOS defaults
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$(brew --prefix)/opt/gnu-tar/libexec/gnubin:$PATH"
date --version
gdate --version
bash --version
cd ~
# Use official Python.org version of Python which is backwards compatible
# with older MacOS versions
export pyfile=python-$BUILD_PYTHON_VERSION-macos11.pkg
wget https://www.python.org/ftp/python/$BUILD_PYTHON_VERSION/$pyfile
echo "installing Python $BUILD_PYTHON_VERSION..."
sudo installer -pkg ./$pyfile -target /
# This fixes https://github.com/pyinstaller/pyinstaller/issues/5062
#codesign --remove-signature /Library/Frameworks/Python.framework/Versions/3.10/Python
#if [ ! -f python-$MIN_PYTHON_VERSION-macosx10.9.pkg ]; then
# wget --quiet https://www.python.org/ftp/python/$MIN_PYTHON_VERSION/python-$MIN_PYTHON_VERSION-macosx10.9.pkg
#fi
#sudo installer -pkg python-$MIN_PYTHON_VERSION-macosx10.9.pkg -target /
#brew install openssl@1.1
#brew upgrade python
#export python=python3
#export pip=pip3
#echo "Python location:"
#which $python
cd ~
#export LD_LIBRARY_PATH=~/ssl/lib:~/python/lib
#export openssl=~/ssl/bin/openssl
#export python=~/python/bin/python3
#export pip=~/python/bin/pip3
export python=/usr/local/bin/python3
export pip=/usr/local/bin/pip3
SSLVER=$($openssl version)
SSLRESULT=$?
PYVER=$($python -V)
PYRESULT=$?
brew install swig
$pip install pyscard
#wget --quiet https://www.python.org/ftp/python/$BUILD_PYTHON_VERSION/python-$BUILD_PYTHON_VERSION-macosx10.9.pkg
#if [ $SSLRESULT -ne 0 ] || [[ "$SSLVER" != "OpenSSL $BUILD_OPENSSL_VERSION "* ]] || [ $PYRESULT -ne 0 ] || [[ "$PYVER" != "Python $BUILD_PYTHON_VERSION"* ]]; then
# echo "SSL Result: $SSLRESULT - SSL Ver: $SSLVER - Py Result: $PYRESULT - Py Ver: $PYVER"
# if [ $SSLRESULT -ne 0 ]; then
# echo "sslresult -ne 0"
# fi
# if [[ "$SSLVER" != "OpenSSL $BUILD_OPENSSL_VERSION "* ]]; then
# echo "sslver not equal to..."
# fi
# if [ $PYRESULT -ne 0 ]; then
# echo "pyresult -ne 0"
# fi
# if [[ "$PYVER" != "Python $BUILD_PYTHON_VERSION" ]]; then
# echo "pyver not equal to..."
# fi
# Start clean
# rm -rf python
# rm -rf ssl
# mkdir python
# mkdir ssl
# Compile latest OpenSSL
# wget --quiet https://www.openssl.org/source/openssl-$BUILD_OPENSSL_VERSION.tar.gz
# echo "Extracting OpenSSL..."
# tar xf openssl-$BUILD_OPENSSL_VERSION.tar.gz
# cd openssl-$BUILD_OPENSSL_VERSION
# echo "Compiling OpenSSL $BUILD_OPENSSL_VERSION..."
# ./config shared --prefix=$HOME/ssl
# echo "Running make for OpenSSL..."
# make -j$cpucount -s
# echo "Running make install for OpenSSL..."
# make install > /dev/null
# cd ~
# Compile latest Python
# echo "Downloading Python $BUILD_PYTHON_VERSION..."
# curl -O https://www.python.org/ftp/python/$BUILD_PYTHON_VERSION/Python-$BUILD_PYTHON_VERSION.tar.xz
# echo "Extracting Python..."
# tar xf Python-$BUILD_PYTHON_VERSION.tar.xz
# cd Python-$BUILD_PYTHON_VERSION
# echo "Compiling Python $BUILD_PYTHON_VERSION..."
# safe_flags="--with-openssl=$HOME/ssl --enable-shared --prefix=$HOME/python --with-ensurepip=upgrade"
# unsafe_flags="--enable-optimizations --with-lto"
# if [ ! -e Makefile ]; then
# echo "running configure with safe and unsafe"
# ./configure $safe_flags $unsafe_flags > /dev/null
# fi
# make -j$cpucount PROFILE_TASK="-m test.regrtest --pgo -j$(( $cpucount * 2 ))" -s
# RESULT=$?
# echo "First make exited with $RESULT"
# if [ $RESULT != 0 ]; then
# echo "Trying Python compile again without unsafe flags..."
# make clean
# ./configure $safe_flags > /dev/null
# make -j$cpucount -s
# echo "Sticking with safe Python for now..."
# fi
# echo "Installing Python..."
# make install > /dev/null
# cd ~
#fi
$python -V
cd $whereibelong

View File

@@ -1,19 +0,0 @@
echo "MacOS Version Info According to Python:"
macver=$(python -c "import platform; print(platform.mac_ver()[0])")
echo $macver
echo "Xcode version:"
xcodebuild -version
export distpath="dist/"
export gampath="${distpath}gam"
rm -rf $gampath
export specfile="gam.spec"
$python -OO -m PyInstaller --clean --noupx --strip --distpath "${gampath}" --target-architecture $PLATFORM "${specfile}"
export gam="${gampath}/gam"
$gam version extended
export GAMVERSION=`$gam version simple`
cp LICENSE "${gampath}"
cp GamCommands.txt "${gampath}"
GAM_ARCHIVE="gam-${GAMVERSION}-${GAMOS}-${PLATFORM}.tar.xz"
rm "${gampath}/lastupdatecheck.txt"
# tar will cd to dist/ and tar up gam/
tar -C dist/ --create --file $GAM_ARCHIVE --xz gam

View File

@@ -0,0 +1,7 @@
oauth2.txt
nobrowser.txt
enabledasa.txt
lastupdatecheck.txt
*.json
*.lck
*.csv

View File

@@ -1,57 +0,0 @@
if [[ "$PLATFORM" == "x86_64" ]]; then
export BITS="64"
export PYTHONFILE_BITS="-amd64"
export OPENSSL_BITS="-x64"
elif [[ "$PLATFORM" == "x86" ]]; then
export BITS="32"
export PYTHONFILE_BITS=""
export OPENSSL_BITS=""
export CHOCOPTIONS="--forcex86"
fi
echo "This is a ${BITS}-bit build for ${PLATFORM}"
export mypath=$(pwd)
cd ~
export python="c:\python\python.exe"
export pip="c:\python\scripts\pip.exe"
# pyscard needs swig, keep these two together
choco install $CHOCOPTIONS swig
$pip install pyscard
# Python
#echo "Installing Python..."
#export python_file=python-${BUILD_PYTHON_VERSION}${PYTHONFILE_BITS}.exe
#if [ ! -e $python_file ]; then
# echo "Downloading $python_file..."
# curl -O https://www.python.org/ftp/python/$BUILD_PYTHON_VERSION/$python_file
#fi
#until ./${python_file} /quiet InstallAllUsers=1 TargetDir=c:\\python; do echo "trying python again..."; done
#export python=/c/python/python.exe
#export pip=/c/python/scripts/pip.exe
#until [ -f $python ]; do sleep 1; done
#export PATH=$PATH:/c/python/scripts
# OpenSSL
#echo "Installing OpenSSL..."
#export exefile=Win${BITS}OpenSSL_Light-${BUILD_OPENSSL_VERSION//./_}.exe
#if [ ! -e $exefile ]; then
# echo "Downloading $exefile..."
# curl -O https://slproweb.com/download/$exefile
#fi
#until ./${exefile} /silent /sp- /suppressmsgboxes /DIR=C:\\ssl; do echo "trying openssl again..."; done
#until cp -v /c/ssl/libcrypto-1_1${OPENSSL_BITS}.dll /c/python/DLLs/; do echo "trying libcrypto copy again..."; sleep 3; done
#until cp -v /c/ssl/libssl-1_1${OPENSSL_BITS}.dll /c/python/DLLs/; do echo "trying libssl copy again..."; done
#if [[ "$PLATFORM" == "x86_64" ]]; then
# cp -v /c/python/DLLs/libssl-1_1-x64.dll /c/python/DLLs/libssl-1_1.dll
# cp -v /c/python/DLLs/libcrypto-1_1-x64.dll /c/python/DLLs/libcrypto-1_1.dll
#fi
cd $mypath
echo "PATH: $PATH"
cd ..
$python setup.py install
echo "cd to $mypath"
cd $mypath

View File

@@ -1,31 +0,0 @@
if [[ "$PLATFORM" == "x86_64" ]]; then
export WIX_BITS="x64"
elif [[ "$PLATFORM" == "x86" ]]; then
export WIX_BITS="x86"
fi
echo "compiling GAM with pyinstaller..."
export distpath="dist/"
export gampath="${distpath}gam"
rm -rf $gampath
/c/python/scripts/pyinstaller --clean --noupx --distpath $gampath gam.spec
export gam="${gampath}/gam"
echo "running compiled GAM..."
$gam version
export GAMVERSION=$($gam version simple)
rm $gampath/lastupdatecheck.txt
cp LICENSE $gampath
cp GamCommands.txt $gampath
cp gam-setup.bat $gampath
GAM_ARCHIVE=gam-$GAMVERSION-$GAMOS-$PLATFORM.zip
cwd=$(pwd)
cd "${distpath}"
/c/Program\ Files/7-Zip/7z.exe a -tzip $GAM_ARCHIVE gam -xr!.svn
mv "${GAM_ARCHIVE}" "${cwd}"
cd "${cwd}"
echo "Running WIX candle $WIX_BITS..."
/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/candle.exe -arch $WIX_BITS gam.wxs
echo "Done with WIX candle..."
echo "Running WIX light..."
/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/light.exe -ext /c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/WixUIExtension.dll gam.wixobj -o gam-$GAMVERSION-$GAMOS-$PLATFORM.msi || true;
echo "Done with WIX light..."
rm *.wixpdb

View File

@@ -12,13 +12,11 @@ defaults:
working-directory: src
env:
BUILD_PYTHON_VERSION: "3.10.0"
MIN_PYTHON_VERSION: "3.10.0"
BUILD_OPENSSL_VERSION: "3.0.0"
MIN_OPENSSL_VERSION: "1.1.1l"
PATCHELF_VERSION: "0.13"
# PYINSTALLER_VERSION can be full commit hash or version like v4.20
PYINSTALLER_VERSION: "6eae2c7cf93a968ddc054339e0cb3063f90d0e64"
OPENSSL_CONFIG_OPTS: no-asm no-fips
OPENSSL_INSTALL_PATH: ${{ github.workspace }}/src/ssl
OPENSSL_SOURCE_PATH: ${{ github.workspace }}/src/openssl
PYTHON_INSTALL_PATH: ${{ github.workspace }}/src/python
PYTHON_SOURCE_PATH: ${{ github.workspace }}/src/cpython
jobs:
build:
@@ -26,57 +24,45 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-18.04
jid: 1
goal: "build"
gamos: "linux"
platform: "x86_64"
- os: ubuntu-20.04
jid: 2
goal: "build"
gamos: "linux"
platform: "x86_64"
- os: macos-11.0
goal: build
arch: x86_64
- os: macos-11
jid: 3
goal: "build"
gamos: "macos"
platform: "universal2"
- os: windows-2019
goal: build
arch: x86_64
- os: windows-2022
jid: 4
goal: "build"
gamos: "windows"
pyarch: "x64"
platform: "x86_64"
- os: windows-2019
goal: build
arch: Win64
- os: windows-2022
jid: 5
goal: "build"
gamos: "windows"
platform: "x86"
pyarch: "x86"
goal: build
arch: Win32
- os: ubuntu-20.04
goal: "test"
python: "3.6"
jid: 6
gamos: "linux"
platform: "x86_64"
- os: ubuntu-20.04
goal: "test"
goal: test
python: "3.7"
jid: 7
gamos: "linux"
platform: "x86_64"
jid: 6
arch: x86_64
- os: ubuntu-20.04
goal: "test"
goal: test
python: "3.8"
jid: 8
gamos: "linux"
platform: "x86_64"
jid: 7
arch: x86_64
- os: ubuntu-20.04
goal: test
python: "3.9"
jid: 8
arch: x86_64
- os: [self-hosted, linux, arm64]
jid: 9
gamos: linux
platform: x86_64
goal: build
arch: aarch64
- os: [self-hosted, linux, arm]
jid: 10
goal: build
arch: armv7l
steps:
@@ -87,148 +73,383 @@ jobs:
- name: Cache multiple paths
uses: actions/cache@v2
if: matrix.goal != 'test'
id: cache-python-ssl
with:
path: |
~/python
~/ssl
key: ${{ matrix.os }}-${{ matrix.jid }}-20211122
- name: Set env variables
env:
GAMOS: ${{ matrix.gamos }}
GOAL: ${{ matrix.goal }}
JID: ${{ matrix.jid }}
PLATFORM: ${{ matrix.platform }}
run: |
echo "GAMOS=${GAMOS}" >> $GITHUB_ENV
echo "GOAL=${GOAL}" >> $GITHUB_ENV
echo "JID=${JID}" >> $GITHUB_ENV
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
uname -a
src/python
src/ssl
key: gam-${{ matrix.jid }}-20220131
- name: Use pre-compiled Python for testing
if: matrix.python != ''
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.pyarch }}
- name: Install Python on Windows
if: matrix.os == 'windows-2019'
run: |
if ( ${Env:PLATFORM} -eq "x86_64" )
{
Set-Variable -name py_arch -value "-amd64"
}
else
{
Set-Variable -name py_arch -value ""
}
Write-Output "py_arch: $py_arch"
Set-Variable -name python_file -value "python-${Env:BUILD_PYTHON_VERSION}${py_arch}.exe"
Write-Output "python_file: $python_file"
Set-Variable -name python_url -value "https://www.python.org/ftp/python/${Env:BUILD_PYTHON_VERSION}/${python_file}"
Write-Output "python_url: $python_url"
Invoke-WebRequest -Uri $python_url -OutFile $python_file
Start-Process -wait -FilePath $python_file -ArgumentList "/quiet","InstallAllUsers=0","TargetDir=c:\\python","AssociateFiles=1","PrependPath=1"
shell: pwsh
- name: Set env variables for pre-compiled Python
- name: Set env variables for test
if: matrix.goal == 'test'
env:
JID: ${{ matrix.jid }}
ACTIONS_CACHE: ${{ steps.cache-python-ssl.outputs.cache-hit }}
ACTIONS_GOAL: ${{ matrix.goal }}
run: |
export python=$(which python3)
export pip=$(which pip3)
export gam="${python} -m gam"
export PYTHON=$(which python3)
export PIP=$(which pip3)
export gam="${PYTHON} -m gam"
export gampath="$(readlink -e .)"
echo -e "python: $python\npip: $pip\ngam: $gam\ngampath: $gampath"
echo "python=${python}" >> $GITHUB_ENV
echo "pip=${pip}" >> $GITHUB_ENV
echo -e "PYTHON: ${PYTHON}\nPIP: ${PIP}\gam: ${gam}\ngampath: ${gampath}"
echo "PYTHON=${PYTHON}" >> $GITHUB_ENV
echo "PIP=${PIP}" >> $GITHUB_ENV
echo "gam=${gam}" >> $GITHUB_ENV
echo "gampath=${gampath}" >> $GITHUB_ENV
echo "RUNNING: apt update..."
sudo apt-get -qq --yes update > /dev/null
sudo apt-get -qq --yes install swig libpcsclite-dev
$pip install --upgrade pip
echo "JID=${JID}" >> $GITHUB_ENV
echo "ACTIONS_CACHE=${ACTIONS_CACHE}" >> $GITHUB_ENV
echo "ACTIONS_GOAL=${ACTIONS_GOAL}" >> $GITHUB_ENV
echo "date=date" >> $GITHUB_ENV
- name: Build and install Python, OpenSSL and PyInstaller
if: matrix.goal != 'test' && steps.cache-primes.outputs.cache-hit != 'true'
- name: Install necessary hosted Linux packages
if: matrix.os == 'ubuntu-20.04'
run: |
set +e
source ../.github/actions/${GAMOS}-before-install.sh
echo "PATH=$PATH" >> $GITHUB_ENV # keep gnutools for MacOS
echo "python=$python" >> $GITHUB_ENV
echo "pip=$pip" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo -e "Python: $python\nPip: $pip\nLD_LIB...: $LD_LIBRARY_PATH"
$pip install --upgrade pip
$pip install wheel
export url="https://codeload.github.com/pyinstaller/pyinstaller/tar.gz/${PYINSTALLER_VERSION}"
echo "Downloading ${url}"
curl -o pyinstaller.tar.gz --compressed "${url}"
tar xf pyinstaller.tar.gz
cd "pyinstaller-${PYINSTALLER_VERSION}/"
if [ $GAMOS == "windows" ]; then
# remove pre-compiled bootloaders so we fail if bootloader compile fails
rm -rf PyInstaller/bootloader/*bit
cd bootloader
if [ "${PLATFORM}" == "x86" ]; then
TARGETARCH="--target-arch=32bit"
else
TARGETARCH=""
fi
$python ./waf all $TARGETARCH
cd ..
fi
$pip install .
#$python setup.py install
#$pip install pyinstaller
echo "RUNNING: apt update..."
sudo apt-get -qq --yes update
sudo apt-get -qq --yes install swig libpcsclite-dev
- name: Windows Configure VCode
uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
with:
arch: ${{ matrix.arch }}
- name: Set Env Variables for build
if: matrix.goal == 'build'
env:
arch: ${{ matrix.arch }}
jid: ${{ matrix.jid }}
run: |
echo "We are running on ${RUNNER_OS}"
if [[ "${arch}" == "Win64" ]]; then
PYEXTERNALS_PATH="amd64"
PYBUILDRELEASE_ARCH="x64"
OPENSSL_CONFIG_TARGET="VC-WIN64A"
GAM_ARCHIVE_ARCH="x86_64"
WIX_ARCH="x64"
CHOC_OPS=""
elif [[ "${arch}" == "Win32" ]]; then
PYEXTERNALS_PATH="win32"
PYBUILDRELEASE_ARCH="Win32"
OPENSSL_CONFIG_TARGET="VC-WIN32"
GAM_ARCHIVE_ARCH="x86"
WIX_ARCH="x86"
CHOC_OPS="--forcex86"
fi
if [[ "${RUNNER_OS}" == "macOS" ]]; then
brew install coreutils
brew install bash
MAKE=make
MAKEOPT="-j$(sysctl -n hw.logicalcpu)"
PERL=perl
# We only care about non-deprecated OSes
MACOSX_DEPLOYMENT_TARGET="10.15"
echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
echo "PYTHON=${PYTHON_INSTALL_PATH}/bin/python3" >> $GITHUB_ENV
export date=gdate
export realpath=grealpath
elif [[ "${RUNNER_OS}" == "Linux" ]]; then
MAKE=make
MAKEOPT="-j$(nproc)"
PERL=perl
echo "PYTHON=${PYTHON_INSTALL_PATH}/bin/python3" >> $GITHUB_ENV
export date=date
export realpath=realpath
elif [[ "${RUNNER_OS}" == "Windows" ]]; then
MAKE=nmake
MAKEOPT=""
PERL="c:\strawberry\perl\bin\perl.exe"
echo "PYTHON=${PYTHON_INSTALL_PATH}\python.exe" >> $GITHUB_ENV
export date=date
export realpath=realpath
echo "GAM_ARCHIVE_ARCH=${GAM_ARCHIVE_ARCH}" >> $GITHUB_ENV
echo "WIX_ARCH=${WIX_ARCH}" >> $GITHUB_ENV
fi
echo "date=${date}" >> $GITHUB_ENV
echo "realpath=${realpath}" >> $GITHUB_ENV
echo "We'll run make with: ${MAKEOPT}"
echo "JID=${jid}" >> $GITHUB_ENV
echo "arch=${arch}" >> $GITHUB_ENV
echo "MAKE=${MAKE}" >> $GITHUB_ENV
echo "MAKEOPT=${MAKEOPT}" >> $GITHUB_ENV
echo "PERL=${PERL}" >> $GITHUB_ENV
echo "PYEXTERNALS_PATH=${PYEXTERNALS_PATH}" >> $GITHUB_ENV
echo "PYBUILDRELEASE_ARCH=${PYBUILDRELEASE_ARCH}" >> $GITHUB_ENV
echo "OPENSSL_CONFIG_TARGET=${OPENSSL_CONFIG_TARGET}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${OPENSSL_INSTALL_PATH}/lib:${PYTHON_INSTALL_PATH}/lib" >> $GITHUB_ENV
#echo "PATH=${PATH}:${PYTHON_INSTALL_PATH}/scripts" >> $GITHUB_ENV
- name: Get latest stable OpenSSL source
if: matrix.goal == 'build' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
git clone https://github.com/openssl/openssl.git
cd "${OPENSSL_SOURCE_PATH}"
export LATEST_STABLE_TAG=$(git tag --list openssl-* | grep -v alpha | grep -v beta | sort -Vr | head -n1)
echo "Checking out version ${LATEST_STABLE_TAG}"
git checkout "${LATEST_STABLE_TAG}"
export COMPILED_OPENSSL_VERSION=${LATEST_STABLE_TAG:8} # Trim the openssl- prefix
echo "COMPILED_OPENSSL_VERSION=${COMPILED_OPENSSL_VERSION}" >> $GITHUB_ENV
- name: Windows NASM Install
uses: ilammy/setup-nasm@v1
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
- name: Config OpenSSL
if: matrix.goal == 'build' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
cd "${OPENSSL_SOURCE_PATH}"
# --libdir=lib is needed so Python can find OpenSSL libraries
"${PERL}" ./Configure "${OPENSSL_CONFIG_TARGET}" --libdir=lib --prefix="${OPENSSL_INSTALL_PATH}" $OPENSSL_CONFIG_OPTS
- name: Rename GNU link on Windows
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
shell: bash
run: mv /usr/bin/link /usr/bin/gnulink
- name: Make OpenSSL
if: matrix.goal == 'build' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
cd "${OPENSSL_SOURCE_PATH}"
$MAKE "${MAKEOPT}"
- name: Install OpenSSL
if: matrix.goal == 'build' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
cd "${OPENSSL_SOURCE_PATH}"
# install_sw saves us ages processing man pages :-)
$MAKE install_sw
- name: Run OpenSSL
if: matrix.goal == 'build'
run: |
"${OPENSSL_INSTALL_PATH}/bin/openssl" version
- name: Get latest stable Python source
if: matrix.goal == 'build' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
git clone https://github.com/python/cpython.git
cd "${PYTHON_SOURCE_PATH}"
export LATEST_STABLE_TAG=$(git tag --list | grep -v a | grep -v rc | grep -v b | sort -Vr | head -n1)
git checkout "${LATEST_STABLE_TAG}"
export COMPILED_PYTHON_VERSION=${LATEST_STABLE_TAG:1} # Trim the "v" prefix
echo "COMPILED_PYTHON_VERSION=${COMPILED_PYTHON_VERSION}" >> $GITHUB_ENV
- name: Mac/Linux Configure Python
if: matrix.goal == 'build' && matrix.os != 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
cd "${PYTHON_SOURCE_PATH}"
./configure --with-openssl="${OPENSSL_INSTALL_PATH}" \
--prefix="${PYTHON_INSTALL_PATH}" \
--enable-shared \
--with-ensurepip=upgrade \
--enable-optimizations \
--with-lto
- name: Windows Get External Python deps
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
shell: powershell
run: |
cd "${env:PYTHON_SOURCE_PATH}"
PCBuild\get_externals.bat
- name: Windows overwrite external OpenSSL with local
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
shell: powershell
run: |
cd "${env:PYTHON_SOURCE_PATH}"
$env:OPENSSL_EXT_PATH = "$(Get-Item externals\openssl-bin-* | Select -exp FullName)\"
echo "External OpenSSL was downloaded to ${env:OPENSSL_EXT_PATH}"
Remove-Item -recurse -force "${env:OPENSSL_EXT_PATH}*"
# Emulate what this script does:
# https://github.com/python/cpython/blob/main/PCbuild/openssl.vcxproj
$env:OPENSSL_EXT_TARGET_PATH = "${env:OPENSSL_EXT_PATH}${env:PYEXTERNALS_PATH}"
echo "Copying our OpenSSL to ${env:OPENSSL_EXT_TARGET_PATH}"
mkdir "${env:OPENSSL_EXT_TARGET_PATH}\include\openssl\"
Copy-Item -Path "${env:OPENSSL_SOURCE_PATH}\LICENSE.txt" -Destination "${env:OPENSSL_EXT_TARGET_PATH}\LICENSE"
cp -v "$env:OPENSSL_INSTALL_PATH\lib\*" "${env:OPENSSL_EXT_TARGET_PATH}"
cp -v "$env:OPENSSL_INSTALL_PATH\bin\*" "${env:OPENSSL_EXT_TARGET_PATH}"
cp -v "$env:OPENSSL_INSTALL_PATH\include\openssl\*" "${env:OPENSSL_EXT_TARGET_PATH}\include\openssl\"
cp -v "$env:OPENSSL_INSTALL_PATH\include\openssl\applink.c" "${env:OPENSSL_EXT_TARGET_PATH}\include\"
- name: Windows Install sphinx-build
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
shell: powershell
run: |
pip install --upgrade pip
pip install --upgrade sphinx
sphinx-build --version
- name: Windows Config/Build Python
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
shell: powershell
run: |
cd "${env:PYTHON_SOURCE_PATH}"
# We need out custom openssl.props which uses OpenSSL 3 DLL names
Copy-Item -Path "${env:GITHUB_WORKSPACE}\src\tools\openssl.props" -Destination PCBuild\
echo "Building for ${env:PYBUILDRELEASE_ARCH}..."
PCBuild\build.bat -m --pgo -c Release -p "${env:PYBUILDRELEASE_ARCH}"
- name: Windows Install Python
if: matrix.goal == 'build' && matrix.os == 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
shell: powershell
run: |
cd "${env:PYTHON_SOURCE_PATH}"
mkdir "${env:PYTHON_INSTALL_PATH}\lib"
mkdir "${env:PYTHON_INSTALL_PATH}\include"
Copy-Item -Path "PCBuild\${env:PYEXTERNALS_PATH}\*" "${env:PYTHON_INSTALL_PATH}\"
Copy-Item -Path "${env:PYTHON_SOURCE_PATH}\Lib\*" "${env:PYTHON_INSTALL_PATH}\lib\" -recurse
Copy-Item -Path "${env:PYTHON_SOURCE_PATH}\Include\*" "${env:PYTHON_INSTALL_PATH}\include\" -recurse
Copy-Item -Path "${env:PYTHON_SOURCE_PATH}\PC\*.h" "${env:PYTHON_INSTALL_PATH}\include\"
- name: Mac/Linux Build Python
if: matrix.goal == 'build' && matrix.os != 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
cd "${PYTHON_SOURCE_PATH}"
echo "Running: ${MAKE} ${MAKEOPT}"
$MAKE $MAKEOPT
- name: Mac/Linux Install Python
if: matrix.goal == 'build' && matrix.os != 'windows-2022' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
cd "${PYTHON_SOURCE_PATH}"
$MAKE altinstall
$MAKE bininstall
- name: Run Python
run: |
"${PYTHON}" -V
- name: Upgrade pip, wheel, etc
run: |
curl -O https://bootstrap.pypa.io/get-pip.py
"${PYTHON}" get-pip.py
"${PYTHON}" -m pip install --upgrade pip
"${PYTHON}" -m pip install --upgrade wheel
"${PYTHON}" -m pip install --upgrade setuptools
- name: Install PyInstaller
if: matrix.goal == 'build'
run: |
git clone https://github.com/pyinstaller/pyinstaller.git
cd pyinstaller
export latest_release=$(git tag --list | grep -v dev | grep -v rc | sort -Vr | head -n1)
git checkout "${latest_release}"
# remove pre-compiled bootloaders so we fail if bootloader compile fails
rm -rvf PyInstaller/bootloader/*-*/*
cd bootloader
if [[ "${arch}" == "Win32" ]]; then
export PYINSTALLER_BUILD_ARGS="--target-arch=32bit"
fi
echo "PyInstaller build arguments: ${PYINSTALLER_BUILD_ARGS}"
"${PYTHON}" ./waf all $PYINSTALLER_BUILD_ARGS
cd ..
"${PYTHON}" -m pip install .
- name: Install pip requirements
if: matrix.os != 'self-hosted'
run: |
set +e
$pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 $pip install -U --force-reinstall
$pip install --upgrade -r requirements.txt
"${PYTHON}" -m pip install --upgrade -r requirements.txt
"${PYTHON}" -m pip list
- name: Build GAM with PyInstaller
if: matrix.goal != 'test'
run: |
set +e
source ../.github/actions/${GAMOS}-install.sh
ls -alRF $gampath
echo "gampath=$gampath" >> $GITHUB_ENV
echo "gam=$gam" >> $GITHUB_ENV
echo -e "GAM: ${gam}\nGAMPATH: ${gampath}\nGAMVERSION: ${GAMVERSION}"
export gampath="./dist/gam"
mkdir -p -v "${gampath}"
export gampath="$($realpath $gampath)"
export gam="${gampath}/gam"
echo "gampath=${gampath}" >> $GITHUB_ENV
echo "gam=${gam}" >> $GITHUB_ENV
echo -e "GAM: ${gam}\nGAMPATH: ${gampath}"
"${PYTHON}" -m PyInstaller --clean --noupx --strip --onefile --distpath="${gampath}" gam.spec
- name: Basic Tests all jobs
run: |
echo -e "python: $python\npip: $pip\ngam: $gam\ngampath: $gampath\n"
$python -m unittest discover --start-directory ./ --pattern "*_test.py" --buffer
touch "${gampath}/nobrowser.txt"
$PYTHON -m unittest discover --start-directory ./ --pattern "*_test.py" --buffer
$gam version extended
export GAMVERSION=$($gam version simple)
echo "GAM Version ${GAMVERSION}"
echo "GAMVERSION=${GAMVERSION}" >> $GITHUB_ENV
- name: Basic Tests build jobs only
if: matrix.goal != 'test'
- name: Linux/MacOS package
if: matrix.os != 'windows-2022' && matrix.goal == 'build'
run: |
$pip install packaging
export vline=$($gam version | grep "Python ")
export python_line=($vline)
export this_python=${python_line[1]}
$python tools/a_atleast_b.py "${this_python}" "${MIN_PYTHON_VERSION}"
export vline=$($gam version extended | grep "OpenSSL ")
export openssl_line=($vline)
export this_openssl="${openssl_line[1]}"
$python tools/a_atleast_b.py "${this_openssl}" "${MIN_OPENSSL_VERSION}"
cp -v LICENSE $gampath
cp -v GamCommands.txt $gampath
if [[ "${RUNNER_OS}" == "macOS" ]]; then
GAM_ARCHIVE="gam-${GAMVERSION}-macos-x86_64.tar.xz"
elif [[ "${RUNNER_OS}" == "Linux" ]]; then
this_glibc_ver=$(ldd --version | awk '/ldd/{print $NF}')
GAM_ARCHIVE="gam-${GAMVERSION}-linux-$(arch)-glibc${this_glibc_ver}.tar.xz"
fi
tar -C dist/ --create --verbose --exclude-from "${GITHUB_WORKSPACE}/.github/actions/package_exclusions.txt" --file $GAM_ARCHIVE --xz gam
- name: Linux install patchelf/staticx
if: matrix.os == 'ubuntu-20.04' && matrix.goal != 'test'
run: |
"${PYTHON}" -m pip install --upgrade patchelf-wrapper
"${PYTHON}" -m pip install --upgrade staticx
- name: Linux Make Static
if: matrix.os == 'ubuntu-20.04' && matrix.goal != 'test'
run: |
$PYTHON -m staticx "${gam}" "${gam}-staticx"
- name: Linux Run StaticX-ed
if: matrix.os == 'ubuntu-20.04' && matrix.goal != 'test'
run: |
"${gam}-staticx" version extended
mv -v "${gam}-staticx" "${gam}"
- name: Linux package staticx
if: matrix.os == 'ubuntu-20.04' && matrix.goal != 'test'
run: |
GAM_ARCHIVE="gam-${GAMVERSION}-linux-x86_64-legacy.tar.xz"
tar -C dist/ --create --verbose --exclude-from "${GITHUB_WORKSPACE}/.github/actions/package_exclusions.txt" --file $GAM_ARCHIVE --xz gam
- name: Windows package
if: matrix.os == 'windows-2022' && matrix.goal != 'test'
run: |
cp -v LICENSE $gampath
cp -v GamCommands.txt $gampath
cp -v gam-setup.bat $gampath
cd dist/
GAM_ARCHIVE="../gam-${GAMVERSION}-windows-${GAM_ARCHIVE_ARCH}.zip"
/c/Program\ Files/7-Zip/7z.exe a -tzip $GAM_ARCHIVE gam "-xr@${GITHUB_WORKSPACE}/.github/actions/package_exclusions.txt" -bb3
cd ..
/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/candle.exe -arch "${WIX_ARCH}" gam.wxs
/c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/light.exe -ext /c/Program\ Files\ \(x86\)/WiX\ Toolset\ v3.11/bin/WixUIExtension.dll gam.wixobj -o "gam-${GAMVERSION}-windows-${GAM_ARCHIVE_ARCH}.msi" || true;
rm -v -f *.wixpdb
- name: Basic Tests build jobs only
if: matrix.goal != 'test' && steps.cache-python-ssl.outputs.cache-hit != 'true'
run: |
export voutput=$($gam version extended)
export python_line=$(echo -e "${voutput}" | grep "Python ")
export python_arr=($python_line)
export this_python=${python_arr[1]}
if [[ "${this_python}" != "${COMPILED_PYTHON_VERSION}" ]]; then
echo "ERROR: Tried to compile Python ${COMPILED_PYTHON_VERSION} but ended up with ${this_python}"
exit 1
fi
export openssl_line=$(echo -e "${voutput}" | grep "OpenSSL ")
export openssl_arr=($openssl_line)
export this_openssl="${openssl_arr[1]}"
if [[ "${this_openssl}" != "${COMPILED_OPENSSL_VERSION}" ]]; then
echo "ERROR: Tried to compile OpenSSL ${COMPILED_OPENSSL_VERSION} but ended up with ${this_openssl}"
exit 1
fi
echo "We successfully compiled Python ${this_python} and OpenSSL ${this_openssl}"
- name: Live API tests push only
if: github.event_name == 'push' || github.event_name == 'schedule'
env: # Or as an environment variable
env:
PASSCODE: ${{ secrets.PASSCODE }}
run: |
source ../.github/actions/decrypt.sh ../.github/actions/creds.tar.gpg creds.tar
@@ -241,7 +462,7 @@ jobs:
$gam oauth refresh
$gam info user
#$gam info user $gam_user grouptree
export tstamp=$(date +%s%3N)
export tstamp=$($date +%s%3N)
export newbase=gha-test-$JID-$tstamp
export newuser=$newbase@pdl.jaylee.us
export newgroup=$newbase-group@pdl.jaylee.us
@@ -253,19 +474,21 @@ jobs:
for i in {01..10}; do
echo "${newbase}-bulkuser-$i" >> sample.csv;
done
$gam create user $newuser firstname GHA lastname $JID password random recoveryphone 12125121110 recoveryemail jay0lee@gmail.com gha.jid $JID
$gam create user $newuser firstname GHA lastname $JID password random recoveryphone 12125121110 recoveryemail jay0lee@gmail.com gha.jid $JID languages en+,en-GB-
$gam user $gam_user sendemail recipient $newuser subject "test message $newbase" message "GHA test message"
$gam user $gam_user sendemail recipient exchange@pdl.jaylee.us subject "test ${tstamp}" message "test message"
$gam create group $newgroup name "GHA $JID group" description "This is a description" isarchived true
$gam update cigroup $newgroup memberrestriction 'member.type == 1 || member.customer_id == groupCustomerId()'
$gam info cigroup $newgroup
$gam user $newuser add license gsuitebusiness
$gam user $newuser add license workspaceenterpriseplus
$gam update group $newgroup add owner $gam_user
$gam update group $newgroup add member $newuser
$gam print privileges
$gam create admin $newuser _GROUPS_EDITOR_ROLE CUSTOMER condition nonsecuritygroup
$gam csv sample.csv gam create user ~~email~~ firstname "GHA Bulk" lastname ~~email~~ gha.jid $JID
$gam csv sample.csv gam update user ~~email~~ recoveryphone 12125121110 recoveryemail jay0lee@gmail.com password random
$gam csv sample.csv gam update user ~~email~~ recoveryphone "" recoveryemail ""
$gam csv sample.csv gam user ~email add license gsuitebusiness
$gam csv sample.csv gam user ~email add license workspaceenterpriseplus
$gam csv sample.csv gam user $gam_user sendemail recipient ~~email~~@pdl.jaylee.us subject "test message $newbase" message "GHA test message"
$gam csv sample.csv gam update group $newgroup add member ~email
$gam info group $newgroup
@@ -292,6 +515,7 @@ jobs:
$gam users "$newbase-bulkuser-04 $newbase-bulkuser-05 $newbase-bulkuser-06" trash messages query in:anywhere maxtotrash 99999 doit
$gam users "$newbase-bulkuser-07 $newbase-bulkuser-08 $newbase-bulkuser-09" modify messages query in:anywhere maxtomodify 99999 addlabel IMPORTANT addlabel STARRED doit
$gam user $newuser delete label --ALL_LABELS--
GAM_CSV_ROW_FILTER="name:regex:gha-test-${JID}" $gam print features | $gam csv - gam delete feature ~name
$gam create feature name Whiteboard-$newbase
$gam create feature name VC-$newbase
$gam create building "My Building - $newbase" id $newbuilding floors 1,2,3,4,5,6,7,8,9,10,11,12,14,15 description "No 13th floor here..."
@@ -304,7 +528,7 @@ jobs:
$gam calendar $gam_user add editor $newuser
$gam calendar $gam_user showacl
$gam calendar $gam_user printacl | $gam csv - gam calendar $gam_user delete id ~id
$gam calendar $gam_user addevent summary "GHA test event" start $(date '+%FT%T.%N%:z' -d "now + 1 hour") end $(date '+%FT%T.%N%:z' -d "now + 2 hours") attendee $newgroup hangoutsmeet guestscanmodify true sendupdates all
$gam calendar $gam_user addevent summary "GHA test event" start $($date '+%FT%T.%N%:z' -d "now + 1 hour") end $($date '+%FT%T.%N%:z' -d "now + 2 hours") attendee $newgroup hangoutsmeet guestscanmodify true sendupdates all
$gam calendar $gam_user printevents after -0d
matterid=uid:$($gam create vaultmatter name "GHA matter $newbase" description "test matter" collaborators $newuser | head -1 | cut -d ' ' -f 3)
$gam create vaulthold matter $matterid name "GHA hold $newbase" corpus mail accounts $newuser
@@ -320,6 +544,7 @@ jobs:
$gam delete building $newbuilding
$gam delete group $newgroup
$gam create alias $newalias user $newuser
$gam user $newuser delete license workspaceenterpriseplus
$gam whatis $newuser
$gam user $gam_user show tokens
$gam print exports matter $matterid | $gam csv - gam download export $matterid id:~~id~~
@@ -334,6 +559,7 @@ jobs:
export sn="$JID$JID$JID$JID-$(openssl rand -base64 32 | sed 's/[^a-zA-Z0-9]//g')"
$gam create device serialnumber $sn devicetype android
$gam print cros allfields orderby serialnumber
#$gam show crostelemetry storagepercentonly
$gam report usageparameters customer
$gam report usage customer parameters gmail:num_emails_sent,accounts:num_1day_logins
$gam report customer todrive
@@ -349,7 +575,7 @@ jobs:
$gam print printermodels | wc -l
#$gam print printers
#$gam create printer displayname "${newbase}" uri ipp://localhost:631 driverless description "made by $(date)"
rm $gampath/enabledasa.txt
rm -f -v $gampath/enabledasa.txt
- name: Upload to Google Drive, build only.
if: github.event_name == 'push' && matrix.goal != 'test'

View File

@@ -1,7 +1,4 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.7
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -27,3 +24,9 @@ repos:
hooks:
- id: pylint
args: [--output-format=colorized]
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py37-plus]

View File

@@ -1,6 +1,6 @@
GAM is a command line tool for Google Workspace (fka G Suite) Administrators to manage domain and user settings quickly and easily.
GAM is a command line tool for Google Workspace admins to manage domain and user settings quickly and easily.
![Build Status](https://github.com/jay0lee/GAM/workflows/Build%20and%20test%20GAM/badge.svg)
![Build Status](https://github.com/GAM-team/GAM/workflows/Build%20and%20test%20GAM/badge.svg)
# Quick Start
@@ -14,14 +14,6 @@ bash <(curl -s -S -L https://git.io/install-gam)
this will download GAM, install it and start setup.
To install with `pip`, run
```sh
pip install git+https://github.com/jay0lee/GAM.git#subdirectory=src
```
This will only download and install GAM. To start setup, simply invoke the `gam` CLI.
## Windows
Download the MSI Installer from the [GitHub Releases] page. Install the MSI and you'll be prompted to setup GAM.
@@ -43,7 +35,7 @@ There is a public chat room hosted in Google Chat. [Instructions to join](https:
GAM is maintained by [Jay Lee](mailto:jay0lee@gmail.com). Please direct "how do I?" questions to [Google Groups].
[GAM release]: https://git.io/gamreleases
[GitHub Releases]: https://github.com/jay0lee/GAM/releases
[GitHub]: https://github.com/jay0lee/GAM/tree/master
[GitHub Wiki]: https://github.com/jay0lee/GAM/wiki/
[GitHub Releases]: https://github.com/GAM-team/GAM/releases
[GitHub]: https://github.com/GAM-team/GAM/tree/master
[GitHub Wiki]: https://github.com/GAM-team/GAM/wiki/
[Google Groups]: http://groups.google.com/group/google-apps-manager

View File

@@ -207,8 +207,9 @@ If an item contains spaces, it should be surrounded by ".
<Namespace> ::= <String>
<NotificationID> ::= <String>
<NumberOfSeats> ::= <Number>
<OrgUnitID> ::= <String>
<OrgUnitID> ::= id:<String>
<OrgUnitPath> ::= /|(/<String)+
<OrgUnitItem> ::= <OrgUnitID>|<OrgUnitPath>
<ParameterKey> ::= <String>
<ParameterValue> ::= <String>
<Password> ::= <String>
@@ -315,6 +316,25 @@ If an item contains spaces, it should be surrounded by ".
<CrOSOrderByFieldName> ::=
lastsync|location|notes|serialnumber|status|supportenddate|user
<CrOSTelemetryFieldName> ::=
batteryinfo|
batterystatusreport|
cpuinfo|
cpustatusreport|
customer|
deviceid|
graphicsinfo|
graphicsstatusreport|
memoryinfo|
memorystatusreport|
name|
networkstatusreport|
orgunitid|
osupdatestatus|
serialnumber|
storageinfo|
storagestatusreport
<DriveFieldName> ::=
appdatacontents|
cancomment|
@@ -326,6 +346,7 @@ If an item contains spaces, it should be surrounded by ".
description|
editable|
explicitlytrashed|
driveid|
fileextension|
filesize|
foldercolorrgb|
@@ -581,6 +602,7 @@ Items, separated by spaces, with spaces, commas or single quotes in the items th
<CourseStateList> ::= "<CourseState>(,<CourseState>)*"
<CrOSFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
<CrOSIDList> ::= "<CrOSID>(,<CrOSID>)*"
<CrOSTelemetryFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
<DriveFileList> ::= "<DriveFileItem>(,<DriveFileItem>)*"
<EmailAddressList> ::= "<EmailAddress>(,<EmailAddress>)*"
<EmailItemList> ::= "<EmailItem>(,<EmailItem>)*"
@@ -594,7 +616,7 @@ Items, separated by spaces, with spaces, commas or single quotes in the items th
<GroupRoleList> ::= "<GroupRole>(,<GroupRole>)*"
<GuardianStateList> ::= "<GuardianState>(,<GuardianState>)*"
<LabelNameList> ::= "<LabelName>(,<LabelName)*"
<LanguageList> ::= "<Language>(,<Language)*"
<LanguageList> ::= "<Language>[+|-](,<Language>[+|-])*"
<MatterItemList> ::= "<MatterItem>(,<MatterItem>)*"
<MembersFieldNameList> ::= "<MembersFieldName>(,<MembersFieldName>)*"
<MobileList> ::= "<MobileId>(,<MobileId>)*"
@@ -633,7 +655,7 @@ Specify a collection of ChromeOS devices by directly specifying them
## Collections of Users
Specify a collection of Users by directly specifying them or by specifiying items that will yield a list of users
Specify a collection of Users by directly specifying them or by specifying items that will yield a list of users
<UserTypeEntity> ::=
(all users)|
@@ -1017,7 +1039,8 @@ gam info customer
gam create datatransfer|transfer <OldOwnerID> <DataTransferServiceList> <NewOwnerID> (<ParameterKey> <ParameterValue>)*
gam info datatransfer|transfer <TransferID>
gam print datatransfers|transfers [todrive] [olduser|oldowner <UserItem>] [newuser|newowner <UserItem>] [status <String>]
gam print datatransfers|transfers [todrive] [olduser|oldowner <UserItem>] [newuser|newowner <UserItem>]
[status completed|failed|inprogress]
gam print transferapps
@@ -1128,6 +1151,7 @@ gam calendar <CalendarItem> modify <CalendarSettings>+
lastPolicyFetchTime|
lastRegistrationTime|
lastStatusReportTime|
machineextensionpolicies|
machineName|
machinePolicies|
orgUnitPath|
@@ -1262,6 +1286,18 @@ The listlimit <Number> argument limits the number of recent users, time ranges a
The start <Date> and end <Date> arguments filter the time ranges.
Delimiter defaults to comma.
gam info crostelemetry <SerialNumber>
<CrOSTelemetryFieldName>* [fields <CrOSTelemetryFieldNameList>]
[storagepercentonly] [showorgunitpath]
gam show crostelemetry
[(ou|org|orgunit <OrgUnitItem>)|(cros_sn <SerialNumber>)|(filter <String>)]
<CrOSTelemetryFieldName>* [fields <CrOSTelemetryFieldNameList>]
[storagepercentonly] [showorgunitpath]
gam print crostelemetry [todrive]
[(ou|org|orgunit <OrgUnitItem>)|(cros_sn <SerialNumber>)|(filter <String>)]
<CrOSTelemetryFieldName>* [fields <CrOSTelemetryFieldNameList>]
[storagepercentonly] [showorgunitpath]
gam print chromeapps [todrive]
[ou|org|orgunit <OrgUnitItem>]
[filter <String>]
@@ -1299,7 +1335,7 @@ gam print chromeversions [todrive]
name|
platform|
version|
<ChromeReleasesOrderByFieldName> ::=
<ChromeReleasesOrderByFieldName> ::=
channel|
endtime|
fraction|
@@ -1328,7 +1364,7 @@ gam show chromeschema [filter <String>]
<DeviceID> ::= devices/<String>
<DeviceType> ::= android|chrome_os|google_sync|ios|linux|mac_os|windows
<DeviceUserID> ::= devices/<String>/deviceUsers/<String>
<DeviceOrderbyFieldName> ::=
<DeviceOrderbyFieldName> ::=
createtime|devicetype|lastsynctime|model|osversion|serialnumber
gam create device serialnumber <String> devicetype <DeviceType> [assetid <String>]
@@ -1469,7 +1505,11 @@ gam create user <EmailAddress> <UserAttribute>* [verifynotinvitable]
gam update user <UserItem> <UserAttribute>* [clearschema <SchemaName>] [clearschema <SchemaName>.<FieldName>] [verifynotinvitable]
gam delete user <UserItem>
gam undelete user <UserItem> [org|ou <OrgUnitPath>]
gam info user [<UserItem>] [noaliases] [nogroups] [nolicenses|nolicences] [noschemas] [schemas|custom <SchemaNameList>] [userview] [skus|sku <SKUIDList>] [grouptree]
gam info user [<UserItem>]
[quick] [noaliases] [nogroups] [nolicenses|nolicences] [noschemas]
[skus|sku <SKUIDList>] [grouptree]
[userview] <UserFieldName>* [fields <UserFieldNameList>]
[schemas|custom all|<SchemaNameList>]
Print fields for selected users; use domain, query/queries and deleted_only to select users to print;
if none of these options are specified, all users are printed.
@@ -1477,10 +1517,12 @@ The first column will always be primaryEmail; the remaining field names will be
otherwise, the remaining field names will appear in the order specified.
gam print users [todrive]
([domain <DomainName>] [(query <QueryUser>)|(queries <QueryUserList>)] [deleted_only|only_deleted])
([domain <DomainName>] [(query <QueryUser>)|(queries <QueryUserList>)]
[limittoou <OrgUnitPath>] [deleted_only|only_deleted])
[groups] [license|licenses|licence|licences] [emailpart|emailparts|username]
[orderby <UserOrderByFieldName> [ascending|descending]] [userview]
[allfields|basic|full | ((<UserFieldName>* | fields <UserFieldNameList>) [schemas|custom all|<SchemaNameList>])]
[orderby <UserOrderByFieldName> [ascending|descending]]
[userview] [allfields|basic|full | (<UserFieldName>* | fields <UserFieldNameList>)]
[schemas|custom all|<SchemaNameList>])]
[delimiter <Character>] [sortheaders]
gam create verify|verification <DomainName>
@@ -1530,6 +1572,7 @@ gam update vaulthold|hold <HoldItem> matter <MatterItem> [query <QueryVaultCorpu
gam delete vaulthold|hold <HoldItem> matter <MatterItem>
gam info vaulthold|hold <HoldItem> matter <MatterItem>
gam print vaultholds|holds [todrive] [matters <MatterItemList>]
gam <UserTypeEntity> show vaultholds|holds
gam create vaultmatter|matter [name <String>] [description <string>]
[collaborator|collaborators <CollaboratorItemList>]
@@ -1720,6 +1763,7 @@ gam <UserTypeEntity> create|add teamdrive <Name>
gam <UserTypeEntity> update teamdrive <TeamDriveID> [asadmin] [name <Name>]
[(theme|themeid <String>) | ([customtheme <DriveFileID> <Float> <Float> <Float>] [color <ColorValue>])]
(<TeamDriveRestrictionsSubfieldName> <Boolean>)*
[hidden <Boolean>]
gam <UserTypeEntity> delete teamdrive <TeamDriveID>
gam <UserTypeEntity> show teamdriveinfo <TeamDriveID> [asadmin]
gam <UserTypeEntity> show teamdrives [query <QueryTeamDrive>] [asadmin]

View File

@@ -501,7 +501,7 @@ This program is Copyright (C) Zeus Technology Limited 1996.
This program may be used and copied freely providing this copyright notice
is not removed.
This software is provided "as is" and any express or implied waranties,
This software is provided "as is" and any express or implied warranties,
including but not limited to, the implied warranties of merchantability and
fitness for a particular purpose are disclaimed. In no event shall
Zeus Technology Ltd. be liable for any direct, indirect, incidental, special,

File diff suppressed because it is too large Load Diff

View File

@@ -4,13 +4,13 @@
"scopes": {
"https://www.googleapis.com/auth/admin.contact.delegation": {
"description": "View and manage your Contact Delegation"
},
},
"https://www.googleapis.com/auth/admin.contact.delegation.readonly": {
"description": "View your Contact Delegation"
}
}
}
},
},
"basePath": "",
"baseUrl": "https://admin.googleapis.com/admin/contacts/v1/",
"batchPath": "batch",

View File

@@ -52,7 +52,7 @@ done
target_dir=${target_dir%/}
update_profile() {
[ $2 -eq 1 ] || [ -f "$1" ] || return 1
[ "$2" -eq 1 ] || [ -f "$1" ] || return 1
grep -F "$alias_line" "$1" > /dev/null 2>&1
if [ $? -ne 0 ]; then
@@ -106,7 +106,7 @@ case $gamos in
echo "This Linux distribution uses glibc $this_glibc_ver"
useglibc="legacy"
for gam_glibc_ver in $gam_glibc_vers; do
if version_gt $this_glibc_ver $gam_glibc_ver; then
if version_gt "$this_glibc_ver" "$gam_glibc_ver"; then
useglibc="glibc$gam_glibc_ver"
echo_green "Using GAM compiled against $useglibc"
break
@@ -114,9 +114,10 @@ case $gamos in
done
case $gamarch in
x86_64) gamfile="linux-x86_64-$useglibc.tar.xz";;
arm64|aarch64) gamfile="linux-arm64-$useglibc.tar.xz";;
arm64|aarch64) gamfile="linux-aarch64-glibc2.28.tar.xz";;
arm|armv7l) gamfile="linux-armv7l-glibc2.28.tar.xz";;
*)
echo_red "ERROR: this installer currently only supports x86_64 and arm64 Linux. Looks like you're running on $gamarch. Exiting."
echo_red "ERROR: this installer currently only supports x86_64, arm and arm64 Linux. Looks like you're running on $gamarch. Exiting."
exit
esac
;;
@@ -128,7 +129,7 @@ case $gamos in
this_macos_ver=$osversion
fi
echo "You are running MacOS $this_macos_ver"
gamfile="macos-universal2.tar.xz"
gamfile="macos-x86_64.tar.xz"
;;
MINGW64_NT*)
gamos="windows"
@@ -136,15 +137,15 @@ case $gamos in
gamfile="-windows-x86_64.zip"
;;
*)
echo_red "Sorry, this installer currently only supports Linux and MacOS. Looks like you're runnning on $gamos. Exiting."
echo_red "Sorry, this installer currently only supports Linux and MacOS. Looks like you're running on $gamos. Exiting."
exit
;;
esac
if [ "$gamversion" == "latest" -o "$gamversion" == "prerelease" -o "$gamversion" == "draft" ]; then
release_url="https://api.github.com/repos/jay0lee/GAM/releases"
release_url="https://api.github.com/repos/GAM-team/GAM/releases"
else
release_url="https://api.github.com/repos/jay0lee/GAM/releases/tags/v$gamversion"
release_url="https://api.github.com/repos/GAM-team/GAM/releases/tags/v$gamversion"
fi
if [ -z ${GHCLIENT+x} ]; then
@@ -154,7 +155,7 @@ else
fi
echo_yellow "Checking GitHub URL $release_url for $gamversion GAM release ($check_type)..."
release_json=$(curl -s $GHCLIENT $release_url 2>&1 /dev/null)
release_json=$(curl -s "$GHCLIENT" "$release_url" 2>&1 /dev/null)
echo_yellow "Getting file and download URL..."
# Python is sadly the nearest to universal way to safely handle JSON with Bash
@@ -204,12 +205,12 @@ if (( $rc != 0 )); then
exit
fi
browser_download_url=$(echo "$release_json" | $pycmd -c "$pycode" browser_download_url $gamversion)
browser_download_url=$(echo "$release_json" | $pycmd -c "$pycode" browser_download_url "$gamversion")
if [[ ${browser_download_url:0:5} = "ERROR" ]]; then
echo_red "${browser_download_url}"
exit
fi
name=$(echo "$release_json" | $pycmd -c "$pycode" name $gamversion)
name=$(echo "$release_json" | $pycmd -c "$pycode" name "$gamversion")
if [[ ${name:0:5} = "ERROR" ]]; then
echo_red "${name}"
exit
@@ -223,13 +224,13 @@ trap "rm -rf $temp_archive_dir" EXIT
echo_yellow "Downloading file $name from $browser_download_url to $temp_archive_dir ($check_type)..."
# Save archive to temp w/o losing our path
(cd $temp_archive_dir && curl -O -L $GHCLIENT $browser_download_url)
(cd "$temp_archive_dir" && curl -O -L $GHCLIENT $browser_download_url)
mkdir -p "$target_dir"
echo_yellow "Extracting archive to $target_dir"
if [[ "${name}" == *.tar.xz ]]; then
tar xf $temp_archive_dir/$name -C "$target_dir"
tar xf "$temp_archive_dir"/"$name" -C "$target_dir"
else
unzip "${temp_archive_dir}/${name}" -d "${target_dir}"
fi
@@ -293,7 +294,7 @@ while true; do
if [ "$adminuser" == "" ]; then
read -p "Please enter your Google Workspace admin email address: " adminuser
fi
"$target_dir/gam/gam" create project $adminuser
"$target_dir/gam/gam" create project "$adminuser"
rc=$?
if (( $rc == 0 )); then
echo_green "Project creation complete."
@@ -318,7 +319,7 @@ while $project_created; do
read -p "Are you ready to authorize GAM to perform Google Workspace management operations as your admin account? (yes or no) " yn
case $yn in
[Yy]*)
"$target_dir/gam/gam" oauth create $adminuser
"$target_dir/gam/gam" oauth create "$adminuser"
rc=$?
if (( $rc == 0 )); then
echo_green "Admin authorization complete."
@@ -347,7 +348,7 @@ while $project_created; do
read -p "Please enter the email address of a regular Google Workspace user: " regularuser
fi
echo_yellow "Great! Checking service account scopes.This will fail the first time. Follow the steps to authorize and retry. It can take a few minutes for scopes to PASS after they've been authorized in the admin console."
"$target_dir/gam/gam" user $adminuser check serviceaccount
"$target_dir/gam/gam" user "$adminuser" check serviceaccount
rc=$?
if (( $rc == 0 )); then
echo_green "Service account authorization complete."

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Provides backwards compatibility for calling gam as a single .py file"""
import sys

View File

@@ -12,7 +12,7 @@ extra_files = [(os.path.join(proot, 'cacerts.txt'), 'httplib2')]
extra_files += copy_metadata('google-api-python-client')
extra_files += [('cbcm-v1.1beta1.json', '.')]
extra_files += [('contactdelegation-v1.json', '.')]
extra_files += [('versionhistory-v1.json', '.')]
extra_files += [('admin-directory_v1.1beta1.json', '.')]
hidden_imports = [
'gam.auth.yubikey',
@@ -33,6 +33,13 @@ for d in a.datas:
pyz = PYZ(a.pure)
# TODO: fix universal2
target_arch = None
#if sys.platform == "darwin":
# target_arch="universal2"
#else:
# target_arch=None
exe = EXE(pyz,
a.scripts,
a.binaries,
@@ -42,4 +49,5 @@ exe = EXE(pyz,
debug=False,
strip=None,
upx=False,
target_arch=target_arch,
console=True)

View File

@@ -78,6 +78,7 @@ from gam.gapi.directory import printers as gapi_directory_printers
from gam.gapi.directory import privileges as gapi_directory_privileges
from gam.gapi.directory import resource as gapi_directory_resource
from gam.gapi.directory import roles as gapi_directory_roles
from gam.gapi.directory import roleassignments as gapi_directory_roleassignments
from gam.gapi.directory import users as gapi_directory_users
from gam.gapi import licensing as gapi_licensing
from gam.gapi import siteverification as gapi_siteverification
@@ -774,12 +775,12 @@ def doGAMVersion(checkForArgs=True):
cpu_bits = struct.calcsize('P') * 8
api_client_ver = lib_version('google-api-python-client')
print(
(f'GAM {GAM_VERSION} - {GAM_URL} - {GM_Globals[GM_GAM_TYPE]}\n'
f'GAM {GAM_VERSION} - {GAM_URL} - {GM_Globals[GM_GAM_TYPE]}\n'
f'{GAM_AUTHOR}\n'
f'Python {pyversion} {cpu_bits}-bit {sys.version_info.releaselevel}\n'
f'google-api-python-client {api_client_ver}\n'
f'{getOSPlatform()} {platform.machine()}\n'
f'Path: {GM_Globals[GM_GAM_PATH]}'))
f'Path: {GM_Globals[GM_GAM_PATH]}')
if sys.platform.startswith('win') and \
cpu_bits == 32 and \
platform.machine().find('64') != -1:
@@ -1724,134 +1725,6 @@ def doUpdateCourse():
print(f'Updated Course {result["id"]}')
def doDelAdmin():
cd = buildGAPIObject('directory')
roleAssignmentId = sys.argv[3]
print(f'Deleting Admin Role Assignment {roleAssignmentId}')
gapi.call(cd.roleAssignments(),
'delete',
customer=GC_Values[GC_CUSTOMER_ID],
roleAssignmentId=roleAssignmentId)
def doCreateAdmin():
cd = buildGAPIObject('directory')
user = normalizeEmailAddressOrUID(sys.argv[3])
body = {'assignedTo': convertEmailAddressToUID(user, cd)}
role = sys.argv[4]
body['roleId'] = getRoleId(role)
body['scopeType'] = sys.argv[5].upper()
if body['scopeType'] not in ['CUSTOMER', 'ORG_UNIT']:
controlflow.expected_argument_exit('scope type',
', '.join(['customer', 'org_unit']),
body['scopeType'])
if body['scopeType'] == 'ORG_UNIT':
orgUnit, orgUnitId = gapi_directory_orgunits.getOrgUnitId(
sys.argv[6], cd)
body['orgUnitId'] = orgUnitId[3:]
scope = f'ORG_UNIT {orgUnit}'
else:
scope = 'CUSTOMER'
print(f'Giving {user} admin role {role} for {scope}')
gapi.call(cd.roleAssignments(),
'insert',
customer=GC_Values[GC_CUSTOMER_ID],
body=body)
def doPrintAdmins():
cd = buildGAPIObject('directory')
roleId = None
todrive = False
kwargs = {}
fields = 'nextPageToken,items(roleAssignmentId,roleId,assignedTo,scopeType,orgUnitId)'
titles = [
'roleAssignmentId', 'roleId', 'role', 'assignedTo', 'assignedToUser',
'scopeType', 'orgUnitId', 'orgUnit'
]
csvRows = []
i = 3
while i < len(sys.argv):
myarg = sys.argv[i].lower()
if myarg == 'user':
kwargs['userKey'] = normalizeEmailAddressOrUID(sys.argv[i + 1])
i += 2
elif myarg == 'role':
roleId = getRoleId(sys.argv[i + 1])
i += 2
elif myarg == 'todrive':
todrive = True
i += 1
else:
controlflow.invalid_argument_exit(sys.argv[i], 'gam print admins')
if roleId and not kwargs:
kwargs['roleId'] = roleId
roleId = None
admins = gapi.get_all_pages(cd.roleAssignments(),
'list',
'items',
customer=GC_Values[GC_CUSTOMER_ID],
fields=fields,
**kwargs)
for admin in admins:
if roleId and roleId != admin['roleId']:
continue
admin_attrib = {}
for key, value in list(admin.items()):
if key == 'assignedTo':
admin_attrib['assignedToUser'] = user_from_userid(value)
elif key == 'roleId':
admin_attrib['role'] = role_from_roleid(value)
elif key == 'orgUnitId':
value = f'id:{value}'
admin_attrib[
'orgUnit'] = gapi_directory_orgunits.orgunit_from_orgunitid(
value, cd)
admin_attrib[key] = value
csvRows.append(admin_attrib)
display.write_csv_file(csvRows, titles, 'Admins', todrive)
def buildRoleIdToNameToIdMap():
cd = buildGAPIObject('directory')
result = gapi.get_all_pages(cd.roles(),
'list',
'items',
customer=GC_Values[GC_CUSTOMER_ID],
fields='nextPageToken,items(roleId,roleName)')
GM_Globals[GM_MAP_ROLE_ID_TO_NAME] = {}
GM_Globals[GM_MAP_ROLE_NAME_TO_ID] = {}
for role in result:
GM_Globals[GM_MAP_ROLE_ID_TO_NAME][role['roleId']] = role['roleName']
GM_Globals[GM_MAP_ROLE_NAME_TO_ID][role['roleName']] = role['roleId']
def role_from_roleid(roleid):
if not GM_Globals[GM_MAP_ROLE_ID_TO_NAME]:
buildRoleIdToNameToIdMap()
return GM_Globals[GM_MAP_ROLE_ID_TO_NAME].get(roleid, roleid)
def roleid_from_role(role):
if not GM_Globals[GM_MAP_ROLE_NAME_TO_ID]:
buildRoleIdToNameToIdMap()
return GM_Globals[GM_MAP_ROLE_NAME_TO_ID].get(role, None)
def getRoleId(role):
cg = UID_PATTERN.match(role)
if cg:
roleId = cg.group(1)
else:
roleId = roleid_from_role(role)
if not roleId:
controlflow.system_error_exit(
4,
f'{role} is not a valid role. Please ensure role name is exactly as shown in admin console.'
)
return roleId
def buildUserIdToNameMap():
cd = buildGAPIObject('directory')
result = gapi.get_all_pages(cd.users(),
@@ -3273,7 +3146,7 @@ def printDriveFileList(users):
'orderby', ', '.join(sorted(DRIVEFILE_ORDERBY_CHOICES_MAP)),
fieldName)
elif myarg == 'query':
query += f' and {sys.argv[i+1]}'
query += f' and ({sys.argv[i+1]})'
i += 2
elif myarg == 'fullquery':
query = sys.argv[i + 1]
@@ -3734,7 +3607,7 @@ def getDriveFileAttribute(i, body, parameters, myarg, update=False):
i += 2
else:
controlflow.invalid_argument_exit(
myarg, f"gam <users> {operation} drivefile")
myarg, f'gam <users> {operation} drivefile')
return i
@@ -4098,7 +3971,7 @@ def downloadDriveFile(users):
for sheet in spreadsheet['sheets']:
if sheet['properties']['title'].lower(
) == csvSheetTitleLower:
spreadsheetUrl = '{0}?format=csv&id={1}&gid={2}'.format(
spreadsheetUrl = '{}?format=csv&id={}&gid={}'.format(
re.sub('/edit.*$', '/export',
spreadsheet['spreadsheetUrl']),
fileId, sheet['properties']['sheetId'])
@@ -4123,8 +3996,7 @@ def downloadDriveFile(users):
while not done:
status, done = downloader.next_chunk()
if showProgress:
print('Downloaded: {0:>7.2%}'.format(
status.progress()))
print(f'Downloaded: {status.progress():>7.2%}')
else:
_, content = drive._http.request(uri=spreadsheetUrl,
method='GET')
@@ -4135,7 +4007,7 @@ def downloadDriveFile(users):
fileutils.close_file(fh)
fileDownloaded = True
break
except (IOError, httplib2.HttpLib2Error) as e:
except (OSError, httplib2.HttpLib2Error) as e:
display.print_error(str(e))
GM_Globals[GM_SYSEXITRC] = 6
fileDownloadFailed = True
@@ -6693,13 +6565,27 @@ def getUserAttributes(i, cd, updateCmd):
i += 1
continue
for language in sys.argv[i].replace(',', ' ').split():
if language.lower() in LANGUAGE_CODES_MAP:
appendItemToBodyList(
body, 'languages',
{'languageCode': LANGUAGE_CODES_MAP[language.lower()]})
lang_item = {}
if language[-1] == '+':
suffix = '+'
language = language[:-1]
lang_item['preference'] = 'preferred'
elif language[-1] == '-':
suffix = '-'
language = language[:-1]
lang_item['preference'] = 'not_preferred'
else:
appendItemToBodyList(body, 'languages',
{'customLanguage': language})
suffix = ''
if language.lower() in LANGUAGE_CODES_MAP:
lang_item['languageCode'] = LANGUAGE_CODES_MAP[language.lower()]
else:
if suffix:
controlflow.system_error_exit(
2,
f'suffix {suffix} not allowed with customLanguage {language}'
)
lang_item['customLanguage'] = language
appendItemToBodyList(body, 'languages', lang_item)
i += 1
elif myarg == 'gender':
i += 1
@@ -8182,6 +8068,7 @@ def doUpdateTeamDrive(users):
teamDriveId = sys.argv[5]
body = {}
useDomainAdminAccess = False
change_hide = None
i = 6
while i < len(sys.argv):
myarg = sys.argv[i].lower().replace('_', '')
@@ -8205,6 +8092,15 @@ def doUpdateTeamDrive(users):
elif myarg == 'asadmin':
useDomainAdminAccess = True
i += 1
elif myarg in ['ou', 'org', 'orgunit']:
body['orgUnitId'] = gapi_directory_orgunits.getOrgUnitId(sys.argv[i + 1])
i += 2
elif myarg in ['hidden']:
if getBoolean(sys.argv[i+1], myarg):
change_hide = 'hide'
else:
change_hide = 'unhide'
i += 2
elif myarg in TEAMDRIVE_RESTRICTIONS_MAP:
body.setdefault('restrictions', {})
body['restrictions'][
@@ -8214,25 +8110,31 @@ def doUpdateTeamDrive(users):
else:
controlflow.invalid_argument_exit(sys.argv[i],
'gam <users> update teamdrive')
if not body:
if not body and not change_hide:
controlflow.system_error_exit(
4, 'nothing to update. Need at least a name argument.')
for user in users:
user, drive = buildDrive3GAPIObject(user)
if not drive:
continue
result = gapi.call(drive.drives(),
if body:
result = gapi.call(drive.drives(),
'update',
useDomainAdminAccess=useDomainAdminAccess,
body=body,
driveId=teamDriveId,
fields='id',
soft_errors=True)
if not result:
continue
if not result:
continue
if change_hide:
ch_result = gapi.call(drive.drives(),
change_hide,
driveId=teamDriveId,
fields='id',
soft_errors=True)
print(f'Updated Team Drive {teamDriveId}')
def printShowTeamDrives(users, csvFormat):
todrive = False
useDomainAdminAccess = False
@@ -8770,6 +8672,20 @@ def _get_admin_email():
)
return _getValueFromOAuth('email')
def _formatLanguagesList(propertyValue, delimiter):
languages = []
for language in propertyValue:
if 'languageCode' in language:
lang = language['languageCode']
if language.get('preference') == 'preferred':
lang += '+'
elif language.get('preference') == 'not_preferred':
lang += '-'
else:
lang = language.get('customLanguage')
languages.append(lang)
return delimiter.join(languages)
def doGetUserInfo(user_email=None):
def user_lic_result(request_id, response, exception):
@@ -8784,6 +8700,7 @@ def doGetUserInfo(user_email=None):
i = 4
else:
user_email = _get_admin_email()
fieldsList = []
getSchemas = True
getAliases = True
getGroups = True
@@ -8814,10 +8731,35 @@ def doGetUserInfo(user_email=None):
getSchemas = False
projection = 'basic'
i += 1
elif myarg == 'quick':
getAliases = getCIGroups = getGroups = getLicenses = getSchemas = False
i += 1
elif myarg in ['custom', 'schemas']:
getSchemas = True
projection = 'custom'
customFieldMask = sys.argv[i + 1]
if not fieldsList:
fieldsList = ['primaryEmail']
fieldsList.append('customSchemas')
if sys.argv[i + 1].lower() == 'all':
projection = 'full'
else:
projection = 'custom'
customFieldMask = sys.argv[i + 1].replace(' ', ',')
i += 2
elif myarg in USER_ARGUMENT_TO_PROPERTY_MAP:
if not fieldsList:
fieldsList = ['primaryEmail',]
fieldsList.extend(USER_ARGUMENT_TO_PROPERTY_MAP[myarg])
i += 1
elif myarg == 'fields':
if not fieldsList:
fieldsList = ['primaryEmail',]
fieldNameList = sys.argv[i + 1]
for field in fieldNameList.lower().replace(',', ' ').split():
if field in USER_ARGUMENT_TO_PROPERTY_MAP:
fieldsList.extend(USER_ARGUMENT_TO_PROPERTY_MAP[field])
else:
controlflow.invalid_argument_exit(field,
'gam info users fields')
i += 2
elif myarg == 'userview':
viewType = 'domain_public'
@@ -8831,6 +8773,7 @@ def doGetUserInfo(user_email=None):
'get',
userKey=user_email,
projection=projection,
fields=','.join(set(fieldsList)) if fieldsList else '*',
customFieldMask=customFieldMask,
viewType=viewType)
print(f'User: {user["primaryEmail"]}')
@@ -8839,14 +8782,7 @@ def doGetUserInfo(user_email=None):
if 'name' in user and 'familyName' in user['name']:
print(f'Last Name: {user["name"]["familyName"]}')
if 'languages' in user:
up = 'languageCode'
languages = [row[up] for row in user['languages'] if up in row]
if languages:
print(f'Languages: {",".join(languages)}')
up = 'customLanguage'
languages = [row[up] for row in user['languages'] if up in row]
if languages:
print(f'Custom Languages: {",".join(languages)}')
print(f"Languages: {_formatLanguagesList(user['languages'], ',')}")
if 'isAdmin' in user:
print(f'Is a Super Admin: {user["isAdmin"]}')
if 'isDelegatedAdmin' in user:
@@ -9381,13 +9317,6 @@ def doDeprovUser(users):
print(f'Done deprovisioning {user}')
def doDeleteUser():
cd = buildGAPIObject('directory')
user_email = normalizeEmailAddressOrUID(sys.argv[3])
print(f'Deleting account for {user_email}')
gapi.call(cd.users(), 'delete', userKey=user_email)
def doUndeleteUser():
cd = buildGAPIObject('directory')
user = normalizeEmailAddressOrUID(sys.argv[3])
@@ -9661,6 +9590,7 @@ def doPrintUsers():
customFieldMask = None
sortHeaders = getGroupFeed = getLicenseFeed = email_parts = False
viewType = deleted_only = orderBy = sortOrder = None
orgUnitPath = orgUnitPathLower = None
groupDelimiter = ' '
licenseDelimiter = ','
i = 3
@@ -9690,7 +9620,7 @@ def doPrintUsers():
projection = 'full'
else:
projection = 'custom'
customFieldMask = sys.argv[i + 1]
customFieldMask = sys.argv[i + 1].replace(' ', ',')
i += 2
elif myarg == 'todrive':
todrive = True
@@ -9725,19 +9655,19 @@ def doPrintUsers():
elif myarg in ['query', 'queries']:
queries = getQueries(myarg, sys.argv[i + 1])
i += 2
elif myarg == 'limittoou':
orgUnitPath = gapi_directory_orgunits.getOrgUnitItem(sys.argv[i + 1], pathOnly=True)
orgUnitPathLower = orgUnitPath.lower()
i += 2
elif myarg in USER_ARGUMENT_TO_PROPERTY_MAP:
if not fieldsList:
fieldsList = [
'primaryEmail',
]
fieldsList = ['primaryEmail',]
display.add_field_to_csv_file(myarg, USER_ARGUMENT_TO_PROPERTY_MAP,
fieldsList, fieldsTitles, titles)
i += 1
elif myarg == 'fields':
if not fieldsList:
fieldsList = [
'primaryEmail',
]
fieldsList = ['primaryEmail',]
fieldNameList = sys.argv[i + 1]
for field in fieldNameList.lower().replace(',', ' ').split():
if field in USER_ARGUMENT_TO_PROPERTY_MAP:
@@ -9760,10 +9690,21 @@ def doPrintUsers():
else:
controlflow.invalid_argument_exit(sys.argv[i], 'gam print users')
if fieldsList:
if orgUnitPath is not None:
fieldsList.append('orgUnitPath')
fields = f'nextPageToken,users({",".join(set(fieldsList)).replace(".", "/")})'
else:
fields = None
for query in queries:
if orgUnitPath is not None:
if query is not None and query.find(orgUnitPath) == -1:
query += f" orgUnitPath='{orgUnitPath}'"
else:
if query is None:
query = ''
else:
query += ' '
query += f"orgUnitPath='{orgUnitPath}'"
printGettingAllItems('Users', query)
page_message = gapi.got_total_items_first_last_msg('Users')
all_users = gapi.get_all_pages(cd.users(),
@@ -9782,13 +9723,16 @@ def doPrintUsers():
projection=projection,
customFieldMask=customFieldMask)
for user in all_users:
if email_parts and ('primaryEmail' in user):
user_email = user['primaryEmail']
if user_email.find('@') != -1:
user['primaryEmailLocal'], user[
'primaryEmailDomain'] = splitEmailAddress(user_email)
display.add_row_titles_to_csv_file(utils.flatten_json(user),
csvRows, titles)
if orgUnitPathLower is None or orgUnitPathLower == user.get('orgUnitPath', '').lower():
if email_parts and ('primaryEmail' in user):
user_email = user['primaryEmail']
if user_email.find('@') != -1:
user['primaryEmailLocal'], user[
'primaryEmailDomain'] = splitEmailAddress(user_email)
if 'languages' in user:
user['languages'] = _formatLanguagesList(user.pop('languages'), ' ')
display.add_row_titles_to_csv_file(utils.flatten_json(user),
csvRows, titles)
if sortHeaders:
display.sort_csv_titles([
'primaryEmail',
@@ -10452,9 +10396,10 @@ OAUTH2_SCOPES = [
'scopes': 'https://www.googleapis.com/auth/admin.directory.device.chromebrowsers',
},
{
'name': 'Chrome Management API - read only',
'name': 'Chrome Management API - read only (2 scopes)',
'subscope': [],
'scopes': ['https://www.googleapis.com/auth/chrome.management.reports.readonly'],
'scopes': ['https://www.googleapis.com/auth/chrome.management.reports.readonly',
'https://www.googleapis.com/auth/chrome.management.telemetry.readonly'],
},
{
'name': 'Chrome Policy API',
@@ -11162,7 +11107,7 @@ def run_batch(items):
# Otherwise, the argument is preserved as is
#
# SubFields is a dictionary; the key is the argument number, the value is a list of tuples that mark
# the substition (fieldname, start, end).
# the substitution (fieldname, start, end).
# Example: update user '~User' address type work unstructured '~~Street~~, ~~City~~, ~~State~~ ~~ZIP~~' primary
# {2: [('User', 0, 5)], 7: [('Street', 0, 10), ('City', 12, 20), ('State', 22, 31), ('ZIP', 32, 39)]}
#
@@ -11368,7 +11313,7 @@ def ProcessGAMCommand(args):
elif argument in ['domainalias', 'aliasdomain']:
gapi_directory_domainaliases.create()
elif argument == 'admin':
doCreateAdmin()
gapi_directory_roleassignments.create()
elif argument in ['guardianinvite', 'inviteguardian', 'guardian']:
doInviteGuardian()
elif argument in ['project', 'apiproject']:
@@ -11488,6 +11433,8 @@ def ProcessGAMCommand(args):
gapi_directory_resource.getResourceCalendarInfo()
elif argument == 'cros':
gapi_directory_cros.doGetCrosInfo()
elif argument == 'crostelemetry':
gapi_chromemanagement.printShowCrosTelemetry('info')
elif argument == 'mobile':
gapi_directory_mobiledevices.info()
elif argument in ['verify', 'verification']:
@@ -11544,7 +11491,7 @@ def ProcessGAMCommand(args):
elif command == 'delete':
argument = sys.argv[2].lower()
if argument == 'user':
doDeleteUser()
gapi_directory_users.delete()
elif argument == 'group':
gapi_directory_groups.delete()
elif argument == 'device':
@@ -11570,7 +11517,7 @@ def ProcessGAMCommand(args):
elif argument in ['domainalias', 'aliasdomain']:
gapi_directory_domainaliases.delete()
elif argument == 'admin':
doDelAdmin()
gapi_directory_roleassignments.delete()
elif argument in ['guardian', 'guardians']:
doDeleteGuardian()
elif argument in ['project', 'projects']:
@@ -11640,6 +11587,8 @@ def ProcessGAMCommand(args):
gapi_cloudidentity_groups.print_()
elif argument == 'devices':
gapi_cloudidentity_devices.print_()
elif argument == 'crostelemetry':
gapi_chromemanagement.printShowCrosTelemetry('print')
elif argument in ['groupmembers', 'groupsmembers']:
gapi_directory_groups.print_members()
elif argument in ['cigroupmembers', 'cigroupsmembers']:
@@ -11675,7 +11624,7 @@ def ProcessGAMCommand(args):
elif argument in ['domainaliases', 'aliasdomains']:
gapi_directory_domainaliases.print_()
elif argument == 'admins':
doPrintAdmins()
gapi_directory_roleassignments.print_()
elif argument in ['roles', 'adminroles']:
gapi_directory_roles.print_()
elif argument in ['guardian', 'guardians']:
@@ -11748,6 +11697,8 @@ def ProcessGAMCommand(args):
gapi_chromepolicy.printshow_schemas()
elif argument in ['chromepolicy', 'chromepolicies']:
gapi_chromepolicy.printshow_policies()
elif argument == 'crostelemetry':
gapi_chromemanagement.printShowCrosTelemetry('show')
else:
controlflow.invalid_argument_exit(argument, 'gam show')
sys.exit(0)
@@ -11956,6 +11907,8 @@ def ProcessGAMCommand(args):
doGetTeamDriveInfo(users)
elif showWhat in ['contactdelegate', 'contactdelegates']:
gapi_contactdelegation.print_(users, False)
elif showWhat in ['holds', 'vaultholds']:
gapi_vault.showHoldsForUsers(users)
else:
controlflow.invalid_argument_exit(showWhat, 'gam <users> show')
elif command == 'print':

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# GAM
#
@@ -37,10 +36,10 @@ def main():
# to break parallel operations with errors about extra -b
# command line arguments
set_start_method('fork')
if sys.version_info[0] < 3 or sys.version_info[1] < 6:
if sys.version_info[0] < 3 or sys.version_info[1] < 7:
controlflow.system_error_exit(
5,
f'GAM requires Python 3.6 or newer. You are running %s.%s.%s. Please upgrade your Python version or use one of the binary GAM downloads.'
f'GAM requires Python 3.7 or newer. You are running %s.%s.%s. Please upgrade your Python version or use one of the binary GAM downloads.'
% sys.version_info[:3])
sys.exit(gam.ProcessGAMCommand(sys.argv))

View File

@@ -37,7 +37,7 @@ def get_admin_credentials(api=None):
credential_file = get_admin_credentials_filename()
if not os.path.isfile(credential_file):
raise oauth.InvalidCredentialsFileError
with open(credential_file, 'r') as f:
with open(credential_file) as f:
creds_data = json.load(f)
# Validate that enable DASA matches content of authorization file
if GC_Values[GC_ENABLE_DASA] and 'private_key_id' in creds_data:

View File

@@ -115,7 +115,7 @@ class Credentials(google.oauth2.credentials.Credentials):
Raises:
TypeError: If id_token_data is not the required dict type.
"""
super(Credentials, self).__init__(token=token,
super().__init__(token=token,
refresh_token=refresh_token,
id_token=id_token,
token_uri=token_uri,
@@ -161,9 +161,9 @@ class Credentials(google.oauth2.credentials.Credentials):
ValueError: If missing fields are detected in the info.
"""
# We need all of these keys
keys_needed = set(('client_id', 'client_secret'))
keys_needed = {'client_id', 'client_secret'}
# We need 1 or more of these keys
keys_need_one_of = set(('refresh_token', 'auth_token', 'token'))
keys_need_one_of = {'refresh_token', 'auth_token', 'token'}
missing = keys_needed.difference(info.keys())
has_one_of = set(info) & keys_need_one_of
if missing or not has_one_of:
@@ -472,7 +472,7 @@ class Credentials(google.oauth2.credentials.Credentials):
def _locked_refresh(self, request):
"""Refreshes the credential's access token while the file lock is held."""
assert self._lock.is_locked
super(Credentials, self).refresh(request)
super().refresh(request)
def write(self):
"""Writes credentials to disk."""
@@ -523,12 +523,12 @@ class _ShortURLFlow(google_auth_oauthlib.flow.InstalledAppFlow):
def authorization_url(self, http=None, **kwargs):
"""Gets a shortened authorization URL."""
long_url, state = super(_ShortURLFlow, self).authorization_url(**kwargs)
long_url, state = super().authorization_url(**kwargs)
short_url = utils.shorten_url(long_url)
return short_url, state
class _FileLikeThreadLock(object):
class _FileLikeThreadLock:
"""A threading.lock which has the same interface as filelock.Filelock."""
def __init__(self):

View File

@@ -38,15 +38,15 @@ class CredentialsTest(unittest.TestCase):
'client_id': self.fake_client_id,
'client_secret': self.fake_client_secret,
}
super(CredentialsTest, self).setUp()
super().setUp()
def tearDown(self):
# Remove any credential files that may have been created.
if os.path.exists(self.fake_filename):
os.remove(self.fake_filename)
if os.path.exists('%s.lock' % self.fake_filename):
os.remove('%s.lock' % self.fake_filename)
super(CredentialsTest, self).tearDown()
if os.path.exists(f'{self.fake_filename}.lock'):
os.remove(f'{self.fake_filename}.lock')
super().tearDown()
def test_from_authorized_user_info_only_required_info(self):
creds = oauth.Credentials.from_authorized_user_info(
@@ -126,7 +126,7 @@ class CredentialsTest(unittest.TestCase):
client_secret=self.fake_client_secret,
filename=self.fake_filename)
self.assertIsInstance(creds._lock, oauth.FileLock)
self.assertEqual(creds._lock.lock_file, '%s.lock' % creds.filename)
self.assertEqual(creds._lock.lock_file, f'{creds.filename}.lock')
def test_credentials_uses_thread_lock_when_filename_not_provided(self):
creds = oauth.Credentials(token=self.fake_token,
@@ -540,7 +540,7 @@ class CredentialsTest(unittest.TestCase):
client_id=self.fake_client_id,
client_secret=self.fake_client_secret,
filename=self.fake_filename)
lock_file = '%s.lock' % creds.filename
lock_file = f'{creds.filename}.lock'
creds.write()
self.assertTrue(os.path.exists(lock_file))
creds.delete()
@@ -564,9 +564,9 @@ class CredentialsTest(unittest.TestCase):
creds.revoke(http=mock_http)
uri = mock_http.request.call_args[0][0]
self.assertRegex(uri, '^%s' % oauth.Credentials._REVOKE_TOKEN_BASE_URI)
self.assertRegex(uri, f'^{oauth.Credentials._REVOKE_TOKEN_BASE_URI}')
params = uri[uri.index('?'):]
self.assertIn('token=%s' % creds.refresh_token, params)
self.assertIn(f'token={creds.refresh_token}', params)
self.assertEqual('GET', mock_http.request.call_args[0][1])
@@ -592,7 +592,7 @@ class ShortUrlFlowTest(unittest.TestCase):
}
self.long_url = 'http://example.com/some/long/url'
self.short_url = 'http://ex.co/short'
super(ShortUrlFlowTest, self).setUp()
super().setUp()
@patch.object(oauth.google_auth_oauthlib.flow.InstalledAppFlow,
'authorization_url')

View File

@@ -92,8 +92,8 @@ def wait_on_failure(current_attempt_num,
wait_on_fail = min(2**current_attempt_num,
60) + float(random.randint(1, 1000)) / 1000
if current_attempt_num > error_print_threshold:
sys.stderr.write((f'Temporary error: {error_message}, Backing off: '
sys.stderr.write(f'Temporary error: {error_message}, Backing off: '
f'{int(wait_on_fail)} seconds, Retry: '
f'{current_attempt_num}/{total_num_retries}\n'))
f'{current_attempt_num}/{total_num_retries}\n')
sys.stderr.flush()
time.sleep(wait_on_fail)

View File

@@ -79,7 +79,7 @@ class ControlFlowTest(unittest.TestCase):
controlflow.wait_on_failure(
attempt,
total_attempts,
'Attempt #%s' % attempt,
f'Attempt #{attempt}',
# Suppress messages while we make a lot of attempts.
error_print_threshold=total_attempts + 1)
# Wait time may be between 60 and 61 secs, due to rand addition.
@@ -102,7 +102,7 @@ class ControlFlowTest(unittest.TestCase):
for attempt in range(1, total_attempts + 1):
controlflow.wait_on_failure(attempt,
total_attempts,
'Attempt #%s' % attempt,
f'Attempt #{attempt}',
error_print_threshold=threshold)
self.assertEqual(total_attempts - threshold,
mock_stderr_write.call_count)

View File

@@ -259,9 +259,9 @@ def write_csv_file(csvRows, titles, list_type, todrive):
dialect='nixstdout',
extrasaction='ignore')
try:
writer.writerow(dict((item, item) for item in writer.fieldnames))
writer.writerow({item: item for item in writer.fieldnames})
writer.writerows(csvRows)
except IOError as e:
except OSError as e:
controlflow.system_error_exit(6, e)
if todrive:
admin_email = gam._get_admin_email()
@@ -309,12 +309,12 @@ and follow recommend steps to authorize GAM for Drive access.''')
def print_error(message):
"""Prints a one-line error message to stderr in a standard format."""
sys.stderr.write('\n{0}{1}\n'.format(ERROR_PREFIX, message))
sys.stderr.write(f'\n{ERROR_PREFIX}{message}\n')
def print_warning(message):
"""Prints a one-line warning message to stderr in a standard format."""
sys.stderr.write('\n{0}{1}\n'.format(WARNING_PREFIX, message))
sys.stderr.write(f'\n{WARNING_PREFIX}{message}\n')
def print_json(object_value, spacing=''):

View File

@@ -59,7 +59,7 @@ def open_file(filename,
# Open a file on disk
f = _open_file(filename, mode, newline=newline, encoding=encoding)
if strip_utf_bom:
utf_bom = u'\ufeff'
utf_bom = '\ufeff'
has_bom = False
if 'b' in mode:
@@ -79,7 +79,7 @@ def open_file(filename,
return f
except IOError as e:
except OSError as e:
controlflow.system_error_exit(6, e)
@@ -101,7 +101,7 @@ def close_file(f, force_flush=False):
try:
f.close()
return True
except IOError as e:
except OSError as e:
display.print_error(e)
return False
@@ -140,7 +140,7 @@ def read_file(filename,
encoding=encoding) as f:
return f.read()
except IOError as e:
except OSError as e:
if continue_on_error:
if display_errors:
display.print_warning(e)
@@ -174,7 +174,7 @@ def write_file(filename,
f.write(data)
return True
except IOError as e:
except OSError as e:
if continue_on_error:
if display_errors:
display.print_error(e)

View File

@@ -13,7 +13,7 @@ class FileutilsTest(unittest.TestCase):
def setUp(self):
self.fake_path = '/some/path/to/file'
super(FileutilsTest, self).setUp()
super().setUp()
@patch.object(fileutils.sys, 'stdin')
def test_open_file_stdin(self, mock_stdin):
@@ -63,7 +63,7 @@ class FileutilsTest(unittest.TestCase):
self.assertEqual(fileutils.UTF8_SIG, mock_open.call_args[1]['encoding'])
def test_open_file_strips_utf_bom_in_utf(self):
bom_prefixed_data = u'\ufefffoobar'
bom_prefixed_data = '\ufefffoobar'
fake_file = io.StringIO(bom_prefixed_data)
mock_open = MagicMock(spec=open, return_value=fake_file)
with patch.object(fileutils, 'open', mock_open):
@@ -89,7 +89,7 @@ class FileutilsTest(unittest.TestCase):
self.assertEqual('foobar', f.read())
def test_open_file_strips_utf_bom_in_binary(self):
bom_prefixed_data = u'\ufefffoobar'.encode('UTF-8')
bom_prefixed_data = '\ufefffoobar'.encode()
fake_file = io.BytesIO(bom_prefixed_data)
mock_open = MagicMock(spec=open, return_value=fake_file)
with patch.object(fileutils, 'open', mock_open):

View File

@@ -80,7 +80,7 @@ class GapiTest(unittest.TestCase):
]
self.empty_items_response = {'items': []}
super(GapiTest, self).setUp()
super().setUp()
def test_call_returns_basic_200_response(self):
response = gapi.call(self.mock_service, self.mock_method_name)

View File

@@ -211,7 +211,7 @@ def update():
browser.update(body)
result = gapi.call(cbcm.chromebrowsers(), 'update', deviceId=device_id,
customer=customer_id, body=browser,
projection='BASIC', fields="deviceId")
projection='BASIC', fields='deviceId')
print(f'Updated browser {result["deviceId"]}')

View File

@@ -76,7 +76,7 @@ def print_members():
todrive = True
i += 1
else:
controlflow.invalid_argument_exit(myarg, "gam print chatmembers")
controlflow.invalid_argument_exit(myarg, 'gam print chatmembers')
if not space:
controlflow.system_error_exit(2,
'space <ChatSpace> is required.')
@@ -117,7 +117,7 @@ def create_message():
body['thread'] = {'name': sys.argv[i+1]}
i += 2
else:
controlflow.invalid_argument_exit(myarg, "gam create chat")
controlflow.invalid_argument_exit(myarg, 'gam create chat')
if not space:
controlflow.system_error_exit(2,
'space <ChatSpace> is required.')
@@ -151,7 +151,7 @@ def delete_message():
name = sys.argv[i+1]
i += 2
else:
controlflow.invalid_argument_exit(myarg, "gam delete chat")
controlflow.invalid_argument_exit(myarg, 'gam delete chat')
if not name:
controlflow.system_error_exit(2,
'name <String> is required.')
@@ -182,7 +182,7 @@ def update_message():
name = sys.argv[i+1]
i += 2
else:
controlflow.invalid_argument_exit(myarg, "gam update chat")
controlflow.invalid_argument_exit(myarg, 'gam update chat')
if not name:
controlflow.system_error_exit(2,
'name <String> is required.')

View File

@@ -203,7 +203,7 @@ def printHistory():
if 'channel' in citem:
citem['channel'] = citem['channel'].lower()
else:
channel_match = re.search(r"\/channels\/([^/]*)", citem['name'])
channel_match = re.search(r'\/channels\/([^/]*)', citem['name'])
if channel_match:
try:
citem['channel'] = channel_match.group(1)
@@ -212,7 +212,7 @@ def printHistory():
if 'platform' in citem:
citem['platform'] = citem['platform'].lower()
else:
platform_match = re.search(r"\/platforms\/([^/]*)", citem['name'])
platform_match = re.search(r'\/platforms\/([^/]*)', citem['name'])
if platform_match:
try:
citem['platform'] = platform_match.group(1)

View File

@@ -9,6 +9,8 @@ from gam.var import YYYYMMDD_FORMAT
from gam import controlflow
from gam import display
from gam import gapi
from gam import utils
from gam.gapi import directory as gapi_directory
from gam.gapi.directory import orgunits as gapi_directory_orgunits
from gam.gapi.directory.cros import _getFilterDate
@@ -201,6 +203,109 @@ def printAppDevices():
display.write_csv_file(csvRows, titles, 'Chrome Installed Application Devices', todrive)
def printShowCrosTelemetry(mode):
cm = build()
cd = None
parent = _get_customerid()
todrive = False
filter_ = None
readMask = []
orgUnitIdPathMap = {}
diskpercentonly = False
showOrgUnitPath = False
supported_readmask_values = list(cm._rootDesc['schemas']['GoogleChromeManagementV1TelemetryDevice']['properties'].keys())
supported_readmask_values.sort()
supported_readmask_map = {item.lower():item for item in supported_readmask_values}
i = 3
if mode == 'info':
if i >= len(sys.argv):
controlflow.system_error_exit(3, f'<SerialNumber> required for "gam info crostelemetry"')
filter_ = f'serialNumber={sys.argv[i]}'
i += 1
mode = 'show'
while i < len(sys.argv):
myarg = sys.argv[i].lower().replace('_', '')
if myarg == 'fields':
field_list = sys.argv[i+1].lower().split(',')
for field_item in field_list:
if field_item not in supported_readmask_map:
controlflow.expected_argument_exit('fields',
', '.join(supported_readmask_values),
field_item)
else:
readMask.append(supported_readmask_map[field_item])
i += 2
elif myarg in supported_readmask_map:
readMask.append(supported_readmask_map[myarg])
i += 1
elif myarg == 'filter':
filter_ = sys.argv[i+1]
i += 2
elif myarg in ['ou', 'org', 'orgunit']:
_, orgUnitId = gapi_directory_orgunits.getOrgUnitId(sys.argv[i + 1], None)
filter_ = f'orgUnitId={orgUnitId[3:]}'
i += 2
elif myarg == 'crossn':
filter_ = f'serialNumber={sys.argv[i + 1]}'
i += 2
elif myarg == 'todrive':
todrive = True
i += 1
elif myarg == 'showorgunitpath':
showOrgUnitPath = True
cd = gapi_directory.build()
i += 1
elif myarg == 'storagepercentonly':
diskpercentonly = True
i += 1
else:
msg = f'{myarg} is not a valid argument to "gam print crostelemetry"'
controlflow.system_error_exit(3, msg)
if not readMask:
readMask = ','.join(supported_readmask_values)
else:
if 'deviceId' not in readMask:
readMask.append('deviceId')
readMask = ','.join(readMask)
gam.printGettingAllItems('Chrome Device Telemetry...', filter_)
page_message = gapi.got_total_items_msg('Chrome Device Telemetry', '...\n')
devices = gapi.get_all_pages(cm.customers().telemetry().devices(),
'list',
'devices',
page_message=page_message,
parent=parent,
filter=filter_,
readMask=readMask)
for device in devices:
if 'totalDiskBytes' in device.get('storageInfo', {}) and 'availableDiskBytes' in device.get('storageInfo', {}):
disk_avail = int(device['storageInfo']['availableDiskBytes'])
disk_size = int(device['storageInfo']['totalDiskBytes'])
if diskpercentonly:
device['storageInfo'] = {}
device['storageInfo']['percentDiskFree'] = int((disk_avail / disk_size) * 100)
device['storageInfo']['percentDiskUsed'] = 100 - device['storageInfo']['percentDiskFree']
for cpuStatusReport in device.get('cpuStatusReport', []):
for tempInfo in cpuStatusReport.pop('cpuTemperatureInfo', []):
cpuStatusReport[f"cpuTemperatureInfo.{tempInfo['label'].strip()}"] = tempInfo['temperatureCelsius']
if showOrgUnitPath:
orgUnitId = device.get('orgUnitId')
if orgUnitId not in orgUnitIdPathMap:
orgUnitIdPathMap[orgUnitId] = gapi_directory_orgunits.orgunit_from_orgunitid(orgUnitId, cd)
device['orgUnitPath'] = orgUnitIdPathMap[orgUnitId]
if mode == 'show':
for device in devices:
display.print_json(device)
print()
print()
else:
csvRows = []
titles = []
for device in devices:
display.add_row_titles_to_csv_file(utils.flatten_json(device),
csvRows, titles)
display.write_csv_file(csvRows, titles, 'Telemetry Devices', todrive)
CHROME_VERSIONS_TITLES = [
'version', 'count', 'channel', 'deviceOsVersion', 'system'
]

View File

@@ -179,7 +179,7 @@ def build_schemas(svc=None, sfilter=None):
if fdesc.get('field') == setting_name:
for d in fdesc.get('knownValueDescriptions', []):
if d['value'][prefix_len:] == an:
setting_dict['descriptions'][i] = d['description']
setting_dict['descriptions'][i] = d.get('description', '')
break
break
break

View File

@@ -12,6 +12,14 @@ from gam.gapi import errors as gapi_errors
from gam.gapi import cloudidentity as gapi_cloudidentity
from gam.gapi.directory import customer as gapi_directory_customer
# This allows easy switching between v1 and v1beta1
# v1
CIGROUP_API_BETA = 'cloudidentity'
CIGROUP_MEMBERKEY = 'preferredMemberKey'
# v1beta1
#CIGROUP_API_BETA = 'cloudidentity_beta'
#CIGROUP_MEMBERKEY = 'memberKey'
def create():
ci = gapi_cloudidentity.build()
@@ -73,7 +81,7 @@ def delete():
def info():
ci = gapi_cloudidentity.build('cloudidentity_beta')
ci = gapi_cloudidentity.build(CIGROUP_API_BETA)
group = gam.normalizeEmailAddressOrUID(sys.argv[3])
getUsers = True
getSecuritySettings = True
@@ -126,7 +134,7 @@ def info():
print(' Members:')
for member in members:
role = get_single_role(member.get('roles', [])).lower()
email = member.get('preferredMemberKey', {}).get('id')
email = member.get(CIGROUP_MEMBERKEY, {}).get('id')
member_type = member.get('type', 'USER').lower()
jc_string = ''
if showJoinDate:
@@ -155,7 +163,7 @@ def print_member_tree(ci, group_id, cached_group_members, spaces, show_role):
for member in cached_group_members[group_id]:
member_id = member.get('name', '')
member_id = member_id.split('/')[-1]
email = member.get('preferredMemberKey', {}).get('id')
email = member.get(CIGROUP_MEMBERKEY, {}).get('id')
member_type = member.get('type', 'USER').lower()
if show_role:
role = get_single_role(member.get('roles', [])).lower()
@@ -197,7 +205,7 @@ GROUP_ROLES_MAP = {
def print_():
ci = gapi_cloudidentity.build('cloudidentity_beta')
ci = gapi_cloudidentity.build(CIGROUP_API_BETA)
i = 3
members = False
membersCountOnly = False
@@ -335,12 +343,12 @@ def print_():
)
page_message = gapi.got_total_items_first_last_msg('Members')
validRoles, _, _ = gam._getRoleVerification(
'.'.join(roles), 'nextPageToken,members(email,id,role)')
','.join(roles), 'nextPageToken,members(email,id,role)')
groupMembers = gapi.get_all_pages(ci.groups().memberships(),
'list',
'memberships',
page_message=page_message,
message_attribute=['preferredMemberKey', 'id'],
message_attribute=[CIGROUP_MEMBERKEY, 'id'],
soft_errors=True,
parent=groupKey_id,
view='BASIC')
@@ -354,7 +362,7 @@ def print_():
ownersList = []
ownersCount = 0
for member in groupMembers:
member_email = member['preferredMemberKey']['id']
member_email = member[CIGROUP_MEMBERKEY]['id']
role = get_single_role(member.get('roles', []))
if not validRoles or role in validRoles:
if role == ROLE_MEMBER:
@@ -447,7 +455,7 @@ def _get_groups_list(ci=None, member=None, parent=None):
def get_membership_graph(member):
ci = gapi_cloudidentity.build('cloudidentity_beta')
ci = gapi_cloudidentity.build(CIGROUP_API_BETA)
query = f"member_key_id == '{member}' && 'cloudidentity.googleapis.com/groups.discussion_forum' in labels"
result = gapi.call(ci.groups().memberships(),
'getMembershipGraph',
@@ -457,7 +465,7 @@ def get_membership_graph(member):
def print_members():
ci = gapi_cloudidentity.build('cloudidentity_beta')
ci = gapi_cloudidentity.build(CIGROUP_API_BETA)
todrive = False
gapi_directory_customer.setTrueCustomerId()
parent = f'customers/{GC_Values[GC_CUSTOMER_ID]}'
@@ -514,8 +522,8 @@ def print_members():
view='FULL',
pageSize=500,
page_message=page_message,
message_attribute=['preferredMemberKey', 'id'])
#fields='nextPageToken,memberships(preferredMemberKey,roles,createTime,updateTime)')
message_attribute=[CIGROUP_MEMBERKEY, 'id'])
#fields=f'nextPageToken,memberships({CIGROUP_MEMBERKEY},roles,createTime,updateTime)')
if roles:
group_members = filter_members_to_roles(group_members, roles)
for member in group_members:
@@ -573,7 +581,7 @@ def update():
]
return (role, expireTime, users_email)
ci = gapi_cloudidentity.build('cloudidentity_beta')
ci = gapi_cloudidentity.build(CIGROUP_API_BETA)
group = sys.argv[3]
myarg = sys.argv[4].lower()
items = []
@@ -600,7 +608,7 @@ def update():
items.append(item)
elif len(users_email) > 0:
body = {
'preferredMemberKey': {
CIGROUP_MEMBERKEY: {
'id': users_email[0]
},
'roles': [{
@@ -820,12 +828,12 @@ def update():
page_message=page_message,
throw_reasons=gapi_errors.MEMBERS_THROW_REASONS,
parent=parent,
fields='nextPageToken,memberships(preferredMemberKey,roles)')
fields=f'nextPageToken,memberships({CIGROUP_MEMBERKEY},roles)')
result = filter_members_to_roles(result, roles)
if not result:
print('Group already has 0 members')
return
users_email = [member['preferredMemberKey']['id'] for member in result]
users_email = [member[CIGROUP_MEMBERKEY]['id'] for member in result]
sys.stderr.write(
f'Group: {group}, Will remove {len(users_email)} {", ".join(roles).lower()}s.\n'
)

View File

@@ -3,3 +3,6 @@ import gam
def build():
return gam.buildGAPIObject('directory')
def build_beta():
return gam.buildGAPIObject('directory_beta')

View File

@@ -755,11 +755,11 @@ def doPrintCrosDevices():
cros['autoUpdateExpiration'])
row = {}
for attrib in cros:
if attrib not in set([
if attrib not in {
'kind', 'etag', 'tpmVersionInfo', 'recentUsers',
'activeTimeRanges', 'deviceFiles', 'cpuStatusReports',
'diskVolumeReports', 'systemRamFreeReports'
]):
}:
row[attrib] = cros[attrib]
if selectedLists.get('activeTimeRanges'):
timergs = cros.get('activeTimeRanges', [])

View File

@@ -9,6 +9,32 @@ from gam.gapi import directory as gapi_directory
from gam.gapi import errors as gapi_errors
def _getAllParentOrgUnitsForUser(user, cd=None):
if not cd:
cd = gapi_directory.build()
parent_path = gapi.call(cd.users(),
'get',
userKey=user,
fields='orgUnitPath',
projection='basic')['orgUnitPath']
if parent_path == '/':
orgUnitPath, orgUnitId = getOrgUnitId('/', cd)
return {orgUnitId: orgUnitPath}
parent_path = encodeOrgUnitPath(makeOrgUnitPathRelative(parent_path))
orgUnits = {}
while True:
result = gapi.call(cd.orgunits(),
'get',
customerId=GC_Values[GC_CUSTOMER_ID],
orgUnitPath=parent_path,
fields='orgUnitId,orgUnitPath,parentOrgUnitId')
orgUnits[result['orgUnitId']] = result['orgUnitPath']
if 'parentOrgUnitId' not in result:
break
parent_path = result['parentOrgUnitId']
return orgUnits
def create():
cd = gapi_directory.build()
name = getOrgUnitItem(sys.argv[3], pathOnly=True, absolutePath=False)
@@ -299,7 +325,7 @@ def update():
def orgUnitPathQuery(path, checkSuspended):
query = "orgUnitPath='{0}'".format(path.replace(
query = "orgUnitPath='{}'".format(path.replace(
"'", "\\'")) if path != '/' else ''
if checkSuspended is not None:
query += f' isSuspended={checkSuspended}'

View File

@@ -183,7 +183,7 @@ RESCAL_ARGUMENT_TO_PROPERTY_MAP = {
def printFeatures():
to_drive = False
cd = gapi_directory.build()
titles = []
titles = ['name']
csvRows = []
fieldsList = ['name']
fields = 'nextPageToken,features(%s)'

View File

@@ -0,0 +1,119 @@
import sys
from gam.var import GC_Values, GC_CUSTOMER_ID
import gam
from gam import controlflow
from gam import display
from gam import gapi
from gam.gapi import directory as gapi_directory
from gam.gapi.directory import orgunits as gapi_directory_orgunits
from gam.gapi.directory import roles as gapi_directory_roles
def create():
cd = gapi_directory.build()
user = gam.normalizeEmailAddressOrUID(sys.argv[3])
body = {'assignedTo': gam.convertEmailAddressToUID(user, cd)}
role = sys.argv[4]
body['roleId'] = gapi_directory_roles.getRoleId(role)
body['scopeType'] = sys.argv[5].upper()
i = 6
while i < len(sys.argv):
myarg = sys.argv[i].lower()
if myarg == 'condition':
cd = gapi_directory.build_beta()
body['condition'] = sys.argv[i+1]
if body['condition'] == 'securitygroup':
body['condition'] = "api.getAttribute('cloudidentity.googleapis.com/groups.labels', []).hasAny(['groups.security']) && resource.type == 'cloudidentity.googleapis.com/Group'"
elif body['condition'] == 'nonsecuritygroup':
body['condition'] = "!api.getAttribute('cloudidentity.googleapis.com/groups.labels', []).hasAny(['groups.security']) && resource.type == 'cloudidentity.googleapis.com/Group'"
i += 2
else:
controlflow.invalid_argument_exit(sys.argv[i], 'gam create admin')
if body['scopeType'] not in ['CUSTOMER', 'ORG_UNIT']:
controlflow.expected_argument_exit('scope type',
', '.join(['customer', 'org_unit']),
body['scopeType'])
if body['scopeType'] == 'ORG_UNIT':
orgUnit, orgUnitId = gapi_directory_orgunits.getOrgUnitId(
sys.argv[6], cd)
body['orgUnitId'] = orgUnitId[3:]
scope = f'ORG_UNIT {orgUnit}'
else:
scope = 'CUSTOMER'
print(f'Giving {user} admin role {role} for {scope}')
gapi.call(cd.roleAssignments(),
'insert',
customer=GC_Values[GC_CUSTOMER_ID],
body=body)
def delete():
cd = gapi_directory.build()
roleAssignmentId = sys.argv[3]
print(f'Deleting Admin Role Assignment {roleAssignmentId}')
gapi.call(cd.roleAssignments(),
'delete',
customer=GC_Values[GC_CUSTOMER_ID],
roleAssignmentId=roleAssignmentId)
def print_():
cd = gapi_directory.build()
roleId = None
todrive = False
kwargs = {}
item_fields = ['roleAssignmentId', 'roleId', 'assignedTo', 'scopeType', 'orgUnitId']
titles = [
'roleAssignmentId', 'roleId', 'role', 'assignedTo', 'assignedToUser',
'scopeType', 'orgUnitId', 'orgUnit'
]
csvRows = []
i = 3
while i < len(sys.argv):
myarg = sys.argv[i].lower()
if myarg == 'user':
kwargs['userKey'] = gam.normalizeEmailAddressOrUID(sys.argv[i + 1])
i += 2
elif myarg == 'role':
roleId = gapi_directory_roles.getRoleId(sys.argv[i + 1])
i += 2
elif myarg == 'condition':
cd = gapi_directory.build_beta()
item_fields.append('condition')
i += 1
elif myarg == 'todrive':
todrive = True
i += 1
else:
controlflow.invalid_argument_exit(sys.argv[i], 'gam print admins')
fields = f'nextPageToken,items({",".join(item_fields)})'
if roleId and not kwargs:
kwargs['roleId'] = roleId
roleId = None
admins = gapi.get_all_pages(cd.roleAssignments(),
'list',
'items',
customer=GC_Values[GC_CUSTOMER_ID],
fields=fields,
**kwargs)
for admin in admins:
if roleId and roleId != admin['roleId']:
continue
admin_attrib = {}
for key, value in list(admin.items()):
if key == 'assignedTo':
admin_attrib['assignedToUser'] = gam.user_from_userid(value)
elif key == 'roleId':
admin_attrib['role'] = gapi_directory_roles.role_from_roleid(value)
elif key == 'orgUnitId':
value = f'id:{value}'
admin_attrib[
'orgUnit'] = gapi_directory_orgunits.orgunit_from_orgunitid(
value, cd)
if key not in titles:
titles.append(key)
admin_attrib[key] = value
csvRows.append(admin_attrib)
display.write_csv_file(csvRows, titles, 'Admins', todrive)

View File

@@ -1,6 +1,13 @@
import sys
from gam.var import GC_Values, GC_CUSTOMER_ID
from gam.var import (
GC_Values,
GC_CUSTOMER_ID,
GM_Globals,
GM_MAP_ROLE_ID_TO_NAME,
GM_MAP_ROLE_NAME_TO_ID,
UID_PATTERN
)
import gam
from gam import controlflow
from gam import display
@@ -9,6 +16,47 @@ from gam.gapi import directory as gapi_directory
from gam.gapi.directory import privileges as gapi_directory_privileges
def buildRoleIdToNameToIdMap(cd=None):
if not cd:
cd = gapi_directory.build()
result = gapi.get_all_pages(cd.roles(),
'list',
'items',
customer=GC_Values[GC_CUSTOMER_ID],
fields='nextPageToken,items(roleId,roleName)')
GM_Globals[GM_MAP_ROLE_ID_TO_NAME] = {}
GM_Globals[GM_MAP_ROLE_NAME_TO_ID] = {}
for role in result:
GM_Globals[GM_MAP_ROLE_ID_TO_NAME][role['roleId']] = role['roleName']
GM_Globals[GM_MAP_ROLE_NAME_TO_ID][role['roleName']] = role['roleId']
def role_from_roleid(roleid):
if not GM_Globals[GM_MAP_ROLE_ID_TO_NAME]:
buildRoleIdToNameToIdMap()
return GM_Globals[GM_MAP_ROLE_ID_TO_NAME].get(roleid, roleid)
def roleid_from_role(role):
if not GM_Globals[GM_MAP_ROLE_NAME_TO_ID]:
buildRoleIdToNameToIdMap()
return GM_Globals[GM_MAP_ROLE_NAME_TO_ID].get(role, None)
def getRoleId(role):
cg = UID_PATTERN.match(role)
if cg:
roleId = cg.group(1)
else:
roleId = roleid_from_role(role)
if not roleId:
controlflow.system_error_exit(
4,
f'{role} is not a valid role. Please ensure role name is exactly as shown in admin console.'
)
return roleId
def getPrivileges(body, privs, action):
all_privileges = gapi_directory_privileges.print_(return_only=True)
if privs == 'ALL':
@@ -30,6 +78,7 @@ def getPrivileges(body, privs, action):
controlflow.invalid_argument_exit(priv,
f'gam {action} adminrole privileges')
def create():
cd = gapi_directory.build()
body = {'roleName': sys.argv[3]}
@@ -55,6 +104,7 @@ def create():
customer=GC_Values[GC_CUSTOMER_ID],
body=body)
def update():
cd = gapi_directory.build()
body = {}
@@ -122,3 +172,4 @@ def print_():
role_attrib[key] = value
csvRows.append(role_attrib)
display.write_csv_file(csvRows, titles, 'Admin Roles', todrive)

View File

@@ -1,11 +1,28 @@
import sys
from time import sleep
import gam
from gam import display
from gam import gapi
from gam.gapi import directory as gapi_directory
from gam.gapi import errors as gapi_errors
def delete():
cd = gapi_directory.build()
user_email = gam.normalizeEmailAddressOrUID(sys.argv[3])
print(f'Deleting account for {user_email}')
try:
gapi.call(cd.users(),
'delete',
userKey=user_email,
throw_reasons=[gapi_errors.ErrorReason.CONDITION_NOT_MET])
except gam.gapi.errors.GapiConditionNotMetError as err:
display.print_error(
f'{err} The user {user_email} may be (or have recently been) on Google Vault Hold and thus not eligible for deletion. You can check holds with "gam user <email> show vaultholds".'
)
def get_primary(email):
'''returns primary email of user or empty if email is not a user primary or
alias address.'''

View File

@@ -1,10 +1,9 @@
"""GAPI and OAuth Token related errors methods."""
from enum import Enum
import json
from enum import Enum
from gam import controlflow
from gam import display
from gam import controlflow, display
from gam.var import UTF8
@@ -282,7 +281,7 @@ def get_gapi_error_detail(e,
Args:
e: googleapiclient.HttpError, The HTTP Error received.
soft_errors: Boolean, If true, causes error messages to be surpressed,
soft_errors: Boolean, If true, causes error messages to be suppressed,
rather than sending them to stderr.
silent_errors: Boolean, If true, suppresses and ignores any errors from
being displayed

View File

@@ -504,9 +504,9 @@ def showReport():
purge_parameters = True
for event in events:
for item in event.get('parameters', []):
if set(item) == set(['value', 'name']):
if set(item) == {'value', 'name'}:
event[item['name']] = item['value']
elif set(item) == set(['intValue', 'name']):
elif set(item) == {'intValue', 'name'}:
if item['name'] in ['start_time', 'end_time']:
val = item.get('intValue')
if val is not None:
@@ -517,9 +517,9 @@ def showReport():
val-62135683200).isoformat()
else:
event[item['name']] = item['intValue']
elif set(item) == set(['boolValue', 'name']):
elif set(item) == {'boolValue', 'name'}:
event[item['name']] = item['boolValue']
elif set(item) == set(['multiValue', 'name']):
elif set(item) == {'multiValue', 'name'}:
event[item['name']] = ' '.join(item['multiValue'])
elif item['name'] == 'scope_data':
parts = {}

View File

@@ -12,6 +12,7 @@ from gam import display
from gam import fileutils
from gam import gapi
from gam.gapi import storage as gapi_storage
from gam.gapi import directory as gapi_directory
from gam.gapi.directory import orgunits as gapi_directory_orgunits
from gam import utils
@@ -667,6 +668,37 @@ def updateHold():
accountId=accountId)
def showHoldsForUsers(users):
cd = gapi_directory.build()
v = buildGAPIObject()
matterIds = _getAllMatterIds(v)
matterHolds = {}
for matterId in matterIds:
matterHolds[matterId] = gapi.get_all_pages(v.matters().holds(),
'list',
'holds',
fields='holds(holdId,name,accounts(accountId,email),orgUnit),nextPageToken',
matterId=matterId)
totalHolds = 0
for user in users:
user = user.lower()
orgUnits = gapi_directory_orgunits._getAllParentOrgUnitsForUser(user, cd)
for matterId in matterIds:
for hold in matterHolds[matterId]:
if 'orgUnit' in hold:
orgUnitId = hold['orgUnit'].get('orgUnitId')
if orgUnitId in orgUnits:
print(f'FOUND: OrgUnit {orgUnits[orgUnitId]} for user {user} is on hold in matterId {matterId} and holdId {hold["holdId"]} named "{hold["name"]}"')
totalHolds += 1
else:
for account in hold.get('accounts', []):
if (user == account.get('email', '').lower()) or (user == account.get('accountId', '')):
print(f'FOUND: User account {user} is on hold in matterId {matterId} and holdId {hold["holdId"]} named "{hold["name"]}"')
totalHolds += 1
break
sys.stdout.write(f'Total Holds: {totalHolds}\n')
def updateMatter(action=None):
v = buildGAPIObject()
matterId = getMatterItem(v, sys.argv[3])
@@ -790,8 +822,7 @@ def downloadExport():
done = False
while not done:
status, done = downloader.next_chunk()
sys.stdout.write(' Downloaded: {0:>7.2%}\r'.format(
status.progress()))
sys.stdout.write(f' Downloaded: {status.progress():>7.2%}\r')
sys.stdout.flush()
sys.stdout.write('\n Download complete. Flushing to disk...\n')
fileutils.close_file(f, True)
@@ -894,6 +925,19 @@ def printExports():
display.write_csv_file(csvRows, titles, 'Vault Exports', todrive)
def _getAllMatterIds(v=None, state='OPEN'):
if not v:
v = buildGAPIObject()
fields = 'matters(matterId),nextPageToken'
results = gapi.get_all_pages(v.matters(),
'list',
'matters',
view='BASIC',
state=state,
fields=fields)
return [matter['matterId'] for matter in results]
def printHolds():
v = buildGAPIObject()
todrive = False
@@ -914,20 +958,15 @@ def printHolds():
else:
controlflow.invalid_argument_exit(myarg, 'gam print holds')
if not matters:
fields = 'matters(matterId),nextPageToken'
matters_results = gapi.get_all_pages(v.matters(),
'list',
'matters',
view='BASIC',
state='OPEN',
fields=fields)
for matter in matters_results:
matterIds.append(matter['matterId'])
matterIds = _getAllMatterIds(v)
else:
for matter in matters:
matterIds.append(getMatterItem(v, matter))
i = 0
matter_count = len(matterIds)
for matterId in matterIds:
sys.stderr.write(f'Retrieving holds for matter {matterId}\n')
i += 1
sys.stderr.write(f'Retrieving holds for matter {matterId} ({i}/{matter_count})\n')
holds = gapi.get_all_pages(v.matters().holds(),
'list',
'holds',

View File

@@ -90,7 +90,7 @@ class Request(google_auth_httplib2.Request):
@_force_user_agent(GAM_USER_AGENT)
def __call__(self, *args, **kwargs):
"""Inserts the GAM user-agent header in requests."""
return super(Request, self).__call__(*args, **kwargs)
return super().__call__(*args, **kwargs)
class AuthorizedHttp(google_auth_httplib2.AuthorizedHttp):
@@ -99,4 +99,4 @@ class AuthorizedHttp(google_auth_httplib2.AuthorizedHttp):
@_force_user_agent(GAM_USER_AGENT)
def request(self, *args, **kwargs):
"""Inserts the GAM user-agent header in requests."""
return super(AuthorizedHttp, self).request(*args, **kwargs)
return super().request(*args, **kwargs)

View File

@@ -15,7 +15,7 @@ class CreateHttpTest(unittest.TestCase):
def setUp(self):
SetGlobalVariables()
super(CreateHttpTest, self).setUp()
super().setUp()
def test_create_http_sets_default_values_on_http(self):
http = transport.create_http()
@@ -56,7 +56,7 @@ class TransportTest(unittest.TestCase):
self.mock_content)
self.mock_credentials = MagicMock()
self.test_uri = 'http://example.com'
super(TransportTest, self).setUp()
super().setUp()
@patch.object(transport, 'create_http')
def test_create_request_uses_default_http(self, mock_create_http):

View File

@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import datetime
import re
import sys
@@ -32,7 +28,7 @@ class LazyLoader(types.ModuleType):
self._local_name = local_name
self._parent_module_globals = parent_module_globals
super(LazyLoader, self).__init__(name)
super().__init__(name)
def _load(self):
# Import the target module and insert it into the parent's namespace
@@ -123,7 +119,7 @@ def dehtml(text):
def indentMultiLineText(message, n=0):
return message.replace('\n', '\n{0}'.format(' ' * n)).rstrip()
return message.replace('\n', f"\n{' ' * n}").rstrip()
def flatten_json(structure, key='', path='', flattened=None, listLimit=None):

View File

@@ -8,7 +8,7 @@ import platform
import re
GAM_AUTHOR = 'Jay Lee <jay0lee@gmail.com>'
GAM_VERSION = '6.11'
GAM_VERSION = '6.15'
GAM_LICENSE = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
GAM_URL = 'https://git.io/gam'
@@ -17,11 +17,11 @@ GAM_INFO = (
f'Python {platform.python_version()} {sys.version_info.releaselevel} / '
f'{platform.platform()} {platform.machine()}')
GAM_RELEASES = 'https://github.com/jay0lee/GAM/releases'
GAM_WIKI = 'https://github.com/jay0lee/GAM/wiki'
GAM_ALL_RELEASES = 'https://api.github.com/repos/jay0lee/GAM/releases'
GAM_RELEASES = 'https://github.com/GAM-team/GAM/releases'
GAM_WIKI = 'https://github.com/GAM-team/GAM/wiki'
GAM_ALL_RELEASES = 'https://api.github.com/repos/GAM-team/GAM/releases'
GAM_LATEST_RELEASE = GAM_ALL_RELEASES + '/latest'
GAM_PROJECT_FILEPATH = 'https://raw.githubusercontent.com/jay0lee/GAM/master/src/'
GAM_PROJECT_FILEPATH = 'https://raw.githubusercontent.com/GAM-team/GAM/master/src/'
true_values = ['on', 'yes', 'enabled', 'true', '1']
false_values = ['off', 'no', 'disabled', 'false', '0']
@@ -292,6 +292,7 @@ V1_DISCOVERY_APIS = {
API_NAME_MAPPING = {
'directory': 'admin',
'directory_beta': 'admin',
'reports': 'admin',
'datatransfer': 'admin',
'drive3': 'drive',
@@ -313,6 +314,7 @@ API_VER_MAPPING = {
'contactdelegation': 'v1',
'datatransfer': 'datatransfer_v1',
'directory': 'directory_v1',
'directory_beta': 'directory_v1.1beta1',
'drive': 'v2',
'drive3': 'v3',
'gmail': 'v1',
@@ -458,6 +460,7 @@ DRIVEFILE_FIELDS_CHOICES_MAP = {
'createddate': 'createdDate',
'createdtime': 'createdDate',
'description': 'description',
'driveid': 'driveId',
'editable': 'editable',
'explicitlytrashed': 'explicitlyTrashed',
'fileextension': 'fileExtension',
@@ -1075,7 +1078,7 @@ COLLABORATIVE_INBOX_ATTRIBUTES = [
'favoriteRepliesOnTop',
]
GROUP_SETTINGS_LIST_ATTRIBUTES = set([
GROUP_SETTINGS_LIST_ATTRIBUTES = {
# ACL choices
'whoCanAdd',
'whoCanApproveMembers',
@@ -1116,8 +1119,8 @@ GROUP_SETTINGS_LIST_ATTRIBUTES = set([
'messageModerationLevel',
'replyTo',
'spamModerationLevel',
])
GROUP_SETTINGS_BOOLEAN_ATTRIBUTES = set([
}
GROUP_SETTINGS_BOOLEAN_ATTRIBUTES = {
'allowExternalMembers',
'allowGoogleCommunication',
'allowWebPosting',
@@ -1130,7 +1133,7 @@ GROUP_SETTINGS_BOOLEAN_ATTRIBUTES = set([
'membersCanPostAsTheGroup',
'sendMessageDenyNotification',
'showInGroupDirectory',
])
}
#
# Global variables
@@ -1290,7 +1293,7 @@ GC_TLS_MAX_VERSION = 'tls_max_ver'
# Path to certificate authority file for validating TLS hosts
GC_CA_FILE = 'ca_file'
TLS_MIN = 'TLSv1_2' if hasattr(ssl.SSLContext(), 'minimum_version') else None
TLS_MIN = 'TLSv1_3' if hasattr(ssl.SSLContext(), 'minimum_version') else None
GC_Defaults = {
GC_ADMIN_EMAIL: '',
GC_AUTO_BATCH_MIN: 0,

View File

@@ -8,6 +8,6 @@ google-auth>=2.3.2
httplib2>=0.17.0
importlib.metadata; python_version < '3.8'
passlib>=1.7.2
pathvalidate
python-dateutil
yubikey-manager>=4.0.0
pathvalidate

View File

@@ -1,10 +1,10 @@
[metadata]
name = GAM for Google Workspace
version = 6.0.7
version = 6.0.14
description = Command line management for Google Workspaces
long_description = file: readme.md
long_description_content_type = text/markdown
url = https://github.com/jay0lee/GAM
url = https://github.com/GAM-team/GAM
author = Jay Lee
author_email = jay0lee@gmail.com
license = Apache
@@ -13,26 +13,26 @@ keywords = google, oauth2, gsuite, google-apps, google-admin-sdk, google-drive,
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
License :: OSI Approved :: Apache License
[options]
packages = find:
python_requires = >=3.6
python_requires = >= 3.7
install_requires =
cryptography
distro; sys_platform == 'linux'
filelock
google-api-python-client >= 2.1
google-api-python-client >= 2.36
google-auth-httplib2
google-auth-oauthlib >= 0.4.1
google-auth >= 1.11.2
httplib2 >= 0.17.0
google-auth-oauthlib >= 0.4.6
google-auth >= 2.3.3
httplib2 >= 0.20.2
importlib.metadata; python_version < '3.8'
passlib >= 1.7.2
passlib >= 1.7.4
python-dateutil
yubikey-manager >= 4.0.0
pathvalidate

View File

@@ -7,7 +7,7 @@ a = sys.argv[1]
b = sys.argv[2]
result = version.parse(a) >= version.parse(b)
if result:
print('OK: %s is equal or newer than %s' % (a, b))
print(f'OK: {a} is equal or newer than {b}')
else:
print('ERROR: %s is older than %s' % (a, b))
print(f'ERROR: {a} is older than {b}')
sys.exit(not result)

30
src/tools/openssl.props Normal file
View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(opensslIncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(opensslOutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>ws2_32.lib;libcrypto.lib;libssl.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<PropertyGroup>
<_DLLSuffix>-3</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'ARM'">$(_DLLSuffix)-arm</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'ARM64'">$(_DLLSuffix)-arm64</_DLLSuffix>
<_DLLSuffix Condition="$(Platform) == 'x64'">$(_DLLSuffix)-x64</_DLLSuffix>
</PropertyGroup>
<ItemGroup>
<_SSLDLL Include="$(opensslOutDir)\libcrypto$(_DLLSuffix).dll" />
<_SSLDLL Include="$(opensslOutDir)\libcrypto$(_DLLSuffix).pdb" />
<_SSLDLL Include="$(opensslOutDir)\libssl$(_DLLSuffix).dll" />
<_SSLDLL Include="$(opensslOutDir)\libssl$(_DLLSuffix).pdb" />
</ItemGroup>
<Target Name="_CopySSLDLL" Inputs="@(_SSLDLL)" Outputs="@(_SSLDLL->'$(OutDir)%(Filename)%(Extension)')" AfterTargets="Build">
<Copy SourceFiles="@(_SSLDLL)" DestinationFolder="$(OutDir)" />
</Target>
<Target Name="_CleanSSLDLL" BeforeTargets="Clean">
<Delete Files="@(_SSLDLL->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
</Target>
</Project>

View File

@@ -1,486 +0,0 @@
{
"revision": "20210322",
"name": "versionhistory",
"mtlsRootUrl": "https://versionhistory.mtls.googleapis.com/",
"version_module": true,
"basePath": "",
"title": "Version History API",
"kind": "discovery#restDescription",
"servicePath": "",
"ownerDomain": "google.com",
"parameters": {
"access_token": {
"location": "query",
"description": "OAuth access token.",
"type": "string"
},
"alt": {
"default": "json",
"location": "query",
"enum": [
"json",
"media",
"proto"
],
"type": "string",
"enumDescriptions": [
"Responses with Content-Type of application/json",
"Media download with context-dependent Content-Type",
"Responses with Content-Type of application/x-protobuf"
],
"description": "Data format for response."
},
"quotaUser": {
"type": "string",
"description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.",
"location": "query"
},
"$.xgafv": {
"location": "query",
"enumDescriptions": [
"v1 error format",
"v2 error format"
],
"enum": [
"1",
"2"
],
"description": "V1 error format.",
"type": "string"
},
"fields": {
"type": "string",
"description": "Selector specifying which fields to include in a partial response.",
"location": "query"
},
"key": {
"description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
"location": "query",
"type": "string"
},
"callback": {
"location": "query",
"description": "JSONP",
"type": "string"
},
"oauth_token": {
"description": "OAuth 2.0 token for the current user.",
"location": "query",
"type": "string"
},
"upload_protocol": {
"location": "query",
"type": "string",
"description": "Upload protocol for media (e.g. \"raw\", \"multipart\")."
},
"prettyPrint": {
"description": "Returns response with indentations and line breaks.",
"default": "true",
"location": "query",
"type": "boolean"
},
"uploadType": {
"description": "Legacy upload protocol for media (e.g. \"media\", \"multipart\").",
"type": "string",
"location": "query"
}
},
"ownerName": "Google",
"protocol": "rest",
"resources": {
"platforms": {
"methods": {
"list": {
"httpMethod": "GET",
"parameterOrder": [
"parent"
],
"response": {
"$ref": "ListPlatformsResponse"
},
"path": "v1/{+parent}/platforms",
"description": "Returns list of platforms that are avaialble for a given product. The resource \"product\" has no resource name in its name.",
"flatPath": "v1/{v1Id}/platforms",
"id": "versionhistory.platforms.list",
"parameters": {
"parent": {
"location": "path",
"pattern": "^[^/]+$",
"type": "string",
"required": true,
"description": "Required. The product, which owns this collection of platforms. Format: {product}"
},
"pageSize": {
"format": "int32",
"description": "Optional. Optional limit on the number of channels to include in the response. If unspecified, the server will pick an appropriate default.",
"type": "integer",
"location": "query"
},
"pageToken": {
"location": "query",
"description": "Optional. A page token, received from a previous `ListChannels` call. Provide this to retrieve the subsequent page.",
"type": "string"
}
}
}
},
"resources": {
"channels": {
"resources": {
"versions": {
"resources": {
"releases": {
"methods": {
"list": {
"id": "versionhistory.platforms.channels.versions.releases.list",
"path": "v1/{+parent}/releases",
"httpMethod": "GET",
"parameterOrder": [
"parent"
],
"response": {
"$ref": "ListReleasesResponse"
},
"flatPath": "v1/{v1Id}/platforms/{platformsId}/channels/{channelsId}/versions/{versionsId}/releases",
"parameters": {
"parent": {
"type": "string",
"required": true,
"description": "Required. The version, which owns this collection of releases. Format: {product}/platforms/{platform}/channels/{channel}/versions/{version}",
"pattern": "^[^/]+/platforms/[^/]+/channels/[^/]+/versions/[^/]+$",
"location": "path"
},
"filter": {
"type": "string",
"location": "query",
"description": "Optional. Filter string. Format is a comma separated list of All comma separated filter clauses are conjoined with a logical \"and\". Valid field_names are \"version\", \"name\", \"platform\", \"channel\", \"fraction\" \"starttime\", and \"endtime\". Valid operators are \"\u003c\", \"\u003c=\", \"=\", \"\u003e=\", and \"\u003e\". Channel comparison is done by distance from stable. must be a valid channel when filtering by channel. Ex) stable \u003c beta, beta \u003c dev, canary \u003c canary_asan. Version comparison is done numerically. Ex) 1.0.0.8 \u003c 1.0.0.10. If version is not entirely written, the version will be appended with 0 for the missing fields. Ex) version \u003e 80 becoms version \u003e 80.0.0.0 When filtering by starttime or endtime, string must be in RFC 3339 date string format. Name and platform are filtered by string comparison. Ex) \"...?filter=channel\u003c=beta, version \u003e= 80 Ex) \"...?filter=version \u003e 80, version \u003c 81 Ex) \"...?filter=starttime\u003e2020-01-01T00:00:00Z"
},
"orderBy": {
"location": "query",
"description": "Optional. Ordering string. Valid order_by strings are \"version\", \"name\", \"starttime\", \"endtime\", \"platform\", \"channel\", and \"fraction\". Optionally, you can append \"desc\" or \"asc\" to specify the sorting order. Multiple order_by strings can be used in a comma separated list. Ordering by channel will sort by distance from the stable channel (not alphabetically). A list of channels sorted in this order is: stable, beta, dev, canary, and canary_asan. Sorting by name may cause unexpected behaviour as it is a naive string sort. For example, 1.0.0.8 will be before 1.0.0.10 in descending order. If order_by is not specified the response will be sorted by starttime in descending order. Ex) \"...?order_by=starttime asc\" Ex) \"...?order_by=platform desc, channel, startime desc\"",
"type": "string"
},
"pageSize": {
"location": "query",
"format": "int32",
"description": "Optional. Optional limit on the number of releases to include in the response. If unspecified, the server will pick an appropriate default.",
"type": "integer"
},
"pageToken": {
"description": "Optional. A page token, received from a previous `ListReleases` call. Provide this to retrieve the subsequent page.",
"location": "query",
"type": "string"
}
},
"description": "Returns list of releases of the given version."
}
}
}
},
"methods": {
"list": {
"response": {
"$ref": "ListVersionsResponse"
},
"path": "v1/{+parent}/versions",
"parameters": {
"pageSize": {
"location": "query",
"format": "int32",
"description": "Optional. Optional limit on the number of versions to include in the response. If unspecified, the server will pick an appropriate default.",
"type": "integer"
},
"pageToken": {
"description": "Optional. A page token, received from a previous `ListVersions` call. Provide this to retrieve the subsequent page.",
"location": "query",
"type": "string"
},
"parent": {
"required": true,
"location": "path",
"description": "Required. The channel, which owns this collection of versions. Format: {product}/platforms/{platform}/channels/{channel}",
"pattern": "^[^/]+/platforms/[^/]+/channels/[^/]+$",
"type": "string"
},
"orderBy": {
"type": "string",
"location": "query",
"description": "Optional. Ordering string. Valid order_by strings are \"version\", \"name\", \"platform\", and \"channel\". Optionally, you can append \" desc\" or \" asc\" to specify the sorting order. Multiple order_by strings can be used in a comma separated list. Ordering by channel will sort by distance from the stable channel (not alphabetically). A list of channels sorted in this order is: stable, beta, dev, canary, and canary_asan. Sorting by name may cause unexpected behaviour as it is a naive string sort. For example, 1.0.0.8 will be before 1.0.0.10 in descending order. If order_by is not specified the response will be sorted by version in descending order. Ex) \"...?order_by=version asc\" Ex) \"...?order_by=platform desc, channel, version\""
},
"filter": {
"description": "Optional. Filter string. Format is a comma separated list of All comma separated filter clauses are conjoined with a logical \"and\". Valid field_names are \"version\", \"name\", \"platform\", and \"channel\". Valid operators are \"\u003c\", \"\u003c=\", \"=\", \"\u003e=\", and \"\u003e\". Channel comparison is done by distance from stable. Ex) stable \u003c beta, beta \u003c dev, canary \u003c canary_asan. Version comparison is done numerically. If version is not entirely written, the version will be appended with 0 in missing fields. Ex) version \u003e 80 becoms version \u003e 80.0.0.0 Name and platform are filtered by string comparison. Ex) \"...?filter=channel\u003c=beta, version \u003e= 80 Ex) \"...?filter=version \u003e 80, version \u003c 81",
"location": "query",
"type": "string"
}
},
"id": "versionhistory.platforms.channels.versions.list",
"parameterOrder": [
"parent"
],
"description": "Returns list of version for the given platform/channel.",
"flatPath": "v1/{v1Id}/platforms/{platformsId}/channels/{channelsId}/versions",
"httpMethod": "GET"
}
}
}
},
"methods": {
"list": {
"response": {
"$ref": "ListChannelsResponse"
},
"parameterOrder": [
"parent"
],
"parameters": {
"pageToken": {
"type": "string",
"location": "query",
"description": "Optional. A page token, received from a previous `ListChannels` call. Provide this to retrieve the subsequent page."
},
"parent": {
"location": "path",
"type": "string",
"required": true,
"pattern": "^[^/]+/platforms/[^/]+$",
"description": "Required. The platform, which owns this collection of channels. Format: {product}/platforms/{platform}"
},
"pageSize": {
"format": "int32",
"type": "integer",
"description": "Optional. Optional limit on the number of channels to include in the response. If unspecified, the server will pick an appropriate default.",
"location": "query"
}
},
"path": "v1/{+parent}/channels",
"httpMethod": "GET",
"flatPath": "v1/{v1Id}/platforms/{platformsId}/channels",
"id": "versionhistory.platforms.channels.list",
"description": "Returns list of channels that are available for a given platform."
}
}
}
}
}
},
"description": "Version History API - Prod",
"discoveryVersion": "v1",
"schemas": {
"Channel": {
"id": "Channel",
"type": "object",
"description": "Each Channel is owned by a Platform and owns a collection of versions. Possible Channels are listed in the Channel enum below. Not all Channels are available for every Platform (e.g. CANARY does not exist for LINUX).",
"properties": {
"name": {
"description": "Channel name. Format is \"{product}/platforms/{platform}/channels/{channel}\"",
"type": "string"
},
"channelType": {
"description": "Type of channel.",
"enumDescriptions": [
"",
"",
"",
"",
"",
"",
"",
""
],
"type": "string",
"enum": [
"CHANNEL_TYPE_UNSPECIFIED",
"STABLE",
"BETA",
"DEV",
"CANARY",
"CANARY_ASAN",
"ALL",
"EXTENDED"
]
}
}
},
"Interval": {
"description": "Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.",
"type": "object",
"id": "Interval",
"properties": {
"endTime": {
"type": "string",
"format": "google-datetime",
"description": "Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end."
},
"startTime": {
"format": "google-datetime",
"type": "string",
"description": "Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start."
}
}
},
"ListVersionsResponse": {
"description": "Response message for ListVersions.",
"type": "object",
"properties": {
"versions": {
"type": "array",
"description": "The list of versions.",
"items": {
"$ref": "Version"
}
},
"nextPageToken": {
"description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.",
"type": "string"
}
},
"id": "ListVersionsResponse"
},
"ListChannelsResponse": {
"description": "Response message for ListChannels.",
"id": "ListChannelsResponse",
"type": "object",
"properties": {
"nextPageToken": {
"description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.",
"type": "string"
},
"channels": {
"description": "The list of channels.",
"type": "array",
"items": {
"$ref": "Channel"
}
}
}
},
"Platform": {
"properties": {
"platformType": {
"enum": [
"PLATFORM_TYPE_UNSPECIFIED",
"WIN",
"WIN64",
"MAC",
"LINUX",
"ANDROID",
"WEBVIEW",
"IOS",
"ALL",
"MAC_ARM64",
"LACROS"
],
"description": "Type of platform.",
"enumDescriptions": [
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
],
"type": "string"
},
"name": {
"description": "Platform name. Format is \"{product}/platforms/{platform}\"",
"type": "string"
}
},
"id": "Platform",
"type": "object",
"description": "Each Platform is owned by a Product and owns a collection of channels. Available platforms are listed in Platform enum below. Not all Channels are available for every Platform (e.g. CANARY does not exist for LINUX)."
},
"Version": {
"properties": {
"version": {
"description": "String containing just the version number. e.g. \"84.0.4147.38\"",
"type": "string"
},
"name": {
"description": "Version name. Format is \"{product}/platforms/{platform}/channels/{channel}/versions/{version}\" e.g. \"chrome/platforms/win/channels/beta/versions/84.0.4147.38\"",
"type": "string"
}
},
"id": "Version",
"type": "object",
"description": "Each Version is owned by a Channel. A Version only displays the Version number (e.g. 84.0.4147.38). A Version owns a collection of releases."
},
"ListPlatformsResponse": {
"description": "Response message for ListPlatforms.",
"id": "ListPlatformsResponse",
"type": "object",
"properties": {
"nextPageToken": {
"type": "string",
"description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages."
},
"platforms": {
"type": "array",
"items": {
"$ref": "Platform"
},
"description": "The list of platforms."
}
}
},
"ListReleasesResponse": {
"type": "object",
"id": "ListReleasesResponse",
"description": "Response message for ListReleases.",
"properties": {
"nextPageToken": {
"description": "A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.",
"type": "string"
},
"releases": {
"description": "The list of releases.",
"items": {
"$ref": "Release"
},
"type": "array"
}
}
},
"Release": {
"properties": {
"fraction": {
"format": "double",
"type": "number",
"description": "Rollout fraction. This fraction indicates the fraction of people that should receive this version in this release. If the fraction is not specified in ReleaseManager, the API will assume fraction is 1."
},
"version": {
"type": "string",
"description": "String containing just the version number. e.g. \"84.0.4147.38\""
},
"name": {
"type": "string",
"description": "Release name. Format is \"{product}/platforms/{platform}/channels/{channel}/versions/{version}/releases/{release}\""
},
"serving": {
"description": "Timestamp interval of when the release was live. If end_time is unspecified, the release is currently live.",
"$ref": "Interval"
}
},
"type": "object",
"description": "A Release is owned by a Version. A Release contains information about the release(s) of its parent version. This includes when the release began and ended, as well as what percentage it was released at. If the version is released again, or if the serving percentage changes, it will create another release under the version.",
"id": "Release"
}
},
"fullyEncodeReservedExpansion": true,
"documentationLink": "https://developers.chrome.com/",
"icons": {
"x16": "http://www.google.com/images/icons/product/search-16.gif",
"x32": "http://www.google.com/images/icons/product/search-32.gif"
},
"baseUrl": "https://versionhistory.googleapis.com/",
"batchPath": "batch",
"version": "v1",
"canonicalName": "Version History",
"id": "versionhistory:v1",
"rootUrl": "https://versionhistory.googleapis.com/"
}