Skip to content

Latest commit

 

History

History
93 lines (72 loc) · 4.77 KB

2.apiimplementation.md

File metadata and controls

93 lines (72 loc) · 4.77 KB

API Implementation and Reuse

Overview

In this hands-on lab you will extend itineraries API implementation by reusing aircrafts API. The current itineraries API responds with reservation, passenger, flight and status details. We want to also include aircraft details.

Get Started

Start by signing into TIBCO Cloud and opening Flogo. There are many ways to navigate to Flogo but let’s start with this.

[To return to the Home Page of TIBCO Cloud Integration, clik the TIBCO CLOUD icon from the top left corner]

  1. Start at Welcome to your TIBCO Cloud (Home Page).
  2. Select Integration.
  3. Select Integration Apps.

Import Application

We are going to use a prebuilt application for this hands-on lab and extend it by reusing flights API.

  1. Select Create/Import app.
  2. Select Flogo.
  3. Select Create New App.
  4. On screen that opens next, click Import app.
  5. Navigate to where you extracted the connected customer experience artifacts and choose or drag "project/apispects/TCI/itineraries_lab/v1_itineraries_todo.json" into upload files and select Upload. Or redownload the v1_itineraries_todo.json (tip: ctrl+click and save file)
  6. Note the Errors and Warnings screen - and then click Import All.
  7. Click on the default name and type ‘FlightItinerariesApp’ as the new name.
  8. You are now ready to extend this API with aircraft details.

Extend and Reuse API

Let’s extend the itineraries API to include aircrafts details.

  1. Select V1Itineraries_reservationid_GET. GET /itineraries/{reservationid} implementation will be opened. Here you see the orchestration that invokes reservations, passengers, flights, and statuses APIs. You are now going invoke an API call to aircrafts in the next steps.
  2. Hover your mouse over the gray line and select the + to add a new activity.
  3. From Add Activity, scroll down, select General, select Invoke REST Service.
  4. Drag the InvokeRESTService to the right of Status step (i.e before the Return step).
  5. Now let’s configure the Invoke Rest Service activity.
    1. Let’s rename this activity. Select InvokeRESTService, hover your mouse over the name InvokeRESTService and select the edit icon.
    2. Rename InvokeRESTService to Aircraft.
    3. Select Settings and paste the following URL in URL field. https://integration.cloud.tibcoapps.com:443/wz3dr4zotkxmqg5au6yhc526iw2otlc2/v1/aircrafts/{aircraftid}
    4. Now let’s map activity input.
    • Select Input, expand pathParams and select aircraftid.
    • Expand Upstream Output->Reservation->responseBody->reservation and select aircraftid.
    1. Configure the Output settings.
      • Select Output Settings and paste the following schema into Response Schema.
{"aircraft":
    {"aircraftid":"111",
    "type":"767",
    "seatcapacity":"280"}
}
- Save this configured "Aircraft" step.
  1. Let’s map the aircraft details into the Return activity.
    1. Select Return activity chevron from the flow at the top (the step after the Invoke Rest Service you just added),
    2. Then expand Flow Outputs->itinerary and select aircraft.
    3. In upstream Output, expand Aircraft->responseBody, select aircraft.
    4. Click Save

Start Testing

In this section we will test itineraries API implementation.

  1. Select Test button (top right).
  2. Select Create a Launch Configuration.
  3. Expand Activity Input under the Mapping settings, flowInputs->pathParams->reservationid. And enter "AAAAA11111" into flowInputs. Use quotes.
  4. Select Next.
  5. Select Run.
  6. Your Testing is complete. Scroll down to see the response and confirm that aircraft details were added to the response.
  7. Select Stop Testing.
  8. Close the testing window.
  9. Click arrow on left to return to the FlightItinerariesApp main page.

Push App

In this section we are going to push the itineraries app to the cloud and test the live endpoints.

  1. Select Push app button to the right of the page.
  2. The itineraries app will be pushed to the cloud.
  3. Change the number of instances to 1 and click Scale button.
  4. Message will be changing to Running.
  5. Test your live endpoint by selecting Endpoints tab, then click the Test link.
  6. Expand the GET request and click Try it out.
  7. Enter AAAAA11111 for reserverationid input parameter and select Execute.

Summary

In this exercise you imported an application and extended by reusing aircrafts API. You performed a local test and pushed the application to the cloud. You finshed by testing the application's live endpoints.

Next step: Import Offer API Engine