Get user.organisations subresouces
341625
def user_organisations_resource(doc):
    """"""
    if doc.get('type') == 'user':
        for org_id, resource in doc.get('organisations', {}).items():
            resource['id'] = org_id
            resource['user_id'] = doc['_id']
            yield [doc['_id'], org_id], resource
772931
def organization_subscriptions(self, organization_id, **kwargs):
        ""
        api_path = "/api/v2/organizations/{organization_id}/subscriptions.json"
        api_path = api_path.format(organization_id=organization_id)
        return self.call(api_path, **kwargs)
1322115
def get_groups(self, username):
        """"""
        username = ldap.filter.escape_filter_chars(self._byte_p2(username))
        userdn = self._get_user(username, NO_ATTR)

        searchfilter = self.group_filter_tmpl % {
            'userdn': userdn,
            'username': username
        }

        groups = self._search(searchfilter, NO_ATTR, self.groupdn)
        ret = []
        for entry in groups:
            ret.append(self._uni(entry[0]))
        return ret
1234794
def list(self):
        
        
        uri = URITemplate(self.baseuri + '/{owner}').expand(
            owner=self.username)
        return self.session.get(uri)
1351806
def get_memberships(self):
        

        response = self._get_xml(self.rest_url + "/group/membership")

        if not response.ok:
            return None

        xmltree = etree.fromstring(response.content)
        memberships = {}
        for mg in xmltree.findall('membership'):
            # coerce values to unicode in a python 2 and 3 compatible way
            group = u'{}'.format(mg.get('group'))
            users = [u'{}'.format(u.get('name')) for u in mg.find('users').findall('user')]
            groups = [u'{}'.format(g.get('name')) for g in mg.find('groups').findall('group')]
            memberships[group] = {u'users': users, u'groups': groups}
        return memberships
519921
def __getOrganizations(self, web):
        
        orgsElements = web.find_all("a", {"class": "avatar-group-item"})
        self.organizations = len(orgsElements)
51966
def list_vms_sub(access_token, subscription_id):
    '''
    '''
    endpoint = ''.join([get_rm_endpoint(),
                        '/subscriptions/', subscription_id,
                        '/providers/Microsoft.Compute/virtualMachines',
                        '?api-version=', COMP_API])
    return do_get_next(endpoint, access_token)
964048
protected static function fetch_subsystems() {
        global $CFG;

        // NOTE: Any additions here must be verified to not collide with existing add-on modules and subplugins!!!

        $info = array(
            'access'      => null,
            'admin'       => $CFG->dirroot.'/'.$CFG->admin,
            'analytics'   => $CFG->dirroot . '/analytics',
            'antivirus'   => $CFG->dirroot . '/lib/antivirus',
            'auth'        => $CFG->dirroot.'/auth',
            'availability' => $CFG->dirroot . '/availability',
            'backup'      => $CFG->dirroot.'/backup/util/ui',
            'badges'      => $CFG->dirroot.'/badges',
            'block'       => $CFG->dirroot.'/blocks',
            'blog'        => $CFG->dirroot.'/blog',
            'bulkusers'   => null,
            'cache'       => $CFG->dirroot.'/cache',
            'calendar'    => $CFG->dirroot.'/calendar',
            'cohort'      => $CFG->dirroot.'/cohort',
            'comment'     => $CFG->dirroot.'/comment',
            'competency'  => $CFG->dirroot.'/competency',
            'completion'  => $CFG->dirroot.'/completion',
            'countries'   => null,
            'course'      => $CFG->dirroot.'/course',
            'currencies'  => null,
            'customfield' => $CFG->dirroot.'/customfield',
            'dbtransfer'  => null,
            'debug'       => null,
            'editor'      => $CFG->dirroot.'/lib/editor',
            'edufields'   => null,
            'enrol'       => $CFG->dirroot.'/enrol',
            'error'       => null,
            'favourites'  => $CFG->dirroot . '/favourites',
            'filepicker'  => null,
            'fileconverter' => $CFG->dirroot.'/files/converter',
            'files'       => $CFG->dirroot.'/files',
            'filters'     => $CFG->dirroot.'/filter',
            //'fonts'       => null, // Bogus.
            'form'        => $CFG->dirroot.'/lib/form',
            'grades'      => $CFG->dirroot.'/grade',
            'grading'     => $CFG->dirroot.'/grade/grading',
            'group'       => $CFG->dirroot.'/group',
            'help'        => null,
            'hub'         => null,
            'imscc'       => null,
            'install'     => null,
            'iso6392'     => null,
            'langconfig'  => null,
            'license'     => null,
            'mathslib'    => null,
            'media'       => $CFG->dirroot.'/media',
            'message'     => $CFG->dirroot.'/message',
            'mimetypes'   => null,
            'mnet'        => $CFG->dirroot.'/mnet',
            //'moodle.org'  => null, // Not used any more.
            'my'          => $CFG->dirroot.'/my',
            'notes'       => $CFG->dirroot.'/notes',
            'pagetype'    => null,
            'pix'         => null,
            'plagiarism'  => $CFG->dirroot.'/plagiarism',
            'plugin'      => null,
            'portfolio'   => $CFG->dirroot.'/portfolio',
            'privacy'     => $CFG->dirroot . '/privacy',
            'question'    => $CFG->dirroot.'/question',
            'rating'      => $CFG->dirroot.'/rating',
            'repository'  => $CFG->dirroot.'/repository',
            'rss'         => $CFG->dirroot.'/rss',
            'role'        => $CFG->dirroot.'/'.$CFG->admin.'/roles',
            'search'      => $CFG->dirroot.'/search',
            'table'       => null,
            'tag'         => $CFG->dirroot.'/tag',
            'timezones'   => null,
            'user'        => $CFG->dirroot.'/user',
            'userkey'     => $CFG->dirroot.'/lib/userkey',
            'webservice'  => $CFG->dirroot.'/webservice',
        );

        return $info;
    }
