How to use the keepercommander.api.sync_down function in keepercommander

To help you get started, weā€™ve selected a few keepercommander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Keeper-Security / Commander / tests / test_commands.py View on Github external
} for x in folder_uids
                ]
            }
            rs = api.communicate(params, request)
            request = {
                'command': 'delete',
                'pre_delete_token': rs['pre_delete_response']['pre_delete_token']
            }
            rs = api.communicate(params, request)

        request = {
            'command': 'purge_deleted_records'
        }
        rs = api.communicate(params, request)
        params.revision = 0
        api.sync_down(params)
github Keeper-Security / Commander / tests / test_commands.py View on Github external
def wipe_out_data(cls):
        params = cls.params # type: KeeperParams

        params.revision = 0
        api.sync_down(params)
        request = {
            'command': 'record_update',
            'delete_records': [key for key in params.record_cache.keys()]
        }
        rs = api.communicate(params, request)

        for shared_folder_uid in params.shared_folder_cache:
            request = {
                'command': 'shared_folder_update',
                'operation': 'delete',
                'shared_folder_uid': shared_folder_uid
            }
            rs = api.communicate(params, request)

        folder_uids = [x for x in params.root_folder.subfolders if params.subfolder_cache[x]['type'] == BaseFolderNode.UserFolderType]
        if folder_uids:
github Keeper-Security / Commander / unit-tests / data_vault.py View on Github external
def get_synced_params():
    p = get_connected_params()
    with mock.patch('keepercommander.api.communicate') as mock_comm:
        mock_comm.return_value = get_sync_down_response()
        api.sync_down(p)
    return p
github Keeper-Security / Commander / keepercommander / custom / create_delete.py View on Github external
import string
import random

from keepercommander.record import Record
from keepercommander.params import KeeperParams
from keepercommander import display, api

my_params = KeeperParams()

while not my_params.user:
    my_params.user = getpass.getpass(prompt='User(Email): ', stream=None)

while not my_params.password:
    my_params.password = getpass.getpass(prompt='Master Password: ', stream=None)

api.sync_down(my_params)

# Add record 
r = Record()
r.title = 'Test Record'
r.login = 'someone@company.com'

# generate a 32-char random password
r.password = ''.join(random.SystemRandom().choice(string.printable) for _ in range(32)) 

if api.add_record(my_params, r):
    print('Added record UID='+r.record_uid) 

# Delete the record 
if r.record_uid:
    api.delete_record(my_params, r.record_uid)
github Keeper-Security / Commander / keepercommander / importer / imp_exp.py View on Github external
def export(params, file_format, filename, **export_args):
    api.sync_down(params)

    exporter = exporter_for_format(file_format)()  # type: BaseExporter
    if export_args:
        if 'max_size' in export_args:
            exporter.max_size = int(export_args['max_size'])

    to_export = []
    if exporter.has_shared_folders():
        shfolders = [api.get_shared_folder(params, sf_uid) for sf_uid in params.shared_folder_cache]
        shfolders.sort(key=lambda x: x.name.lower(), reverse=False)
        for f in shfolders:
            fol = ImportSharedFolder()
            fol.uid = f.shared_folder_uid
            fol.path = get_folder_path(params, f.shared_folder_uid)
            fol.manage_users = f.default_manage_users
            fol.manage_records = f.default_manage_records
github Keeper-Security / Commander / keepercommander / importer / imp_exp.py View on Github external
sf.manage_records = manage_records
            sf.can_edit = can_edit
            sf.can_share = can_share
            folders.append(sf)

    if folders:
        shared_folder_add = prepare_shared_folder_add(params, folders)
        api.execute_batch(params, shared_folder_add)
        api.sync_down(params)

    if records:
        # create folders
        folder_add = prepare_folder_add(params, records)
        if folder_add:
            api.execute_batch(params, folder_add)
            api.sync_down(params)

        # create records
        record_adds = prepare_record_add(params, records)
        if record_adds:
            api.execute_batch(params, record_adds)
            api.sync_down(params)

        # ensure records are linked to folders
        record_links = prepare_record_link(params, records)
        if record_links:
            api.execute_batch(params, record_links)
            api.sync_down(params)

        # adjust shared folder permissions
        shared_update = prepare_record_permission(params, records)
        if shared_update:
github Keeper-Security / Commander / keepercommander / commands / enterprise.py View on Github external
record_name = kwargs.get('record') or log_export.default_record_title()
        for r_uid in params.record_cache:
            rec = api.get_record(params, r_uid)
            if record_name in [rec.record_uid, rec.title]:
                record = rec
        if record is None:
            answer = user_choice('Do you want to create a Keeper record to store audit log settings?', 'yn', 'n')
            if answer.lower() == 'y':
                record_title = input('Choose the title for audit log record [Default: {0}]: '.format(record_name)) or log_export.default_record_title()
                cmd = RecordAddCommand()
                record_uid = cmd.execute(params, **{
                    'title': record_title,
                    'force': True
                })
                if record_uid:
                    api.sync_down(params)
                    record = api.get_record(params, record_uid)
        if record is None:
            return

        props = {}
        props['enterprise_name'] = params.enterprise['enterprise_name']
        log_export.store_record = False
        log_export.get_properties(record, props)

        #query data
        last_event_time = 0
        val = record.get('last_event_time')
        if val:
            try:
                last_event_time = int(val)
            except:
github Keeper-Security / Commander / keepercommander / custom / add_record_to_shared_folder.py View on Github external
# to an existing shared folder. 
#

from keepercommander.params import KeeperParams
from keepercommander import api
from keepercommander.commands.record import RecordAddCommand

params = KeeperParams()

# Inputs - hard coded for demo purposes
params.user = 'your_keeper_email'
params.password = 'your_keeper_password'
shared_folder_uid = 'your_shared_folder_uid'

# Login and sync
api.sync_down(params)

command = RecordAddCommand()
record_uid = command.execute(params, title='Test Record', login='someone@company.com', url='https://google.com', folder=shared_folder_uid, generate=True, force=True)
print('Added record to shared folder')