本文整理汇总了Python中cloudrunner_server.api.util.JsonOutput.repository方法的典型用法代码示例。如果您正苦于以下问题:Python JsonOutput.repository方法的具体用法?Python JsonOutput.repository怎么用?Python JsonOutput.repository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudrunner_server.api.util.JsonOutput
的用法示例。
在下文中一共展示了JsonOutput.repository方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: repo
# 需要导入模块: from cloudrunner_server.api.util import JsonOutput [as 别名]
# 或者: from cloudrunner_server.api.util.JsonOutput import repository [as 别名]
def repo(self, *args, **kwargs):
if not args:
repos = Repository.visible(request).all()
tier = request.user.tier
repositories = sorted([r.serialize(
skip=['id', 'org_id', 'owner_id', 'linked_id'],
rel=[('owner.username', 'owner')],
editable=lambda r: r.editable(request))
for r in repos],
key=lambda l: l['name'])
return O._anon(repositories=repositories,
quota=dict(total=tier.total_repos,
user=tier.total_repos,
external=tier.external_repos == "True"))
else:
repo_name = args[0]
repo = Repository.visible(request).filter(
Repository.name == repo_name).first()
def get_creds(repo):
parents = [p for p in repo.parents
if p.org.name == request.user.org]
if parents:
return dict(auth_user=parents[0].credentials.auth_user)
else:
return {}
if repo.type == 'cloudrunner':
return O.repository(repo.serialize(
skip=['id', 'org_id', 'owner_id', 'linked_id'],
rel=[('owner.username', 'owner')],
editable=lambda r: r.editable(request)))
else:
if repo.editable(request):
return O.repository(repo.serialize(
skip=['id', 'org_id', 'owner_id', 'linked_id'],
rel=[('owner.username', 'owner'),
('linked', 'credentials', get_creds),
# ('credentials.auth_user', 'key'),
# ('credentials.auth_pass', 'secret'),
# ('credentials.auth_args', 'args')
],
editable=lambda r: True))
else:
return O.repository(**repo.serialize(
skip=['id', 'org_id', 'owner_id', 'linked_id'],
rel=[('owner.username', 'owner')],
editable=lambda r: True))