# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Use case 1 - Setup vars - Process files

# ### Step 1 :  configure server and check health

# +
from jupyter_apis.API_Client import API_Client
import json

url_server='http://api:8880'             # api dns resolution is provided by docker-compose or kubernetes
api = API_Client(url_server)

assert api.health() =={'status': 'ok'}       
# -

# ### Step 2 : Configure hard discs
#
# - Configure hd1_path, hd2_path and hd3_path in "data"

# +

data = { "hd1_path"  : "./test_data/scenario-1/hd1", 
         "hd2_path"  : "./test_data/scenario-1/hd2", 
         "hd3_path"  : "./test_data/scenario-1/hd3"}    

response=api.configure_environment(data=data)
assert response.status_code == 200 
assert response.json() == data

"Hard discs are configured"

# -

# ### Step 3 : Configure GW SDK Endpoints
#
# - Configure gw sdk IP and Port
# - Edit IP and Port in varibale "data"
# - You can pass multiple endpoints
# - Example : data = '{ "Endpoints": [{ "IP": "172.16.17.32", "Port": "8080" },{ "IP": "127.0.0.1", "Port": "8080" }]}'

# +
data = { "Endpoints": [{ "IP": "172.16.31.10", "Port": "8080" } ] }

response=api.set_gw_sdk_endpoints(data=data)
assert response.status_code == 200
assert response.json() == data

"SDK Endpoints are set"

# -

# ### Step 4 : Process files
#
# These calls will:
#
# - copy all files from HD1 into HD2 (based on hash)
# - process all files from HD2 using Glasswall Cloud SDK
# - copy all processed files into HD3
#

assert api.pre_process() == '["Processing is done"]'
assert api.start_process() == '"Loop completed"'
"all files processed "

# +

API_Client('http://api:8880' ).health()
# -

# # Step 5 : Folder structure visualization

# +
from jupyter_apis.Display_Path import display_path

display_path('../test_data/scenario-1')
# -





StarcoderdataJupyterScriptsDedupFiltered