from torii import Torii

## Connection to torii API with hpcgadmin the account service.
t = Torii(base_url='https://localhost:8443/torii', username='hpcgadmin', password='hpcgadmin')

## Init services for users, teams and projects.
user_service = t.service('users')
team_service = t.service('teams')
project_service = t.service('projects')

## Get teams list
teams = team_service.list()
## Projects list
projects = project_service.list()
## Get users list
users = user_service.list()

## Print name of first user.
print(users[0]['name'])

## Add team for user
user_id = users[0]['_id']
team_id = teams[0]['_id']
project_id = projects[0]['_id']

params = {
    'userID': user_id,
    'value': 'add',
}

user_service.request('POST', path='teams/' + team_id, params=params)

## Add project for user
user_service.request('POST', path='projects/' + project_id, params=params)
