예제 #1
0
    def BotoEntryToJson(cls, entry):
        """Converts a Boto ACL entry to a valid JSON dictionary."""
        acl_entry_json = {}
        # JSON API documentation uses camel case.
        scope_type_lower = entry.scope.type.lower()
        if scope_type_lower == ALL_USERS.lower():
            acl_entry_json['entity'] = 'allUsers'
        elif scope_type_lower == ALL_AUTHENTICATED_USERS.lower():
            acl_entry_json['entity'] = 'allAuthenticatedUsers'
        elif scope_type_lower == USER_BY_EMAIL.lower():
            acl_entry_json['entity'] = 'user-%s' % entry.scope.email_address
            acl_entry_json['email'] = entry.scope.email_address
        elif scope_type_lower == USER_BY_ID.lower():
            acl_entry_json['entity'] = 'user-%s' % entry.scope.id
            acl_entry_json['entityId'] = entry.scope.id
        elif scope_type_lower == GROUP_BY_EMAIL.lower():
            acl_entry_json['entity'] = 'group-%s' % entry.scope.email_address
            acl_entry_json['email'] = entry.scope.email_address
        elif scope_type_lower == GROUP_BY_ID.lower():
            acl_entry_json['entity'] = 'group-%s' % entry.scope.id
            acl_entry_json['entityId'] = entry.scope.id
        elif scope_type_lower == GROUP_BY_DOMAIN.lower():
            acl_entry_json['entity'] = 'domain-%s' % entry.scope.domain
            acl_entry_json['domain'] = entry.scope.domain
        else:
            raise ArgumentException('ACL contains invalid scope type: %s' %
                                    scope_type_lower)

        acl_entry_json['role'] = cls.XML_TO_JSON_ROLES[entry.permission]
        return acl_entry_json
예제 #2
0
  def BotoEntryToJson(cls, entry):
    """Converts a Boto ACL entry to a valid JSON dictionary."""
    acl_entry_json = {}
    # JSON API documentation uses camel case.
    scope_type_lower = entry.scope.type.lower()
    if scope_type_lower == ALL_USERS.lower():
      acl_entry_json['entity'] = 'allUsers'
    elif scope_type_lower == ALL_AUTHENTICATED_USERS.lower():
      acl_entry_json['entity'] = 'allAuthenticatedUsers'
    elif scope_type_lower == USER_BY_EMAIL.lower():
      acl_entry_json['entity'] = 'user-%s' % entry.scope.email_address
      acl_entry_json['email'] = entry.scope.email_address
    elif scope_type_lower == USER_BY_ID.lower():
      acl_entry_json['entity'] = 'user-%s' % entry.scope.id
      acl_entry_json['entityId'] = entry.scope.id
    elif scope_type_lower == GROUP_BY_EMAIL.lower():
      acl_entry_json['entity'] = 'group-%s' % entry.scope.email_address
      acl_entry_json['email'] = entry.scope.email_address
    elif scope_type_lower == GROUP_BY_ID.lower():
      acl_entry_json['entity'] = 'group-%s' % entry.scope.id
      acl_entry_json['entityId'] = entry.scope.id
    elif scope_type_lower == GROUP_BY_DOMAIN.lower():
      acl_entry_json['entity'] = 'domain-%s' % entry.scope.domain
      acl_entry_json['domain'] = entry.scope.domain
    else:
      raise ArgumentException('ACL contains invalid scope type: %s' %
                              scope_type_lower)

    acl_entry_json['role'] = cls.XML_TO_JSON_ROLES[entry.permission]
    return acl_entry_json