-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
executable file
·30 lines (26 loc) · 1.52 KB
/
example.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
#!/usr/bin/env python3
import DockerHubAdmin
import argparse
parser = argparse.ArgumentParser(description='Python admin interface to Docker Hub')
parser.add_argument('-u','--username', help='Admin username for Docker Hub', required=True)
parser.add_argument('-p','--password', help='Admin password for Docker Hub', required=True)
parser.add_argument('-o','--organization', help='Password for Docker Hub', required=True)
parser.add_argument('--user', help='Non-Admin User Account on Docker Hub')
parser.add_argument('-t','--team', help='A Docker Hub Team')
parser.add_argument('--adduser', help='Add account to a Docker Hub Team', action='store_true')
parser.add_argument('--rmuser', help='Remove account from a Docker Hub Team', action='store_true')
parser.add_argument('--listmembers', help='List members of a Docker Hub Team', action='store_true')
parser.add_argument('--listteams', help='List all teams within an org', action='store_true')
parser.add_argument('--finduserteams', help='List all teams an account is a member of within an org', action='store_true')
args = parser.parse_args()
hub = DockerHubAdmin.DockerHubAdmin(args.username, args.password)
if args.listteams:
print(hub.listGroups(args.organization))
elif args.listmembers:
print(hub.listMembers(args.organization, args.team))
elif args.finduserteams:
print(hub.findUserGroups(args.organization, args.user))
elif args.adduser:
hub.addUserGroup(args.organization, args.user, args.team)
elif args.rmuser:
hub.removeUserGroup(args.organization, args.user, args.team)