Metadata-Version: 2.1
Name: 4logik-python-rest-client
Version: 1.0.3
Summary: Execute microservice endpoint using HTTP REST
Home-page: https://www.4logik.com/
Author: Eugenia Morales
Author-email: eugeniamorales251@gmail.com
License: MIT
Description: # 4logik python rest client
        Utility package to call an enpoint generated by 4Logik
        
        ## Installation
        Use pip
        
        ```
        pip install 4logik-python-rest-client
        ```
        
        ## How to call a CSV endpoint
        - Locate the input CSV file
        - Identify the URL of the enpoint
        - Identify the name of the data set of the response that contains the results
        
        Example of using the package:
        
        ```python
        from py4logik_python_rest_client.endpoint_caller import call_csv_endpoint, call_csv_endpoint_read_data_set
        
        # input parameters
        input_csv_file = "/home/user1/incomingData.csv"
        endpoint_url = "http://myOrganization.myDeployedService.com/RiskCalulationProcess"
        
        # call the endpoint
        received_json_data = call_csv_endpoint(ms_url, input_csv_file)
        print(received_json_data)
        ```
        
        The result will contain useful metadata like the quantity of business exceptions and the list of data sets which you can print using:
        
        ```python
        print(received_json_data["data_sets_names"])
        ```
        
        To read only the rows of a specific data you have two options, option 1 is to read it by index from the array of results, for example in the following code we read the first result data set:
        
        ```python
        print(received_json_data["data_sets_results"][0])
        ```
        
        The second option is to call the method that returns only a specific data set result name like this:
        
        ```python
        specific_data_set_name_to_read = "ReportResult"
        data_set_result_rows = call_csv_endpoint_read_data_set(ms_url, input_csv_file, specific_data_set_name_to_read)
        print(data_set_result_rows)
        ```
        
        ## Example using the package inside Jupyter and converting the result to a data frame:
        
        ```python
        import json
        import pandas as pd
        import tempfile
        
        from py4logik_python_rest_client.endpoint_caller import call_csv_endpoint_read_data_set
        
        # input parameters
        input_csv_file = "/home/user1/incomingData.csv"
        endpoint_url = "http://myOrganization.myDeployedService.com/RiskCalulationProcess"
        dataset_name = "riskResult"
        
        # call the endpoint
        received_json_data = call_csv_endpoint_read_data_set(ms_url, input_csv_file, dataset_name)
        
        # now convert the received json to panda
        temp_file = tempfile.NamedTemporaryFile(delete=False)
        output_json = temp_file.name
        
        with open(output_json,'w', encoding='UTF_8') as f:
            f.write(json.dumps(received_json_data))
            f.close()
        
        final_data_frame = pd.read_json(output_json)
        
        final_data_frame
        ```
Keywords: python project
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
