from mona_sdk import Client
# For regular smadar's user
client_id = "40c08ee6-f411-41b1-9752-80d98897aae6"
secret_key = "5694fad0-e372-488e-89cf-22ed8693a5a2"


my_mona_client = Client(
    api_key=client_id,
    secret=secret_key,
    user_id="aec02df0-813d-4f6a-8574-bdc2668c3cbc",
    #should_use_authentication=False,
    #should_use_ssl=False,
    #override_rest_api_host="rest-api host address",
    #context_class_to_sampling_rate={"SMADAR_TEST1": 0.5, "SMADAR_TEST2": 0.2},
    #default_sampling_rate=0.7
)

# print("------------------ get config ------------------")
# config = my_mona_client.get_config()
# print(config)

# print("------------------ get_suggested_config ------------------")
# res = my_mona_client.get_suggested_config()
# my_suggested_mona_config = my_mona_client.get_suggested_config()
# print(my_suggested_mona_config)
from mona_sdk import MonaSingleMessage, Client

config = {"user_id": 123}

# print("------------------ upload config ------------------")
# res = my_mona_client.upload_config(config, f"Anat test {time.time()}", "anat_local_test")
# print(res)


# print("------------------ send single message ------------------")
# example_to_send = {"ANAT_TEST": "b", "c": None, "test": 2, "a": False, "b": None}
# succeed_to_export = my_mona_client.export(MonaSingleMessage(
#     message=example_to_send,
#     contextClass='ANAT_TEST',
#     contextId='603c97a218d6812b4cce32fa1',
#     exportTimestamp="2021-05-04T21:55:23+00:00",
# ), filter_none_fields=False)
# print(succeed_to_export)


print("------------------ send batch ------------------")

#example_to_send = {"SMADAR_TEST": "a"}
succeed_to_export = my_mona_client.export_batch([
    MonaSingleMessage(
        message={"smadar_test": "a - should be added"},
        contextClass="SMADAR_TEST1",
        contextId='603c97a218d6812b4cce32fa',
    ),
    MonaSingleMessage(
        message={"smadar_test": "b - shouldn't be added 1"},
        contextClass="SMADAR_TEST2",
        contextId='903c97aagfd6812b4c8e32fa',
    ),
    MonaSingleMessage(
        message={"smadar_test": "c - shouldn't be added 2"},
        contextClass="SMADAR_TEST1",
        contextId='903c97aagfd6812b48gj27df',
    ),
    MonaSingleMessage(
        message={"smadar_test": "d - should be added or not, without context_id"},
        contextClass="SMADAR_TEST1",
    ),
    MonaSingleMessage(
        message={"smadar_test": "e - should be added or not, without context_id"},
        contextClass="SMADAR_TEST_NOT_IN_SAMPLING_CONFIG",
    ),
    MonaSingleMessage(
        message={"smadar_test": "f - should be added, with context_id"},
        contextClass="SMADAR_TEST_NOT_IN_SAMPLING_CONFIG",
        contextId='10jjf8e4gfd681204j38f7gb'
    )
])

print(succeed_to_export)
#
#
# a = {
#     "userId": "JMETER_TEST_USER_ID",
#     "messages": [
#         {
#             "arcClass": "JMETER_TEST",
#             "message": {
#                 "field_number_0": "we want each message to be 2k with 20 fields, here's a random numberrandom.nextInt()",
#                 "field_number_1": "we want each message to be 2k with 20 fields, here's a random numberrandom.nextInt()"
#             },
#             "contextId": "context_random.nextInt()",
#             "exportTimestamp": "1649215835"},
#         {
#             "arcClass": "JMETER_TEST",
#             "message": {
#                 "field_number_0": "we want each message to be 2k with 20 fields, here's a random numberrandom.nextInt()",
#                 "field_number_1": "we want each message to be 2k with 20 fields, here's a random numberrandom.nextInt()"
#             },
#             "contextId": "context_random.nextInt()",
#             "exportTimestamp": "1649215835"
#         }
#     ]
# }



