# -*- coding: utf-8 -*-
# yav is required
# pip install yandex-passport-vault-client -i https://pypi.yandex-team.ru/simple
# from vault_client import instances  # noqa  TODO: Update to use vault-client from arcadia
#
# READ_ACCESS = 'reader'
# WRITE_ACCESS = 'owner'
#
# IMPULSE_ABC_GROUP_ID = 1658
# XPROD_ROBOTS = ['robot-xprod', 'robot-xprod-dc']
# XPROD_USERS = ['re9ulusv', 'nryzhikov', 'blinoff']
#
#
# def create_secret(secret_name, secret_data):
#     client = instances.Production()
#     secret_uuid = client.create_secret(secret_name)
#     secret_version = client.create_secret_version(secret_uuid, secret_data)
#     return secret_uuid, secret_version
#
#
# def update_secret(secret_uuid, secret_data)
#     # TODO: Test, never was tested
#     client = instances.Production()
#     secret_version = client.create_secret_version(
#         secret_uuid,
#         secret_data,
#     )
#     return secret_version
#
#
# def share_secret(secret_uuid, access_type, user_logins=None, abc_group_ids=None):
#     client = instances.Production()
#     user_logins = user_logins or []
#     abc_group_ids = abc_group_ids or []
#     for login in user_logins:
#         print('add {} access to user: {} secret: {}'.format(access_type, login, secret_uuid))
#         client.add_user_role_to_secret(
#             secret_uuid,
#             access_type,
#             login=login
#         )
#     for group_id in abc_group_ids:
#         print('add {} access to group: {} secret: {}'.format(access_type, group_id, secret_uuid))
#         client.add_user_role_to_secret(
#             secret_uuid,
#             access_type,
#             abc_id=group_id
#         )
#
#
# if __name__ == '__main__':
#     secret_name = 'xprod-test-json-secret'
#     secret_data = {'test_secret': {'test_key': 'test_val', 'other_test_key': [1,2,3,4,5]}}
#     secret_uuid, version_uuid = create_secret(secret_name, secret_data)
#
#     # secret_uuids = [
#     #     'sec-01cqvkmhmtkr5mw5425sdj65tx',
#     #     'sec-01cqvm7g0tdz43xnp7m6p22psa',
#     #     'sec-01cqvmmnj52chy6nz4tbzfkrw8',
#     #     'sec-01cqvmqz554562bn8cpvzq6atn',
#     #     'sec-01cqvp1dxq61v68k4dhx8x7yva'
#     # ]
#
#     # for sec_uid in secret_uuids:
#     #     share_secret(sec_uid, WRITE_ACCESS, XPROD_USERS)
#     # share_secret(secret_uuid, READ_ACCESS, XPROD_ROBOTS)
#     # share_secret(secret_uuid, WRITE_ACCESS, None, [IMPULSE_ABC_GROUP_ID])
