protectables.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:python-karborclient 作者: openstack 项目源码 文件源码
def get_instance(self, type, id, search_opts=None, session_id=None):
        if session_id:
            headers = {'X-Configuration-Session': session_id}
        else:
            headers = {}

        if search_opts is None:
            search_opts = {}
        query_params = {}
        for key, val in search_opts.items():
            if val:
                query_params[key] = val
        query_string = ""
        if query_params:
            params = sorted(query_params.items(), key=lambda x: x[0])
            query_string = "?%s" % parse.urlencode(params)

        url = ("/protectables/{protectable_type}/instances/"
               "{protectable_id}{query_string}").format(
            protectable_type=type, protectable_id=id,
            query_string=query_string)
        return self._get(url, response_key="instance", headers=headers)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号