本文整理汇总了Python中service.Service.setId方法的典型用法代码示例。如果您正苦于以下问题:Python Service.setId方法的具体用法?Python Service.setId怎么用?Python Service.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service.Service
的用法示例。
在下文中一共展示了Service.setId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import setId [as 别名]
def parse(cls, id, data):
token = Token()
token.setId(id)
data = data["token"]
issued_at = None
expires_at = None
try:
issued_at = datetime.strptime(data["issued_at"],
"%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
issued_at = datetime.strptime(data["issued_at"],
"%Y-%m-%dT%H:%M:%S.%f")
try:
expires_at = datetime.strptime(data["expires_at"],
"%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
expires_at = datetime.strptime(data["expires_at"],
"%Y-%m-%dT%H:%M:%S.%f")
token.setCreation(issued_at)
token.setExpiration(expires_at)
project = Project()
project.setId(data["project"]["id"])
project.setName(data["project"]["name"])
token.setProject(project)
user = User()
user.setId(data["user"]["id"])
user.setName(data["user"]["name"])
user.setProjectId(data["project"]["id"])
token.setUser(user)
if "extras" in data:
token.getExtras().update(data["extras"])
for info in data["roles"]:
role = Role()
role.setId(info["id"])
role.setName(info["name"])
token.getRoles().append(role)
for service_info in data["catalog"]:
service = Service()
service.setId(service_info["id"])
service.setType(service_info["type"])
service.setName(service_info["name"])
for endpoint_info in service_info["endpoints"]:
endpoint = Endpoint()
endpoint.setId(endpoint_info["id"])
endpoint.setInterface(endpoint_info["interface"])
endpoint.setRegion(endpoint_info["region"])
endpoint.setRegionId(endpoint_info["region_id"])
endpoint.setURL(endpoint_info["url"])
service.getEndpoints().append(endpoint)
token.getServices().append(service)
return token