-
Notifications
You must be signed in to change notification settings - Fork 88
/
clearGroup.py
53 lines (40 loc) · 1.46 KB
/
clearGroup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#### Remove (unshare) all items from a designated group in the organization
#### Group IDs can be discovered using this utility: http://developers.arcgis.com/javascript/samples/portal_getgroupamd/
#### Example:
#### clearGroup.py -u myuser -p mypassword -group a23455GROUPID334323434 -portal https://esri.maps.arcgis.com
import argparse
import sys
from agoTools.admin import Admin
def _raw_input(prompt=None, stream=None, input=None):
# A raw_input() replacement that doesn't save the string in the
# GNU readline history.
if not stream:
stream = sys.stderr
if not input:
input = sys.stdin
prompt = str(prompt)
if prompt:
stream.write(prompt)
stream.flush()
# NOTE: The Python C API calls flockfile() (and unlock) during readline.
line = input.readline()
if not line:
raise EOFError
if line[-1] == '\n':
line = line[:-1]
return line
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--user')
parser.add_argument('-p', '--password')
parser.add_argument('-portal', '--portal')
parser.add_argument('-group', '--group')
args = parser.parse_args()
if args.user == None:
args.user = _raw_input("Username:")
if args.portal == None:
args.portal = _raw_input("Portal: ")
if args.group == None:
args.group = _raw_input("Group ID: ")
args.portal = str(args.portal).replace("http://","https://")
agoAdmin = Admin(args.user,args.portal,args.password)
agoAdmin.clearGroup(args.group)