Skip to content

Commit 39f40f6

Browse files
committed
Re-add Admin SDK groups settings quickstart
1 parent 919793b commit 39f40f6

File tree

5 files changed

+39
-338
lines changed

5 files changed

+39
-338
lines changed

admin_sdk/directory/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Google Admin SDK Directory Python Quickstart
2+
3+
Complete the steps described in the [Google Admin SDK Directory Python
4+
Quickstart](https://developers.google.com/google-apps/Admin SDK
5+
Directory/quickstart/python), and in about five minutes you'll have a simple
6+
Python command-line application that makes requests to the Google Admin SDK
7+
Directory API.
8+
9+
## Install
10+
11+
```
12+
pip install --upgrade google-api-python-client
13+
```
14+
15+
## Run
16+
17+
```
18+
python quickstart.py
19+
```
Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,35 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START admin_sdk_groups_settings_quickstart]
15+
# [START admin_sdk_directory_quickstart]
1616
"""
17-
Shows basic usage of the Admin SDK Groups Settings API. Outputs a group's
18-
settings identified by the group's email address.
17+
Shows basic usage of the Admin SDK Directory API. Lists of first 10 users in the
18+
domain.
1919
"""
2020
from __future__ import print_function
21-
from apiclient.discovery import build, http
21+
from apiclient.discovery import build
2222
from httplib2 import Http
2323
from oauth2client import file, client, tools
24-
import StringIO
25-
import random
2624

27-
import apiclient
28-
from email import Utils
29-
from email import MIMEText
30-
31-
# Setup the Admin SDK Groups Migration API
32-
SCOPES = 'https://www.googleapis.com/auth/apps.groups.settings'
25+
# Setup the Admin SDK Directory API
26+
SCOPES = 'https://www.googleapis.com/auth/admin.directory.user'
3327
store = file.Storage('credentials.json')
3428
creds = store.get()
3529
if not creds or creds.invalid:
3630
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
3731
creds = tools.run_flow(flow, store)
38-
service = build('groupssettings', 'v1', http=creds.authorize(Http()))
32+
service = build('admin', 'directory_v1', http=creds.authorize(Http()))
33+
34+
# Call the Admin SDK Directory API
35+
print('Getting the first 10 users in the domain')
36+
results = service.users().list(customer='my_customer', maxResults=10,
37+
orderBy='email').execute()
38+
users = results.get('users', [])
3939

40-
groupEmail = raw_input('Enter the email address of a Google Group in your domain: ')
41-
try:
42-
results = service.groups().get(groupUniqueId=groupEmail,
43-
alt='json').execute()
44-
print(json.dumps(results, indent=4))
45-
except:
46-
print('Unable to read group: {0}'.format(groupEmail))
47-
raise
48-
# [END admin_sdk_groups_settings_quickstart]
40+
if not users:
41+
print('No users in the domain.')
42+
else:
43+
print('Users:')
44+
for user in users:
45+
print('{0} ({1})'.format(user['primaryEmail'], user['name']['fullName']))
46+
# [END admin_sdk_directory_quickstart]

admin_sdk/groups_settings/README.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

admin_sdk/groups_settings/detect_external_access.py

Lines changed: 0 additions & 135 deletions
This file was deleted.

admin_sdk/groups_settings/restrict_external_access.py

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)