def _get_service(client, organisation_id, name):
"""
Get service belonging to organisation which matches given service name
:param client: Accounts Service API Client
:param organisation_id: Id of Organisation
:param name: Service Name
:return: Service Id
"""
try:
response = client.accounts.services.get(organisation_id=organisation_id)
except httpclient.HTTPError as exc:
if exc.code == 404:
# If error is a 404 then this means the organisation_id is not recognised. Raise this error immediately
msg = ('Organisation {} cannot be found. '
'Please check organisation_id.'.format(organisation_id))
raise click.ClickException(click.style(msg, fg='red'))
else:
raise exc
services = [s for s in response['data'] if s['name'] == name]
if services:
return services[0]['id']
return None
评论列表
文章目录