예제 #1
0
파일: consumer.py 프로젝트: bartwo/pulp
def profile(profile):
    serialized = dict(profile)
    href = link.child_link_obj(
        profile['consumer_id'],
        profile['content_type'])
    serialized.update(href)
    return serialized
예제 #2
0
파일: binding.py 프로젝트: bartwo/pulp
def serialize(bind, include_details=True):
    """
    Construct a REST object to be returned.
    Add _href and augments information used by the caller
    to consume published content.
    @param bind: A bind model/SON object.
    @type bind: dict/SON
    @return: A bind REST object.
        {consumer_id:<str>,
         repo_id:<str>,
         distributor_id:<str>,
         href:<str>,
         type_id:<str>,
         details:<dict>}
    @rtype: dict
    """
    # bind
    serialized = dict(bind)

    # href
    href = link.child_link_obj(
        bind['consumer_id'],
        bind['repo_id'],
        bind['distributor_id'])
    serialized.update(href)

    # type_id
    try:
        repo_distributor_manager = manager_factory.repo_distributor_manager()
        distributor = repo_distributor_manager.get_distributor(
            bind['repo_id'],
            bind['distributor_id'])
        serialized['type_id'] = distributor['distributor_type_id']
    except MissingResource:
        if include_details:
            raise

    # details
    if include_details:
        details = repo_distributor_manager.create_bind_payload(
            bind['repo_id'],
            bind['distributor_id'],
            bind['binding_config'])
        serialized['details'] = details

    return serialized
예제 #3
0
파일: binding.py 프로젝트: ehelms/pulp
def serialize(bind):
    """
    Construct a REST object to be returned.
    Add _href and augments information used by the caller
    to consume published content.
    @param bind: A bind model/SON object.
    @type bind: dict/SON
    @return: A bind REST object.
        {consumer_id:<str>,
         repo_id:<str>,
         distributor_id:<str>,
         href:<str>,
         type_id:<str>,
         details:<dict>}
    @rtype: dict
    """
    # bind
    serialized = dict(bind)

    # href
    href = link.child_link_obj(
        bind['consumer_id'],
        bind['repo_id'],
        bind['distributor_id'])
    serialized.update(href)

    # repository
    repo_query_manager = manager_factory.repo_query_manager()
    repo = repo_query_manager.get_repository(bind['repo_id'])
    serialized['repository'] = dict(repo)

    # type_id
    repo_distributor_manager = manager_factory.repo_distributor_manager()
    distributor = repo_distributor_manager.get_distributor(
        bind['repo_id'],
        bind['distributor_id'])
    serialized['type_id'] = distributor['distributor_type_id']

    # details
    details = repo_distributor_manager.create_bind_payload(
        bind['repo_id'],
        bind['distributor_id'])
    serialized['details'] = details

    return serialized
예제 #4
0
파일: consumer.py 프로젝트: tomlanyon/pulp
def profile(profile):
    serialized = dict(profile)
    href = link.child_link_obj(profile['consumer_id'], profile['content_type'])
    serialized.update(href)
    return serialized