def get_user(username, jwt=None): if jwt: client = get_itsyouonline_client_from_jwt(jwt) else: client = get_itsyouonline_client_from_username(username) result = client.api.users.GetUserInformation(convert_to_str(username)) return userview(convert_to_str(result.json()))
def sign_see_document(organization_id, username, doc): client = get_itsyouonline_client_from_username(username) data = serialize_complex_value(doc, IYOSeeDocumentView, False, skip_missing=True) result = client.api.users.SignSeeObject(data, convert_to_str(doc.version), doc.uniqueid, organization_id, convert_to_str(username)) return IYOSeeDocumentView(**result.json())
def update_grant(username, oldgrant, newgrant): client = get_itsyouonline_client() data = UpdateGrantBody(username=convert_to_str(username), oldgrant=oldgrant, newgrant=newgrant) return client.organizations.UpdateUserGrant(data, get_iyo_organization_id())
def create_keystore_key(username, data): client = get_itsyouonline_client_from_username(username) data = serialize_complex_value(data, IYOKeyStoreKey, False, skip_missing=True) result = client.api.users.SaveKeyStoreKey(data, convert_to_str(username)) return IYOKeyStoreKey(**result.json())
def create_see_document(username, doc): client = get_itsyouonline_client_from_username(username) data = serialize_complex_value(doc, IYOSeeDocumentView, False, skip_missing=True) result = client.api.users.CreateSeeObject(data, convert_to_str(username)) return IYOSeeDocumentView(**result.json())
def get_see_document(organization_id, username, uniqueid, version=u"latest"): client = get_itsyouonline_client_from_username(username) query_params = {'version': version} result = client.api.users.GetSeeObject(uniqueid, organization_id, convert_to_str(username), query_params=query_params) return IYOSeeDocument(**result.json())
def invite_user_to_organization(username, organization_id): logging.info('Inviting user %s to IYO organization %s', username, organization_id) client = get_itsyouonline_client() try: data = AddOrganizationMemberReqBody( searchstring=convert_to_str(username)) client.api.organizations.AddOrganizationMember( data=data, globalid=organization_id) except HTTPError as e: if e.response.status_code != httplib.CONFLICT: raise e
def remove_user_from_organization(username, organization_id): logging.info('Removing user %s from IYO organization %s', username, organization_id) client = get_itsyouonline_client() client.api.organizations.RemoveOrganizationMember(convert_to_str(username), organization_id)
def remove_all_grants(username): client = get_itsyouonline_client() return client.organizations.DeleteAllUserGrants(convert_to_str(username), get_iyo_organization_id())
def remove_grant(username, grant): client = get_itsyouonline_client() return client.organizations.DeleteUserGrant(grant, convert_to_str(username), get_iyo_organization_id())
def add_grant(username, grant): client = get_itsyouonline_client() data = CreateGrantBody(username=convert_to_str(username), grant=grant) return client.organizations.CreateUserGrant(data, get_iyo_organization_id())
def list_grants(username): client = get_itsyouonline_client() return client.organizations.GetUserGrants(convert_to_str(username), get_iyo_organization_id())
def has_grant(client, username, grant): assert isinstance(client, itsyouonline.Client) grants = client.organizations.GetUserGrants( convert_to_str(username), get_iyo_organization_id()).json() return grants and grant in grants
def get_keystore(username): client = get_itsyouonline_client_from_username(username) result = client.users.GetKeyStore(convert_to_str(username)) return [IYOKeyStoreKey(**key) for key in result.json()]
def get_see_documents(organization_id, username): client = get_itsyouonline_client_from_username(username) query_params = {'globalid': organization_id} result = client.api.users.GetSeeObjects(convert_to_str(username), query_params=query_params) return [IYOSeeDocumentView(**d) for d in result.json()]
def user_code(username): digester = hashlib.sha256() digester.update(convert_to_str(username)) key = digester.hexdigest() return unicode(key[:5])