Пример #1
0
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()))
Пример #2
0
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())
Пример #3
0
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())
Пример #4
0
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())
Пример #5
0
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())
Пример #6
0
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())
Пример #7
0
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
Пример #8
0
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)
Пример #9
0
def remove_all_grants(username):
    client = get_itsyouonline_client()
    return client.organizations.DeleteAllUserGrants(convert_to_str(username),
                                                    get_iyo_organization_id())
Пример #10
0
def remove_grant(username, grant):
    client = get_itsyouonline_client()
    return client.organizations.DeleteUserGrant(grant,
                                                convert_to_str(username),
                                                get_iyo_organization_id())
Пример #11
0
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())
Пример #12
0
def list_grants(username):
    client = get_itsyouonline_client()
    return client.organizations.GetUserGrants(convert_to_str(username),
                                              get_iyo_organization_id())
Пример #13
0
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
Пример #14
0
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()]
Пример #15
0
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()]
Пример #16
0
def user_code(username):
    digester = hashlib.sha256()
    digester.update(convert_to_str(username))
    key = digester.hexdigest()
    return unicode(key[:5])