FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Directory Synchronisation Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Information Services
DevOps
Google WorkSpace (aka G-Suite)
Directory Synchronisation Tool
Commits
0fd47a5b
Commit
0fd47a5b
authored
4 years ago
by
Robin Goodall
Browse files
Options
Downloads
Patches
Plain Diff
Update group settings for newly created groups even without --group-settings flag
parent
42062597
No related branches found
No related tags found
1 merge request
!13
Add --group-settings option
Pipeline
#47909
passed
4 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gsuitesync/sync.py
+14
-15
14 additions, 15 deletions
gsuitesync/sync.py
with
14 additions
and
15 deletions
gsuitesync/sync.py
+
14
−
15
View file @
0fd47a5b
...
...
@@ -267,9 +267,8 @@ def sync(configuration, *, read_only=True, group_settings=False):
# Build the directory service using Google API discovery.
directory_service
=
discovery
.
build
(
'
admin
'
,
'
directory_v1
'
,
credentials
=
creds
)
if
group_settings
:
# Also build the groupssettings service, which is a parallel API to manage group settings
groupssettings_service
=
discovery
.
build
(
'
groupssettings
'
,
'
v1
'
,
credentials
=
creds
)
# Also build the groupssettings service, which is a parallel API to manage group settings
groupssettings_service
=
discovery
.
build
(
'
groupssettings
'
,
'
v1
'
,
credentials
=
creds
)
# Retrieve information on all users excluding domain admins.
LOG
.
info
(
'
Getting information on Google domain users
'
)
...
...
@@ -733,13 +732,17 @@ def sync(configuration, *, read_only=True, group_settings=False):
LOG
.
info
(
'
Updating settings for new group
"
%s
"
: %s
'
,
gid
,
settings
)
yield
groupssettings_service
.
groups
().
patch
(
groupUniqueId
=
email
,
body
=
settings
)
# Apply any settings that differ to pre-existing groups.
for
gid
,
settings
in
all_google_group_settings_by_gid
.
items
():
patch
=
{
k
:
v
for
k
,
v
in
sync_config
.
group_settings
.
items
()
if
settings
.
get
(
k
)
!=
v
}
if
patch
:
email
=
gid_to_email
(
gid
)
LOG
.
info
(
'
Updating settings for existing group
"
%s
"
: %s
'
,
gid
,
patch
)
yield
groupssettings_service
.
groups
().
patch
(
groupUniqueId
=
email
,
body
=
patch
)
if
group_settings
:
# Apply any settings that differ to pre-existing groups.
for
gid
,
settings
in
all_google_group_settings_by_gid
.
items
():
patch
=
{
k
:
v
for
k
,
v
in
sync_config
.
group_settings
.
items
()
if
settings
.
get
(
k
)
!=
v
}
if
patch
:
email
=
gid_to_email
(
gid
)
LOG
.
info
(
'
Updating settings for existing group
"
%s
"
: %s
'
,
gid
,
patch
)
yield
groupssettings_service
.
groups
().
patch
(
groupUniqueId
=
email
,
body
=
patch
)
else
:
LOG
.
info
(
'
Skipping updating settings for existing groups
'
)
# A generator which will generate insert() and delete() calls to the directory service to
# perform the actions required to update group members
...
...
@@ -793,11 +796,7 @@ def sync(configuration, *, read_only=True, group_settings=False):
# Process all the user, group and group member updates
process_requests
(
directory_service
,
user_api_requests
())
process_requests
(
directory_service
,
group_api_requests
())
if
group_settings
:
LOG
.
info
(
'
Performing group settings update
'
)
process_requests
(
groupssettings_service
,
group_settings_api_requests
())
else
:
LOG
.
info
(
'
Skipping group settings update
'
)
process_requests
(
groupssettings_service
,
group_settings_api_requests
())
process_requests
(
directory_service
,
member_api_requests
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment