def context_endpoint(mock_crud, context_api): context = context_api api_id = context.get('api_id') label = generate_random_string() url = generate_random_string() description = ' '.join([generate_random_string() for _ in range(5)]) tags = context.get('tags') id = CRUD.addEndpoint( api_id, label, url, description, tags=tags, commit=False ) context['endpoint_id'] = id return context
def add_endpoint(api_id, label, url, description=None, tags=None): new_id = CRUD.addEndpoint(api_id, label, url, description=description, tags=tags, commit=True) if new_id: return { 'status': 'ok', 'message': 'Endpoint %s was added' % label, 'id': new_id } else: return { 'status': 'error', 'message': 'Ooops! Something went wrong while adding Endpoint %s' % label }