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


Python SOAPProxy.get_all_users方法代码示例

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


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

示例1: UAClient

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import get_all_users [as 别名]
class UAClient(object):
  """ A client that makes requests to the UAServer. """

  # Users have a list of applications that they own stored in their user data.
  # This character is the delimiter that separates them in their data.
  APP_DELIMITER = ":"

  # A regular expression that can be used to retrieve the SHA1-hashed password
  # stored in a user's data with the UserAppServer.
  USER_DATA_PASSWORD_REGEX = 'password:([0-9a-fA-F]+)'

  # A regular expression that can be used to find out which Google App Engine
  # applications a user owns, when applied to their user data.
  USER_APP_LIST_REGEX = "\napplications:(.+)\n"

  def __init__(self, host, secret):
    """ Creates a UAClient instance.

    Args:
      host: A string specifying the location of the UAServer.
      secret: A string specifying the deployment secret.
    """
    # Disable certificate verification for Python >= 2.7.9.
    if hasattr(ssl, '_create_unverified_context'):
      ssl._create_default_https_context = ssl._create_unverified_context

    self.secret = secret
    self.server = SOAPProxy('https://{}:{}'.format(host, UA_SERVER_PORT))

  def add_admin_for_app(self, email, app_id):
    """ Grants a user admin privileges for an application.
    
    Args:
      email: A string specifying the user's email address.
      app_id: A string specifying an application ID.
    Raises:
      UAException if the operation was not successful.
    """
    response = self.server.add_admin_for_app(email, app_id, self.secret)
    if response.lower() != 'true':
      raise UAException(response)

  def commit_new_user(self, email, hashed_pwd, type):
    """ Creates a new user.

    Args:
      email: A string specifying the user's email address.
      hashed_pwd: A string containing a hashed password.
      type: A string specifying the type of user to create.
    Raises:
      UAException if the commit was not successful.
    """
    response = self.server.commit_new_user(email, hashed_pwd, type,
                                           self.secret)
    if response.lower() != 'true':
      raise UAException(response)

  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.
#.........这里部分代码省略.........
开发者ID:AppScale,项目名称:appscale,代码行数:103,代码来源:ua_client.py


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