Example #1
0
def okta():
    try:
        r = rq.get_url_kwargs(**okta_user_arguments)
        data = json.loads(r.content)
        pretty(data)
        output = [{k: v
                   for k, v in i.items() if k in ['profile', 'id']}
                  for i in data]
        for i in output:
            for k, v in i.items():
                if k == 'profile':
                    for k2, v2 in v.items():
                        if k2 == 'name':
                            print((' ' * 1),
                                  k2,
                                  ':',
                                  v2,
                                  file=open(filepath, 'a'))
                        if k2 == 'description':
                            print((' ' * 1),
                                  k2,
                                  ':',
                                  v2,
                                  file=open(filepath, 'a'))
                if k == 'id':
                    print((' ' * 1), k, ':', v, file=open(filepath, 'a'))
    except Exception as e:
        print(e)
Example #2
0
    def get_app_users():
        try:
            r = rq.get_url_kwargs(**okta_user_arguments)
            data = json.loads(r.content)
            # print(r.links)
            profile = [d['profile'] for d in data]
            with open (filepath, 'a') as f:
                headers = ['email']
                writer = csv.DictWriter(f, fieldnames=headers, extrasaction='ignore')
                if os.stat(filepath).st_size == 0:
                    writer.writeheader()
                # writer.writeheader()
                writer.writerows(profile)
            # pretty(profile)
            has_next_page = False
            if 'next' in r.links:
                has_next_page = True

            while has_next_page:
                okta_user_arguments.update({'url': '{}'.format(r.links['next']['url'])})
                # print(okta_user_arguments)
                r = rq.get_url_kwargs(**okta_user_arguments)
                data = json.loads(r.content)
                profile = [d['profile'] for d in data]
                # pretty(profile)
                
                with open (filepath, 'a') as f:
                    headers = ['email']
                    writer = csv.DictWriter(f, fieldnames=headers, extrasaction='ignore')
                    if os.stat(filepath).st_size == 0:
                        writer.writeheader()
                    # writer.writeheader()
                    writer.writerows(profile)
                if 'next' in r.links:
                    # print(r.links['next'])
                    continue
                else:
                    has_next_page = False
            
                
        except Exception as e:
            print('Exception ', e)
Example #3
0
    def get_group_users():
        try:
            r = rq.get_url_kwargs(**okta_user_arguments)
            data = json.loads(r.content)
            # print(r.links)
            profile = [d['profile'] for d in data] #>>> works
            with open (filepath, 'a') as f:
                headers = ['displayName', 'nickName', 'login', 'email', 'firstName', 'lastName', 'title', 'department', 'manager', 'managementLevel', 'productOrg2', 'productOrg1', 'managerFirstLast', 'employeeNumber', 'state', 'city', 'location', 'hireDate', 'managerUsername', 'isSupervisor', 'payType', 'newHire90', 'userType']
                writer = csv.DictWriter(f, fieldnames=headers, extrasaction='ignore')
                if os.stat(filepath).st_size == 0:
                    writer.writeheader()
                # writer.writeheader()
                writer.writerows(profile)
            # pretty(profile)
            has_next_page = False
            if 'next' in r.links:
                has_next_page = True

            while has_next_page:
                okta_user_arguments.update({'url': '{}'.format(r.links['next']['url'])})
                # print(okta_user_arguments)
                r = rq.get_url_kwargs(**okta_user_arguments)
                data = json.loads(r.content)
                profile = [d['profile'] for d in data]
                # pretty(profile)
                
                with open (filepath, 'a') as f:
                    headers = ['displayName', 'nickName', 'login', 'email', 'firstName', 'lastName', 'title', 'department', 'manager', 'managementLevel', 'productOrg2', 'productOrg1', 'managerFirstLast', 'employeeNumber', 'state', 'city', 'location', 'hireDate', 'managerUsername', 'isSupervisor', 'payType', 'newHire90', 'userType']
                    writer = csv.DictWriter(f, fieldnames=headers, extrasaction='ignore')
                    if os.stat(filepath).st_size == 0:
                        writer.writeheader()
                    # writer.writeheader()
                    writer.writerows(profile)
                if 'next' in r.links:
                    # print(r.links['next'])
                    continue
                else:
                    has_next_page = False
            
                
        except Exception as e:
            print('Exception ', e)
Example #4
0
 def search_okta_app():
     try:
         r = rq.get_url_kwargs(**okta_search_app_arguments)
         data = json.loads(r.content)
         # pretty(data)
         output = [{k: v for k, v in i.items() if k in ['id']} for i in data]
         
         for i in output:
             for k, v in i.items():
                 return v
     except Exception as e:
         print(e)
Example #5
0
    def get_okta_user_ids():
        try:
            with open(file_location) as f:
                read_csv = csv.DictReader(f)
                for row in read_csv:
                    okta_user_arguments.update({
                        'url':
                        OKTA_BASE_URL + '/users/{}'.format(row['username'])
                    })
                    r = rq.get_url_kwargs(**okta_user_arguments)
                    data = json.loads(r.content)
                    userids.append(data['id'])

        except Exception as e:
            print(e)
Example #6
0
def okta():
    try:
        r = rq.get_url_kwargs(**okta_user_arguments)
        data = json.loads(r.content)
        # pretty(data)
        # output = [{k: v for k, v in i.items() if k in ['id', 'profile']} for i in data]
        profile = [d['profile'] for d in data]
        # output = [{d['name'],d['description']} for d in profile]
        headers = ['name', 'description']
        with open(filepath, 'a') as f:
            writer = csv.DictWriter(f,
                                    fieldnames=headers,
                                    extrasaction='ignore')
            writer.writeheader()
            writer.writerows(profile)
    except Exception as e:
        print(e)