762073
def get_users(self):
        
        output = []
        self.con.execute('SELECT userId, uid FROM archive_users;')
        results = self.con.fetchall()

        for result in results:
            # Fetch list of roles
            self.con.execute('SELECT name FROM archive_roles r INNER JOIN archive_user_roles u ON u.roleId=r.uid '
                             'WHERE u.userId = %s;', (result['uid'],))
            role_list = [row['name'] for row in self.con.fetchall()]
            output.append(mp.User(user_id=result['userId'], roles=role_list))
        return output
1096563
def get_user_data(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/get_user_data', params, 'GET')
654653
def membership_in(self, organization):
        """"""
        url = self._build_url('user', 'memberships', 'orgs',
                              str(organization))
        json = self._json(self._get(url), 200)
        return Membership(json, self)
683398
def active_joined_organisations(doc):
    """"""
    if doc.get('type') == 'user' and doc.get('state') != 'deactivated':
        for org_id, state in doc.get('organisations', {}).items():
            if state['state'] == 'deactivated':
                continue

            org = {'_id': org_id}
            yield [doc['_id'], None], org

            try:
                yield [doc['_id'], state['state']], org
            except KeyError:
                pass
31661
public function getAvailableOrganisations($as_simple_array = false)
    {
        $organisations = $this->get('users/' . $this->user_id . '/organisations');
        //If simple array is true, we send back an array with [id] => [name] instead of the full list
        if ($as_simple_array) {
            $temp = [];
            foreach ($organisations as $org) {
                $temp[$org['id']] = $org['name'];
            }
            $organisations = $temp;
        }
        asort($organisations);

        return $organisations;
    }
623551
def get_course_registered_users(self, course, with_admins=True):
        

        l = [entry['students'] for entry in list(self._database.aggregations.aggregate([
            {"$match": {"courseid": course.get_id()}},
            {"$unwind": "$students"},
            {"$project": {"_id": 0, "students": 1}}
        ]))]
        if with_admins:
            return list(set(l + course.get_staff()))
        else:
            return l
193892
def members(self):
        ''''''
        with self._mutex:
            if not self._members:
                self._members = {}
                for o in self.organisations:
                    # TODO: Search for these in the tree
                    self._members[o.org_id] = o.obj.get_members()
        return self._members
768223
def all(self, query=None, **kwargs):
        

        return super(OrganizationsProxy, self).all(query=query)
1319281
def user_organization_subscriptions(self, user_id, **kwargs):
        ""
        api_path = "/api/v2/users/{user_id}/organization_subscriptions.json"
        api_path = api_path.format(user_id=user_id)
        return self.call(api_path, **kwargs)