Add information to the knowledge I have about the user. This is
        for Virtual organizations.

        :param name_id: The subject identifier
        :return: A possibly extended knowledge.
421431
def add_vo_information_about_user(self, name_id):
        

        ava = {}
        try:
            (ava, _) = self.users.get_identity(name_id)
        except KeyError:
            pass

        # is this a Virtual Organization situation
        if self.vorg:
            if self.vorg.do_aggregation(name_id):
                # Get the extended identity
                ava = self.users.get_identity(name_id)[0]
        return ava
370854
def get_knowledge_base(project_id, knowledge_base_id):
    """"""
    import dialogflow_v2beta1 as dialogflow
    client = dialogflow.KnowledgeBasesClient()
    knowledge_base_path = client.knowledge_base_path(
        project_id, knowledge_base_id)

    response = client.get_knowledge_base(knowledge_base_path)

    print('Got Knowledge Base:')
    print(' - Display Name: {}'.format(response.display_name))
    print(' - Knowledge ID: {}'.format(response.name))
1237354
def add_target_id(self,this_id):
        
        new_target = Ctarget()
        new_target.set_id(this_id)
        self.node.append(new_target.get_node())
92723
def _set_id(infos):
    '''
    
    '''
    if infos:
        cid = None
        if infos.get("Id"): cid = infos["Id"]
        elif infos.get("ID"): cid = infos["ID"]
        elif infos.get("id"): cid = infos["id"]
        if "Id" not in infos:
            infos["Id"] = cid
        infos.pop("id",None)
        infos.pop("ID",None)
    return infos
91825
def _populate_input_for_name_id(self, config, record, context, data):
        
        user_id = ""
        user_id_from_attrs = config['user_id_from_attrs']
        for attr in user_id_from_attrs:
            if attr in record["attributes"]:
                value = record["attributes"][attr]
                if isinstance(value, list):
                    # Use a default sort to ensure some predictability since the
                    # LDAP directory server may return multi-valued attributes
                    # in any order.
                    value.sort()
                    user_id += "".join(value)
                    satosa_logging(
                        logger,
                        logging.DEBUG,
                        "Added attribute {} with values {} to input for NameID".format(attr, value),
                        context.state
                        )
                else:
                    user_id += value
                    satosa_logging(
                        logger,
                        logging.DEBUG,
                        "Added attribute {} with value {} to input for NameID".format(attr, value),
                        context.state
                        )
        if not user_id:
            satosa_logging(
                logger,
                logging.WARNING,
                "Input for NameID is empty so not overriding default",
                context.state
                )
        else:
            data.subject_id = user_id
            satosa_logging(
                logger,
                logging.DEBUG,
                "Input for NameID is {}".format(data.subject_id),
                context.state
                )
1268350
def _setID(self, id):
        
        if type(id) in (types.ListType, types.TupleType):
            try:
                for key in self._sqlPrimary:
                    value = id[0]
                    self.__dict__[key] = value
                    id = id[1:] # rest, go revursive
            except IndexError:
                raise 'Not enough id fields, required: %s' % len(self._sqlPrimary)
        elif len(self._sqlPrimary) <= 1:
            # It's a simple value
            key = self._sqlPrimary[0]
            self.__dict__[key] = id
        else:
            raise 'Not enough id fields, required: %s' % len(self._sqlPrimary)
        self._new = False
1240392
def reference_id(self, reference_id):
        

        if reference_id is None:
            raise ValueError("Invalid value for `reference_id`, must not be `None`")
        if len(reference_id) > 40:
            raise ValueError("Invalid value for `reference_id`, length must be less than `40`")

        self._reference_id = reference_id
20360
def add_channel_info(self, attrs, clear=False):
        
        self.assert_writeable()
        if 'channel_id' not in self.handle:
            self.handle.create_group('channel_id')
        self._add_attributes('channel_id', attrs, clear)
845487
def subject_id(self):
        

        if "subject" in self.message.keys():
            _subj = self.message.subject
            if "base_id" in _subj.keys() and _subj.base_id:
                return _subj.base_id
            elif _subj.name_id:
                return _subj.name_id
        else:
            if "base_id" in self.message.keys() and self.message.base_id:
                return self.message.base_id
            elif self.message.name_id:
                return self.message.name_id
            else:  # EncryptedID
                pass
356659
def registration_info_request(self, registration_id):
        
        return self.requests_session.get(
            self.INFO_END_POINT + registration_id,
            params={'details': 'true'}
        )
1188460
def add_identity(cls, db, identity, backend):
        
        uuid = None

        try:
            uuid = api.add_identity(db, backend, identity['email'],
                                    identity['name'], identity['username'])

            logger.debug("New sortinghat identity %s %s,%s,%s ",
                         uuid, identity['username'], identity['name'], identity['email'])

            profile = {"name": identity['name'] if identity['name'] else identity['username'],
                       "email": identity['email']}

            api.edit_profile(db, uuid, **profile)

        except AlreadyExistsError as ex:
            uuid = ex.eid
        except InvalidValueError as ex:
            logger.warning("Trying to add a None identity. Ignoring it.")
        except UnicodeEncodeError as ex:
            logger.warning("UnicodeEncodeError. Ignoring it. %s %s %s",
                           identity['email'], identity['name'],
                           identity['username'])
        except Exception as ex:
            logger.warning("Unknown exception adding identity. Ignoring it. %s %s %s",
                           identity['email'], identity['name'],
                           identity['username'], exc_info=True)

        if 'company' in identity and identity['company'] is not None:
            try:
                api.add_organization(db, identity['company'])
                api.add_enrollment(db, uuid, identity['company'],
                                   datetime(1900, 1, 1),
                                   datetime(2100, 1, 1))
            except AlreadyExistsError:
                pass

        return uuid
92043
def usable_id(cls, id):
        
        try:
            # id is maybe a hostname
            qry_id = cls.from_name(id)
            if not qry_id:
                # id is maybe an ip
                qry_id = cls.from_ip(id)
            if not qry_id:
                qry_id = cls.from_vhost(id)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id
379577
def add_external_reference_to_term(self,term_id, external_ref):
        
        if self.term_layer is not None:
            self.term_layer.add_external_reference(term_id, external_ref)
1246063
def get_knowledge_category_id(self):
        
        # Implemented from template for osid.resource.Resource.get_avatar_id_template
        if not bool(self._my_map['knowledgeCategoryId']):
            raise errors.IllegalState('this Objective has no knowledge_category')
        else:
            return Id(self._my_map['knowledgeCategoryId'])
645874
def add_unique_id(self):
        
        
        uid = 0
        for feature in self._data["features"]:
            if feature["properties"].get("id"):
                raise Exception("one of the features already had an id field")
            feature["properties"]["id"] = uid
            uid += 1
939736
def set_user_info(self, nick, user='*', real='*'):
        
        if self.connected:
            raise Exception("Can't set user info now, we're already connected!")

        # server will pickup list when they exist
        if not self.connected:
            self.nick = nick

        self.connect_info['user'] = {
            'nick': nick,
            'user': user,
            'real': real,
        }
169707
def usable_id(cls, id):
        
        try:
            # id is maybe a sshkey name
            qry_id = cls.from_name(id)
            if not qry_id:
                qry_id = int(id)
        except DuplicateResults as exc:
            cls.error(exc.errors)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id