Example #1
0
    def get_tenant_users(self, admin_token, tenant_id, marker, limit, url):
        self.__validate_token(admin_token, False)

        if tenant_id == None:
            raise fault.BadRequestFault("Expecting a Tenant Id")
        dtenant = api.TENANT.get(tenant_id)
        if dtenant is None:
            raise fault.ItemNotFoundFault("The tenant not found")
        if not dtenant.enabled:
            raise fault.TenantDisabledFault("Your account has been disabled")
        ts = []
        dtenantusers = api.USER.users_get_by_tenant_get_page(
            tenant_id, marker, limit)

        for dtenantuser in dtenantusers:
            ts.append(
                User(
                    None, dtenantuser.id, dtenantuser.name, tenant_id,
                    dtenantuser.email, dtenantuser.eppn, dtenantuser.enabled,
                    dtenantuser.tenant_roles if hasattr(
                        dtenantuser, "tenant_roles") else None))
        links = []
        if ts.__len__():
            prev, next = api.USER.users_get_by_tenant_get_page_markers(
                tenant_id, marker, limit)
            if prev:
                links.append(
                    atom.Link('prev',
                              "%s?'marker=%s&limit=%s'" % (url, prev, limit)))
            if next:
                links.append(
                    atom.Link('next',
                              "%s?'marker=%s&limit=%s'" % (url, next, limit)))
        return Users(ts, links)
Example #2
0
    def __validate_tenant(self, dtenant):
        if not dtenant:
            raise fault.UnauthorizedFault("Tenant not found")

        if not dtenant.enabled:
            raise fault.TenantDisabledFault("Tenant %s has been disabled!" %
                                            dtenant.id)

        return dtenant
Example #3
0
 def validate_and_fetch_user_tenant(self, tenant_id):
     if tenant_id:
         dtenant = api.TENANT.get(tenant_id)
         if dtenant == None:
             raise fault.ItemNotFoundFault("The tenant is not found")
         elif not dtenant.enabled:
             raise fault.TenantDisabledFault(
                 "Your account has been disabled")
         return dtenant