コード例 #1
0
def context_api(mock_crud, context_tags):
    context = context_tags
    label = generate_random_string()
    url = generate_random_string()
    description = ' '.join([generate_random_string() for _ in range(5)])
    tags = context.get('tags')
    api_id = CRUD.addApi(label, url, description=description, tags=tags, commit=False)
    context['api_id'] = api_id
    return context
コード例 #2
0
 def add_api(label, url, description=None, tags=None):
     new_id = CRUD.addApi(label,
                          url,
                          tags=tags,
                          description=description,
                          commit=True)
     if new_id:
         return {
             'status': 'ok',
             'message': 'API %s was added' % label,
             'id': new_id
         }
     else:
         return {
             'status':
             'error',
             'message':
             'Ooops! Something went wrong while adding API %s' % label
         }