:launchURL: https://developers.redhat.com/launch :image: registry.access.redhat.com/fuse7/fuse-java-openshift:1.0 = REST API Level 0 - Fuse Booster == Overview The REST API Level 0 mission shows how to map business operations to a remote procedure call endpoint over HTTP using a REST framework. This corresponds to Level 0 in the Richardson Maturity Model. Creating an HTTP endpoint using REST and its underlying principles to define your API lets you quickly prototype and design the API flexibly. This booster introduces the mechanics of interacting with a remote (exposed by Apache Camel) service using the HTTP protocol. It allows you to: * Execute an HTTP GET request on `api/greetings/{name}`` endpoint; using the url parameter `{name}` and producing a response in JSON format with a payload of Hello, $name! with $name replaced by the value of the url parameter used into the request. * Browse the api's Swagger page. == Deployment options This booster can run in the following modes: * Standalone on your machine * Single-node OpenShift cluster * OpenShift Online at link:{launchURL}[] The most effective way to demonstrate the booster is to deploy and run the project on OpenShift. For more details about running this booster on a single-node OpenShift cluster, CI/CD deployments, as well as the rest of the runtime, see the link:http://appdev.openshift.io/docs/spring-boot-runtime.html[Spring Boot Runtime Guide]. IMPORTANT: This booster requires Java 8 JDK or greater and Maven 3.3.x or greater. == Running the booster standalone on your machine You can run this booster as a standalone project on your local machine: . Download the project and extract the archive on your local filesystem. . Build the project: + [source,bash,options="nowrap",subs="attributes+"] ---- $ cd PROJECT_DIR $ mvn clean package ---- . then run the services as follows: + [source,bash,options="nowrap",subs="attributes+"] ---- $ mvn spring-boot:run ---- . Visit link:http://localhost:8080[] and follow the instructions on that page. == Running the booster on a single-node OpenShift cluster If you have a single-node OpenShift cluster, such as Minishift or the Red Hat Container Development Kit, link:http://appdev.openshift.io/docs/minishift-installation.html[installed and running], you can deploy your booster there. A single-node OpenShift cluster provides you with access to a cloud environment that is similar to a production environment. IMPORTANT: You need to run this example on Container Development Kit 3.3 or OpenShift 3.7. Both of these products have suitable Fuse images pre-installed. If you run it in an evironment where those images are not preinstalled follow the steps described in <>. To deploy your booster to a running single-node OpenShift cluster: . Download the project and extract the archive on your local filesystem. . Log in to your OpenShift cluster: + [source,bash,options="nowrap",subs="attributes+"] ---- $ oc login -u developer -p developer ---- . Create a new OpenShift project for the booster: + [source,bash,options="nowrap",subs="attributes+"] ---- $ oc new-project MY_PROJECT_NAME ---- . Build and deploy the project to the OpenShift cluster: + [source,bash,options="nowrap",subs="attributes+"] ---- $ mvn clean -DskipTests fabric8:deploy -Popenshift ---- . In your browser, navigate to the `MY_PROJECT_NAME` project in the OpenShift console. Wait until you can see that the pod for the `fuse-rest-http-booster` application has started up. . Just above the entry for the `fuse-rest-http-booster` application on the `Overview` page, there is a URL of the form `http://fuse-rest-http-booster-MY_PROJECT_NAME.OPENSHIFT_IP_ADDR.nip.io`. Click on the URL to access the greetings service application and follow the instructions on that page. [#single-node-without-preinstalled-images] === Running the booster on a single-node OpenShift cluster without preinstalled images To deploy your booster to a running single-node OpenShift cluster without preinstalled images: . Download the project and extract the archive on your local filesystem. . Log in to your OpenShift cluster: + [source,bash,options="nowrap",subs="attributes+"] ---- $ oc login -u developer -p developer ---- . Create a new OpenShift project for the booster: + [source,bash,options="nowrap",subs="attributes+"] ---- $ oc new-project MY_PROJECT_NAME ---- . Import base images in your newly created project (MY_PROJECT_NAME): + [source,bash,options="nowrap",subs="attributes+"] ---- $ oc import-image fis-java-openshift:2.0 --from={image} --confirm ---- . Build and deploy the project to the OpenShift cluster: + [source,bash,options="nowrap",subs="attributes+"] ---- $ mvn clean -DskipTests fabric8:deploy -Popenshift -Dfabric8.generator.fromMode=istag -Dfabric8.generator.from=MY_PROJECT_NAME/fis-java-openshift:2.0 ---- . In your browser, navigate to the `MY_PROJECT_NAME` project in the OpenShift console. Wait until you can see that the pod for the `fuse-rest-http-booster` application has started up. . Just above the entry for the `fuse-rest-http-booster` application on the `Overview` page, there is a URL of the form `http://fuse-rest-http-booster-MY_PROJECT_NAME.OPENSHIFT_IP_ADDR.nip.io`. Click on the URL to access the greetings service application and follow the instructions on that page. == Running the booster on OpenShift Online You can deploy the circuit breaker booster directly to OpenShift Online when you create the project at link:{launchURL}[]. . Visit link:{launchURL}[]. . At the *Deployment step*, select *Use OpenShift Online*. . Follow the on-screen instructions to create a new *REST API Level 0ee* project using the *Fuse* runtime. NOTE: As part of the process of creating this booster, link:{launchURL}[] sets up a project with a CI/CD deployment of this booster. You can see the status of this deployment in your Single-node OpenShift Cluster or OpenShift Online Web Console.