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


Python SOAPProxy.is_user_cloud_admin方法代码示例

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


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

示例1: UAClient

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import is_user_cloud_admin [as 别名]

#.........这里部分代码省略.........

  def delete_user(self, email):
    """ Deletes a user.

    Args:
      email: A string specifying the user's email address.
    Raises:
      UAException if the deletion was not successful.
    """
    response = self.server.delete_user(email, self.secret)
    if response.lower() != 'true':
      raise UAException(response)

  def disable_user(self, email):
    """ Disables a user.

    Args:
      email: A string specifying the user's email address.
    Raises:
      UAException if the operation was not successful.
    """
    response = self.server.disable_user(email, self.secret)
    if response.lower() != 'true':
      raise UAException(response)

  def does_user_exist(self, email):
    """ Checks if a user exists.
    
    Args:
      email: A string specifying an email address.
    Returns:
      A boolean indicating whether or not the user exists.
    Raises:
      UAException when unable to determine if user exist.
    """
    response = self.server.does_user_exist(email, self.secret)

    if response.lower() not in ['true', 'false']:
      raise UAException(response)

    return response.lower() == 'true'

  def get_all_users(self):
    """ Retrieves a list of all users.

    Returns:
      A list of string containing user email addresses.
    Raises:
      UAException if unable to retrieve list of users.
    """
    response = self.server.get_all_users(self.secret)

    if response.startswith('Error'):
      raise UAException(response)

    # Strip opening prefix that the UAServer adds.
    if response.startswith('____'):
      response = response[4:]

    return response.split(':')

  def get_user_data(self, email):
    """ Retrieves user metadata.

    Args:
      email: A string specifying an email address.
    Returns:
      A string containing user metadata.
    """
    return self.server.get_user_data(email, self.secret)

  def is_user_cloud_admin(self, email):
    """ Checks if a user has cloud admin privliges.

    Args:
      email: A string specifying an email address.
    Returns:
      A boolean indicating whether or not the user has admin privileges.
    Raises:
      UAException when unable to determine the status.
    """
    response = self.server.is_user_cloud_admin(email, self.secret)
    if response.lower() not in ['true', 'false']:
      raise UAException(response)

    return response.lower() == 'true'

  def set_cloud_admin_status(self, email, is_admin):
    """ Grants or revokes cloud admin privileges.
    
    Args:
      email: A string specifying an email address.
      is_admin: A boolean specifying if the user should be admin or not.
    Raises:
      UAException if the operation was not successful.
    """
    response = self.server.set_cloud_admin_status(email, str(is_admin).lower(),
                                                  self.secret)
    if response.lower() != 'true':
      raise UAException(response)
开发者ID:AppScale,项目名称:appscale,代码行数:104,代码来源:ua_client.py


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