当前位置: 首页>>代码示例>>Python>>正文


Python Transform.to_user方法代码示例

本文整理汇总了Python中sevenbridges.meta.transformer.Transform.to_user方法的典型用法代码示例。如果您正苦于以下问题:Python Transform.to_user方法的具体用法?Python Transform.to_user怎么用?Python Transform.to_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sevenbridges.meta.transformer.Transform的用法示例。


在下文中一共展示了Transform.to_user方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_member

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
    def add_member(self, user, permissions):
        """
        Add a member to the project.
        :param user:  Member username
        :param permissions: Permissions dictionary.
        :return: Member object.
        """
        user = Transform.to_user(user)
        data = {'username': user, 'type': 'USER'}
        if isinstance(permissions, dict):
            data.update({
                'permissions': permissions
            })

        extra = {
            'resource': self.__class__.__name__,
            'query': {
                'id': self.id,
                'data': data,
            }
        }
        logger.info('Adding member using username', extra=extra)
        response = self._api.post(
            url=self._URL['members_query'].format(id=self.id), data=data)
        member_data = response.json()
        return Member(api=self._api, **member_data)
开发者ID:sbg,项目名称:sevenbridges-python,代码行数:28,代码来源:project.py

示例2: remove_member

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
 def remove_member(self, user):
     """
     Remove member from the project.
     :param user: User to be removed.
     """
     member = Transform.to_user(user)
     self._api.delete(url=self._URL['members_get'].format(
         id=self.id,
         member=member))
开发者ID:SenadI,项目名称:sevenbridges-python,代码行数:11,代码来源:project.py

示例3: remove_member

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
 def remove_member(self, user):
     """
     Remove member from the project.
     :param user: User to be removed.
     """
     username = Transform.to_user(user)
     extra = {
         'resource': self.__class__.__name__,
         'query': {
             'id': self.id,
             'user': user,
         }
     }
     logger.info('Removing member', extra=extra)
     self._api.delete(
         url=self._URL['member'].format(id=self.id, username=username)
     )
开发者ID:sbg,项目名称:sevenbridges-python,代码行数:19,代码来源:project.py

示例4: add_member

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
 def add_member(self, user, permissions):
     """
     Add a member to the project.
     :param user:  Member username
     :param permissions: Permissions dictionary.
     :return: Member object.
     """
     user = Transform.to_user(user)
     data = {}
     if isinstance(permissions, dict):
         data = {
             'username': user,
             'permissions': permissions
         }
     response = self._api.post(
         url=self._URL['members_query'].format(id=self.id), data=data)
     member_data = response.json()
     return Member(api=self._api, **member_data)
开发者ID:SenadI,项目名称:sevenbridges-python,代码行数:20,代码来源:project.py

示例5: add_member

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
 def add_member(self, user):
     """
     Add member to team
     :param user: User object or user's username
     :return: Added user.
     """
     user = Transform.to_user(user)
     data = {
         'id': user
     }
     extra = {
         'resource': self.__class__.__name__,
         'query': {
             'id': self.id,
             'data': data,
         }
     }
     logger.info('Adding team member using id', extra=extra)
     response = self._api.post(
         url=self._URL['members_query'].format(id=self.id), data=data)
     member_data = response.json()
     return TeamMember(api=self._api, **member_data)
开发者ID:sbg,项目名称:sevenbridges-python,代码行数:24,代码来源:team.py

示例6: test_transform_user_invalid_values

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
def test_transform_user_invalid_values(user):
    with pytest.raises(SbgError):
        Transform.to_user(user)
开发者ID:sbg,项目名称:sevenbridges-python,代码行数:5,代码来源:test_transformer.py

示例7: test_transform_user

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
def test_transform_user(user):
    Transform.to_user(user)
开发者ID:sbg,项目名称:sevenbridges-python,代码行数:4,代码来源:test_transformer.py

示例8: get

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
 def get(cls, user, api=None):
     user = Transform.to_user(user)
     return super(User, cls).get(id=user)
开发者ID:SenadI,项目名称:sevenbridges-python,代码行数:5,代码来源:user.py

示例9: get

# 需要导入模块: from sevenbridges.meta.transformer import Transform [as 别名]
# 或者: from sevenbridges.meta.transformer.Transform import to_user [as 别名]
 def get(cls, user, api=None):
     api = api if api else cls._API
     user = Transform.to_user(user)
     return super(User, cls).get(id=user, api=api)
开发者ID:sbg,项目名称:sevenbridges-python,代码行数:6,代码来源:user.py


注:本文中的sevenbridges.meta.transformer.Transform.to_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。