def meta(adapter_id):
    """Provides the metadata for a certain adapter."""
    adapter = get_adapter(adapter_id)

    if not adapter:
        return output.failure("That adapter doesn't (yet) exist. Please check the adapter name and try again.", 501)

    return output.success(adapter.do_meta())
def catalog(adapter_id):
    """Provides the catalog data for a certain adapter."""
    adapter = get_adapter(adapter_id)

    if not adapter:
        return output.failure("That adapter doesn't (yet) exist. Please check the adapter name and try again.", 501)

    result = adapter.do_catalog()
    if not isinstance(result, list):
        return output.failure(result.message if hasattr(result, 'message') else repr(result), 500)

    return output.success(result)
def server_create(adapter_id):
    """Creates a server using a certain adapter."""
    adapter = get_adapter(adapter_id)

    if not adapter:
        return output.failure(
            "That adapter doesn't (yet) exist. Please check the adapter name and try again.",
            501)

    if not adapter.do_verify(request.headers):
        return output.failure(
            "Credential verification failed. Please check your credentials and try again.",
            401)

    result = adapter.do_server_create(request.headers, request.json)

    if 'error' in result:
        return output.failure(result['error'], result['status'])

    return output.success(result['data'], result['status'])