def rename_team(team_id, team_name):
"""
Rename team with the provided team_id.
"""
params = {
'team': {
'name': team_name,
# as this is a patch request, it won't modify users in the team.
# what we want is to update the name of the team only.
'users': [
{'id': ''}
]
}
}
headers = api_utils.generate_headers('rw')
try:
response = requests.patch(_url((team_id,))[1], json=params, headers=headers)
if response_utils.response_error(response): # Check response has no errors
click.echo('Renaming team with id: %s failed.' % team_id, err=True)
sys.exit(1)
elif response.status_code == 200:
click.echo("Team: '%s' renamed to: '%s'" % (team_id, team_name))
except requests.exceptions.RequestException as error:
click.echo(error, err=True)
sys.exit(1)
评论列表
文章目录