This Blog aims to showcase a Case Study on how Truck Bookings can be made on a RESTFul Application developed in Python and how Vendors can respond to the Request through Booking Confirmations made through RESTFul Calls completely trigerred and managed through Workload Automation. We have a REST API Program developed in Python using Flask, running in the background on a Server ,the data is stored on a Mongo DB and this API can process the below types of queries :
So, in order to retrieve the list of bookings from such an Application , the company plans to use Workload Scheduler , the get action is defined as a RESTFul Job using the RESTFul Job Type , the job is defined as follows , the Service URL in the Job would be the link which is being hit in the Application , this would be a GET Method Type Job , you would also be filling out the User ID and Password or have Certificate Based Authentication using a keystore Path and password to hit the Service URL in the Authentication tab : The job when executed would send a JSON Response in the Joblog output as shown below with a listing of all Booking Requests made : Job RESTFUL_GET_ALLBOOKINGS Workstation (Job) AGENT Job Stream JOBS Workstation (Job Stream) AGENT =============================================================== = JOB : AGENT#JOBS[(0330 05/25/20),(CF20145AAAAAAAAD)].RESTFUL_GET_ALLBOOKINGS = TASK : <?xml version="1.0" encoding="UTF-8"?> <jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:jsdlrestful="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdlrestful" name="RESTFUL"> <jsdl:variables> <jsdl:stringVariable name="tws.jobstream.name">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.jobstream.id">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.name">RESTFUL_GET_ALLBOOKINGS</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.workstation">AGENT</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.iawstz">202005250330</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.promoted">NO</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.resourcesForPromoted">10</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.num">850043560</jsdl:stringVariable> </jsdl:variables> <jsdl:application name="restful"> <jsdlrestful:restful> <jsdlrestful:RestfulParameters> <jsdlrestful:Authentication> <jsdlrestful:credentials> <jsdl:userName/> <jsdl:password>{aes}MvwiATDb+mZbkSTdrSBDb8AAolOo3TwNhrlCxC9a1Iw=</jsdl:password> </jsdlrestful:credentials> <jsdlrestful:CertificateGroup> <jsdlrestful:keyStoreFilePath/> <jsdlrestful:password/> <jsdlrestful:HostnameVerifyCheckbox/> </jsdlrestful:CertificateGroup> </jsdlrestful:Authentication> <jsdlrestful:RESTAction> <jsdlrestful:URI>http://127.0.0.1:5000/api/v1/resources/requests/all</jsdlrestful:URI> <jsdlrestful:method>GET</jsdlrestful:method> <jsdlrestful:outputFileName/> </jsdlrestful:RESTAction> <jsdlrestful:Body> <jsdlrestful:contentType>application/json</jsdlrestful:contentType> <jsdlrestful:BodyGroup> <jsdlrestful:FileBody> <jsdlrestful:InputFileName/> </jsdlrestful:FileBody> </jsdlrestful:BodyGroup> </jsdlrestful:Body> <jsdlrestful:Advanced> <jsdlrestful:Accept/> <jsdlrestful:JSONPropertiesGroup> <jsdlrestful:JsonObjectResultQuery/> </jsdlrestful:JSONPropertiesGroup> <jsdlrestful:NumberOfRetries>0</jsdlrestful:NumberOfRetries> <jsdlrestful:RetryIntervalSeconds>30</jsdlrestful:RetryIntervalSeconds> </jsdlrestful:Advanced> </jsdlrestful:RestfulParameters> </jsdlrestful:restful> </jsdl:application> <jsdl:resources> <jsdl:orderedCandidatedWorkstations> <jsdl:workstation>3646FC79FFB046588013F5C87F3F0A4A</jsdl:workstation> </jsdl:orderedCandidatedWorkstations> </jsdl:resources> </jsdl:jobDefinition> = TWSRCMAP : = AGENT : AGENT = Job Number: 850043560 = Mon 05/25/2020 15:08:07 IST =============================================================== { "result": [ { "Date": "05/25/2020", "Destination": "Mumbai", "Source": "Bengaluru", "Time": "10:00PM", "Type": "5 Ton(17 ft)", "id": 2 }, { "Date": "05/25/2020", "Destination": "Mumbai", "Source": "Bengaluru", "Time": "10:00PM", "Type": "5 Ton(17 ft)", "id": 2 }, { "Date": "05/25/2020", "Destination": "Mumbai", "Source": "Bengaluru", "Time": "10:00PM", "Type": "5 Ton(17 ft)", "id": 2 } ] } =============================================================== = Exit Status : 0 = Elapsed Time (hh:mm:ss) : 00:00:01 = Mon 05/25/2020 15:08:07 IST =============================================================== Likewise when a New Booking Request is made , a job is executed in the Background which would post the New Booking Request to the Mongo DB . The Job defined would include the Service URL of the Application and the Method selected as “POST” . The form filled in a Booking Portal is passed in the form of JSON Input and the Job posts this against the Mongo DB : Job RESTFUL_POST_TRUCKBOOKING Workstation (Job) AGENT Job Stream JOBS Workstation (Job Stream) AGENT =============================================================== = JOB : AGENT#JOBS[(0330 05/26/20),(JOBS)].RESTFUL_POST_TRUCKBOOKING = TASK : <?xml version="1.0" encoding="UTF-8"?> <jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:jsdlrestful="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdlrestful" name="RESTFUL"> <jsdl:variables> <jsdl:stringVariable name="tws.jobstream.name">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.jobstream.id">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.name">RESTFUL_POST_TRUCKBOOKING</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.workstation">AGENT</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.iawstz">202005260330</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.promoted">NO</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.resourcesForPromoted">10</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.num">850044088</jsdl:stringVariable> </jsdl:variables> <jsdl:application name="restful"> <jsdlrestful:restful> <jsdlrestful:RestfulParameters> <jsdlrestful:Authentication> <jsdlrestful:credentials> <jsdl:userName/> <jsdl:password>{aes}zmbgqdnW6ZCRQwb8vv7DepBfs731FXNJXPzJ913t0/8=</jsdl:password> </jsdlrestful:credentials> <jsdlrestful:CertificateGroup> <jsdlrestful:keyStoreFilePath/> <jsdlrestful:password/> <jsdlrestful:HostnameVerifyCheckbox/> </jsdlrestful:CertificateGroup> </jsdlrestful:Authentication> <jsdlrestful:RESTAction> <jsdlrestful:URI>http://127.0.0.1:5000/api/v1/resources/requests</jsdlrestful:URI> <jsdlrestful:method>POST</jsdlrestful:method> <jsdlrestful:outputFileName/> </jsdlrestful:RESTAction> <jsdlrestful:Body> <jsdlrestful:contentType>application/json</jsdlrestful:contentType> <jsdlrestful:BodyGroup> <jsdlrestful:TextBody> <jsdlrestful:InputTextBody/> </jsdlrestful:TextBody> </jsdlrestful:BodyGroup> </jsdlrestful:Body> <jsdlrestful:Advanced> <jsdlrestful:Accept/> <jsdlrestful:JSONPropertiesGroup> <jsdlrestful:JsonObjectResultQuery/> </jsdlrestful:JSONPropertiesGroup> <jsdlrestful:NumberOfRetries>0</jsdlrestful:NumberOfRetries> <jsdlrestful:RetryIntervalSeconds>30</jsdlrestful:RetryIntervalSeconds> </jsdlrestful:Advanced> </jsdlrestful:RestfulParameters> </jsdlrestful:restful> </jsdl:application> <jsdl:resources> <jsdl:orderedCandidatedWorkstations> <jsdl:workstation>3646FC79FFB046588013F5C87F3F0A4A</jsdl:workstation> </jsdl:orderedCandidatedWorkstations> </jsdl:resources> </jsdl:jobDefinition> = TWSRCMAP : = AGENT : AGENT = Job Number: 850044088 = Tue 05/26/2020 10:08:38 IST =============================================================== POST Successful =============================================================== = Exit Status : 0 = Elapsed Time (hh:mm:ss) : 00:00:01 = Tue 05/26/2020 10:08:38 IST =============================================================== Inorder to retrieve a booking for a Booking ID , a job would be run which would get a Truck Booking Application passing the ID in the Service URL as follows , this would be a RESTFUL GET Job as shown below : Job RESTFUL_GET_TRUCKINFO Workstation (Job) AGENT Job Stream JOBS Workstation (Job Stream) AGENT =============================================================== = JOB : AGENT#JOBS[(0330 05/26/20),(JOBS)].RESTFUL_GET_TRUCKINFO = TASK : <?xml version="1.0" encoding="UTF-8"?> <jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:jsdlrestful="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdlrestful" name="RESTFUL"> <jsdl:variables> <jsdl:stringVariable name="tws.jobstream.name">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.jobstream.id">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.name">RESTFUL_GET_TRUCKINFO</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.workstation">AGENT</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.iawstz">202005260330</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.promoted">NO</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.resourcesForPromoted">10</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.num">850044087</jsdl:stringVariable> </jsdl:variables> <jsdl:application name="restful"> <jsdlrestful:restful> <jsdlrestful:RestfulParameters> <jsdlrestful:Authentication> <jsdlrestful:credentials> <jsdl:userName/> <jsdl:password>{aes}3pIZo56cOJkT3Ri+IpkgVHu75fXyGr+0RGqh3tYiVTc=</jsdl:password> </jsdlrestful:credentials> <jsdlrestful:CertificateGroup> <jsdlrestful:keyStoreFilePath/> <jsdlrestful:password/> <jsdlrestful:HostnameVerifyCheckbox/> </jsdlrestful:CertificateGroup> </jsdlrestful:Authentication> <jsdlrestful:RESTAction> <jsdlrestful:URI>http://127.0.0.1:5000/api/v1/resources/requests?id=0</jsdlrestful:URI> <jsdlrestful:method>GET</jsdlrestful:method> <jsdlrestful:outputFileName/> </jsdlrestful:RESTAction> <jsdlrestful:Body> <jsdlrestful:contentType>application/json</jsdlrestful:contentType> <jsdlrestful:BodyGroup> <jsdlrestful:FileBody> <jsdlrestful:InputFileName/> </jsdlrestful:FileBody> </jsdlrestful:BodyGroup> </jsdlrestful:Body> <jsdlrestful:Advanced> <jsdlrestful:Accept/> <jsdlrestful:JSONPropertiesGroup> <jsdlrestful:JsonObjectResultQuery/> </jsdlrestful:JSONPropertiesGroup> <jsdlrestful:NumberOfRetries>0</jsdlrestful:NumberOfRetries> <jsdlrestful:RetryIntervalSeconds>30</jsdlrestful:RetryIntervalSeconds> </jsdlrestful:Advanced> </jsdlrestful:RestfulParameters> </jsdlrestful:restful> </jsdl:application> <jsdl:resources> <jsdl:orderedCandidatedWorkstations> <jsdl:workstation>3646FC79FFB046588013F5C87F3F0A4A</jsdl:workstation> </jsdl:orderedCandidatedWorkstations> </jsdl:resources> </jsdl:jobDefinition> = TWSRCMAP : = AGENT : AGENT = Job Number: 850044087 = Tue 05/26/2020 10:07:02 IST =============================================================== [ { "Date": "05/20/2020", "Destination": "Chennai", "Source": "Mumbai", "Time": "08:00AM", "Type": "4 Ton(14 ft)", "id": 0 } ] =============================================================== = Exit Status : 0 = Elapsed Time (hh:mm:ss) : 00:00:01 = Tue 05/26/2020 10:07:02 IST =============================================================== The JSON Response retrieved can be viewed in the Joblog as shown above. In order to commit on a Truck Booking Request on the Portal, the Vendor willing to fulfill the Request would confirm the booking Details and a Commitment Time of the request , a RESTFul application running in the background as below would serve to fulfill the same : A job called RESTFUL_TRUCKINFO_COMMITMENT would get called which would be calling the URL http://127.0.0.1:5000/api/v1/resources/commitments to confirm the Booking, this would be a RESTFUL Post Type Job which would as shown below: The Joblog of this job execution would be as follows : Job RESTFUL_TRUCKINFO_COMMITMENT Workstation (Job) AGENT Job Stream JOBS Workstation (Job Stream) AGENT =============================================================== = JOB : AGENT#JOBS[(0330 05/25/20),(CF20145AAAAAAAAD)].RESTFUL_TRUCKINFO_COMMITMENT = TASK : <?xml version="1.0" encoding="UTF-8"?> <jsdl:jobDefinition xmlns:jsdl="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdl" xmlns:jsdlrestful="http://www.ibm.com/xmlns/prod/scheduling/1.0/jsdlrestful" name="RESTFUL"> <jsdl:variables> <jsdl:stringVariable name="tws.jobstream.name">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.jobstream.id">JOBS</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.name">RESTFUL_TRUCKINFO_COMMITMENT</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.workstation">AGENT</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.iawstz">202005250330</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.promoted">NO</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.resourcesForPromoted">10</jsdl:stringVariable> <jsdl:stringVariable name="tws.job.num">850044094</jsdl:stringVariable> </jsdl:variables> <jsdl:application name="restful"> <jsdlrestful:restful> <jsdlrestful:RestfulParameters> <jsdlrestful:Authentication> <jsdlrestful:credentials> <jsdl:userName/> <jsdl:password>{aes}+6ud69aC05miii+GX9AepE1U3XM8AZ7bvXjmV8CMZwA=</jsdl:password> </jsdlrestful:credentials> <jsdlrestful:CertificateGroup> <jsdlrestful:keyStoreFilePath/> <jsdlrestful:password/> <jsdlrestful:HostnameVerifyCheckbox/> </jsdlrestful:CertificateGroup> </jsdlrestful:Authentication> <jsdlrestful:RESTAction> <jsdlrestful:URI>http://127.0.0.1:5000/api/v1/resources/commitments</jsdlrestful:URI> <jsdlrestful:method>POST</jsdlrestful:method> <jsdlrestful:outputFileName/> </jsdlrestful:RESTAction> <jsdlrestful:Body> <jsdlrestful:contentType>application/json</jsdlrestful:contentType> <jsdlrestful:BodyGroup> <jsdlrestful:TextBody> <jsdlrestful:InputTextBody/> </jsdlrestful:TextBody> </jsdlrestful:BodyGroup> </jsdlrestful:Body> <jsdlrestful:Advanced> <jsdlrestful:Accept/> <jsdlrestful:JSONPropertiesGroup> <jsdlrestful:JsonObjectResultQuery/> </jsdlrestful:JSONPropertiesGroup> <jsdlrestful:NumberOfRetries>0</jsdlrestful:NumberOfRetries> <jsdlrestful:RetryIntervalSeconds>30</jsdlrestful:RetryIntervalSeconds> </jsdlrestful:Advanced> </jsdlrestful:RestfulParameters> </jsdlrestful:restful> </jsdl:application> <jsdl:resources> <jsdl:orderedCandidatedWorkstations> <jsdl:workstation>3646FC79FFB046588013F5C87F3F0A4A</jsdl:workstation> </jsdl:orderedCandidatedWorkstations> </jsdl:resources> </jsdl:jobDefinition> = TWSRCMAP : = AGENT : AGENT = Job Number: 850044094 = Tue 05/26/2020 10:38:26 IST =============================================================== POST Successful =============================================================== = Exit Status : 0 = Elapsed Time (hh:mm:ss) : 00:00:01 = Tue 05/26/2020 10:38:27 IST =============================================================== The Successful Post would create a New Commitment in a table in the MongoDB for the Application. Snippet of the type of Application running in the Background against which the IWS jobs are run , the below Implementation can be extended and made more complex as desired : Authors's Bio
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
Archives
August 2024
Categories
All
|