Create an Identity

        :param: name identity name
        :param: attrs list of dict of attributes (zimsoap format)
        :returns: a zobjects.Identity object
493146
def create_identity(self, name, attrs=[]):
        
        params = {
            'name': name,
            'a': attrs
        }
        resp = self.request('CreateIdentity', {'identity': params})
        return zobjects.Identity.from_dict(resp['identity'])
109416
def string_to_identity(identity_str):
    """"""
    m = _identity_regexp.match(identity_str)
    result = m.groupdict()
    log.debug('parsed identity: %s', result)
    return {k: v for k, v in result.items() if v}
260594
def read_identity(self, identity_id, query_membership=None, properties=None):
        
        route_values = {}
        if identity_id is not None:
            route_values['identityId'] = self._serialize.url('identity_id', identity_id, 'str')
        query_parameters = {}
        if query_membership is not None:
            query_parameters['queryMembership'] = self._serialize.query('query_membership', query_membership, 'str')
        if properties is not None:
            query_parameters['properties'] = self._serialize.query('properties', properties, 'str')
        response = self._send(http_method='GET',
                              location_id='28010c54-d0c0-4c89-a5b0-1c9e188b9fb7',
                              version='5.0',
                              route_values=route_values,
                              query_parameters=query_parameters)
        return self._deserialize('Identity', response)
800466
def get_identities(self, item):
        

        message = item['data']['message']
        identity = self.get_sh_identity(message['from'])

        yield identity
549317
def convert_identifiers(self, identifiers: Union[Identifier, List[Identifier]]):
        
        if not identifiers:
            return identifiers

        def _create_or_update(identifier):
            data = self._cache[identifier.key]
            return self.factory.create_or_update(identifier, data)[0]

        if isinstance(identifiers, Identifier):
            return _create_or_update(identifiers)
        elif isinstance(identifiers, list) and isinstance(identifiers[0], Identifier):
            return [_create_or_update(identifier) for identifier in identifiers]
        else:
            raise TypeError('`identifiers` must be an Identifier or list of Identifiers.')
460344
def __load_unique_identity(self, uidentity, verbose):
        """"""

        uuid = uidentity.uuid

        if uuid:
            try:
                api.unique_identities(self.db, uuid)
                self.log("-- %s already exists." % uuid, verbose)
                return uuid
            except NotFoundError as e:
                self.log("-- %s not found. Generating a new UUID." % uuid,
                         debug=verbose)

        # We don't have a unique identity, so we have to create
        # a new one.
        if len(uidentity.identities) == 0:
            msg = "not enough info to load %s unique identity." % uidentity.uuid
            raise LoadError(cause=msg)

        identity = uidentity.identities.pop(0)

        try:
            stored_uuid = api.add_identity(self.db, identity.source,
                                           identity.email,
                                           identity.name,
                                           identity.username)
            self.new_uids.add(stored_uuid)
        except AlreadyExistsError as e:
            with self.db.connect() as session:
                stored_identity = find_identity(session, e.eid)
                stored_uuid = stored_identity.uuid
            self.warning("-- " + str(e), debug=verbose)
        except ValueError as e:
            raise LoadError(cause=str(e))

        self.log("-- using %s for %s unique identity." % (stored_uuid, uuid), verbose)

        return stored_uuid
332058
def create(self, friendly_name):
        
        data = values.of({'FriendlyName': friendly_name, })

        payload = self._version.create(
            'POST',
            self._uri,
            data=data,
        )

        return CredentialListInstance(self._version, payload, account_sid=self._solution['account_sid'], )
427825
def send_identity(self):
        
        service_name = {'service_name': self.messaging._service_name}
        service_name = _json.dumps(service_name).encode('utf8')

        identify_frame = (b'',
                          b'IDENT',
                          _json.dumps([]).encode('utf8'),
                          service_name)

        # NOTE: Have to do this manually since we built the frame
        if self.messaging._run_control_loop:
            # pep8 alias
            send = self.messaging.command_socket.send_multipart
            self.messaging.add_callback(send, identify_frame)
        else:
            self.messaging.command_socket.send_multipart(identify_frame)

        self.logger.info(' Service Identity sent: %s',
                         self.messaging._service_name)

        if self.identity_callback:
            self.identity_callback()
271396
def get_identity(identity):
    """"""
    return flask.Response(
        json.dumps(
            {
                'identity': {
                    'id': identity.id,
                    'etag': identity.etag,
                    'name': identity.name,
                    'fullname': identity.fullname,
                    'email': identity.email,
                    'timezone': identity.timezone,
                    'teams': _encode_dict(identity.teams)
                }
            }
        ), 200,
        headers={'ETag': identity.etag},
        content_type='application/json'
    )
276086
def get_identities(self, item):
        

        field = self.get_field_author()
        yield self.get_sh_identity(item, field)
21462
def identity_on_pols(self, context):
    
    A = np.empty(context.shape, context.dtype)
    A[:,:,:] = [[[1,0,0,1]]]
    return A
63795
def get_identity(user):
    
    identity = Identity(user.id)

    if hasattr(user, 'id'):
        identity.provides.add(UserNeed(user.id))

    for role in getattr(user, 'roles', []):
        identity.provides.add(RoleNeed(role.name))

    identity.user = user
    return identity
390437
def create_signature(self, name, content, contenttype="text/html"):
        
        s = zobjects.Signature(name=name)
        s.set_content(content, contenttype)

        resp = self.request('CreateSignature', {'signature': s.to_creator()})
        return zobjects.Signature.from_dict(resp['signature'])
680399
def run_as(self, identifiers):
        
        if (not self.has_identifiers):
            msg = ("This subject does not yet have an identity.  Assuming the "
                   "identity of another Subject is only allowed for Subjects "
                   "with an existing identity.  Try logging this subject in "
                   "first, or using the DelegatingSubject.Builder "
                   "to build ad hoc Subject instances with identities as "
                   "necessary.")
            raise ValueError(msg)
        self.push_identity(identifiers)
963795
def identity(self):
        
        if hasattr(self._identity, 'get_identity'):
            return self._identity.get_identity(self._environ)
        return self._identity(self._environ)
1024323
def create(self, unique_name=values.unset, data=values.unset):
        
        data = values.of({'UniqueName': unique_name, 'Data': serialize.object(data), })

        payload = self._version.create(
            'POST',
            self._uri,
            data=data,
        )

        return DocumentInstance(self._version, payload, service_sid=self._solution['service_sid'], )
598890
def identity_attributes(cls):
        
        columns = inspect(cls).primary_key
        names = [c.name for c in columns if c.name not in ('width', 'height')]
        return names