YaaS Bites Sequel

YaaS Bites Sequel

The YaaS Bites enable software developers to go from zero-to-YaaS in a couple of days. They are small, focused, incremental coding exercises. Each bite has code, guidelines, and screencasts to ensure your initial journey into YaaS is successful and productive. These bites go beyond Java, and assume you have already worked through the YaaS Bites Essentials.

Index

YaaS with ScalaYaaS with AkkaYaaS with Node.JS

Terminology and Notes

  • You should view these bites on large screens as the layout of the bites is suboptimal on small displays.
  • : The durations given beside each bite are estimates.
  • ⓪ ① ②: Encircled numbers are used to label a concept in a bite, that is then referred to later on in the same bite, using the same encircled number.
  • Terminology: The YaaS Landscape has its own set of terms that, including: package, client, service, project, and more. As these terms often mean other things to developers, YaaS entities are prepended with YaaS, for example "YaaS package", "YaaS client", "YaaS service".
  • The screencasts are silent, and show users working through respective bites. They are not stand-alone tutorials, but are there to add clarity, should something be unclear. Double-click the screencasts to expand them to full screen.

YaaS Bite: A first Scala micro-service ~ 2h*

(Credit to Gaurav.Abbi@sap.com)

Background

The previous bites are all based on Java. This bite explores creating and deploying a micro-service written in Scala. You can use Lightbend's Activator to explore the code, compile, and run the tests. Be sure you understand the initial bites from the YaaS Bites Essentials before doing this bite.

Steps

  1. Download the Play Framework Activator, then add to your System Path (export PATH="pathToYourActivator/bin:$PATH" on OSX, and set PATH=%PATH%;pathToYourActivator/bin on Windows)
  2. For this bite, navigate into the (yb)/scala/scala-yaasbite100 folder.
  3. Execute , from within scala-yaasbite100, which opens the activator in a browser @ http://127.0.0.1:8888/app/scala-yaasbite100-1
  4. You need to become familiar with the activator UI elements, labelled in the screencast and below with (a), (b), (c), ...
    1. Build the Scala project with the Build Menu Entry (a)
    2. Study the code in Code/app/controller and Code/app/model (b)
    3. Study the routing logic @ Code/conf/routes (c)
    4. Study the tests @ Coder/test/* (d)
    5. Run the tests and confirm the tests are passing (e)
    6. Run the code (f) and click the url (g) to open the front-end of your solution (h)
  5. Adjust the name in the manifest.yml file to be unique to you.
  6. Push to the cloud (), verify the application's location in the cloud with () and open that site in the browser
  7. You have now compiled and deployed a Scala micro-service and front-end to the cloud.

YaaS Bite: A CRUD web-service in Scala ~ 1h*

(Credit to Gaurav.Abbi@sap.com)

Background

This Bite has the same business behavior as Working with a CRUD web service, but is implemented in Scala. Be sure you understand the initial bites from the YaaS Bites Essentials before doing this bite.

Steps

  1. For this bite, navigate into the (yb)/scala/scala-yaasbite200 folder and execute
  2. This opens the activator in a browser @ http://127.0.0.1:8888/app/scala-yaasbite200-1 from where you can explore, build, test and run the code locally.
 

YaaS Bite: Calling other services in Scala ~ 2h*

(Credit to Gaurav.Abbi@sap.com)

Background

This Bite has the same business behavior as Calling other services, but is implemented in Scala. Be sure you understand the bites from the YaaS Bites Essentials before doing this bite.

Initial exploration

  1. For this bite, navigate into the (yb)/scala/scala-yaasbite800 folder and execute
  2. This opens the activator in a browser @ http://127.0.0.1:8888/app/scala-yaasbite800-1 from where you can explore, build, test and run the code locally.

Steps

  1. Navigate into the project-directory scala-yaasbite800
  2. Adjust the name in the manifest.yml to make it unique
  3. You need the location of our micro-service in the cloud, but it is not yet adjusted and ready to be deployed.  To get around this, you can skip running tests for now.  Run the following commands
    1. activator dist
    2. cf push
    3. cf apps
  4. Take a note of the URL ① to where the package has been deployed
  5. In your YaaS project
    1. Subscribe to the Persistence (Beta) Package in the YaaS Market.
    2. Wire the micro-service into YaaS: Create a new Service in the YaaS Builder and specify the deployed URL ① in the service's Source URL field. Be sure you use the https prefix (protocol) in the Source URL field.
    3. Add a YaaS client to your YaaS service, and add the three scopes required by the Document Service ( hybris.document_view, hybris.document_manage, and hybris.document_admin) to its list of Required Scopes. This allows you to use its credentials to acquire access-tokens with those scopes.
    4. Be sure to deploy the YaaS service with the Deploy Button in the YaaS service's page.
  6. Modify the configurations in your Scala web service: Search for ADJUSTING and modify those entries to match your YaaS project settings.
  7. Run the tests with activator clean compile test. If these pass, your Scala service is successfully calling the Deployment Service.
  8. Debug through the tests to find how the access-tokens are acquired, and how the document service is being called.
  9. Repackage and redeploy with:
    1. activator dist
    2. cf push
  10. Hit your website. You should see that the application works as before but is now using the Document Service for its persistence.
 

YaaS Bite: Calling other services with Akka ~ 2h*

(Credit to Gaurav.Abbi@sap.com)

Background

This Bite has the same business behavior as Calling other services, but is implemented with Akka.

Initial Exploration

  1. For this bite, navigate into the (yb)/akka/akka-yaasbite800 folder and execute
  2. This opens the activator in a browser @ http://127.0.0.1:8888/app/akka-yaasbite800/ from where you can explore, build, test and run the code locally.

Steps

  1. Navigate into the project-directory (yb)/akka/akka-yaasbite800
  2. The next steps are identical to those in Calling other services in Scala.
 

YaaS Bite: Node.JS Client SDK from hybris Labs ~ 1h*

(Credit to hybris Labs Team)

Background

The NodeJS Client SDK, from hybris Labs, makes it almost trivial to call a YaaS service from Javascript.

Steps

  1. Locate or create a YaaS client with the Product scope
    1. Create a new YaaS project.
    2. Create a new YaaS client within that project and take note of the YaaS client's client_id and client_secret.
    3. Subscribe your YaaS project to the Product Content (Beta) package.
    4. This subscription adds the Product menu to your YaaS Project's Builder page. Use this Product menu to add products to your YaaS project.
  2. Create a client to query your YaaS project for its products.
    1. Clone the Node.js client and change into that directory.
    2. Rename the file yaas-nodejs-client-sdk/examples/test-config-TEMPLATE.json to test-config.json, and update the content to suit your scenario.
    3. If you have not installed node, download it from the https://nodejs.org website.
    4. Execute the command to list the products in your YaaS project.
  3. Examine the code in examples/product.js and see how easy it is to call YaaS services via the Node.JS client.

On Github @ https://github.com/SAP/yaas-getting-started-yaasbites


  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.