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 Scala- YaaS Bite: Taking your first scala web service to the cloud
- YaaS Bite: Working with a Scala CRUD web service
- YaaS Bite: Calling other services in Scala
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
- Download the Play Framework Activator, then add to your System Path (
export PATH="pathToYourActivator/bin:$PATH"
on OSX, andset PATH=%PATH%;pathToYourActivator/bin
on Windows) - For this bite, navigate into the
(yb)/scala/scala-yaasbite100
folder. - Execute , from within
scala-yaasbite100
, which opens the activator in a browser @http://127.0.0.1:8888/app/scala-yaasbite100-1
- You need to become familiar with the activator UI elements, labelled in the screencast and below with (a), (b), (c), ...
- Build the Scala project with the Build Menu Entry (a)
- Study the code in Code/app/controller and Code/app/model (b)
- Study the routing logic @ Code/conf/routes (c)
- Study the tests @ Coder/test/* (d)
- Run the tests and confirm the tests are passing (e)
- Run the code (f) and click the url (g) to open the front-end of your solution (h)
- Adjust the name in the manifest.yml file to be unique to you.
- Push to the cloud (), verify the application's location in the cloud with () and open that site in the browser
- 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
- For this bite, navigate into the
(yb)/scala/scala-yaasbite200
folder and execute - 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
- For this bite, navigate into the
(yb)/scala/scala-yaasbite800
folder and execute - 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
- Navigate into the project-directory
scala-yaasbite800
- Adjust the name in the manifest.yml to make it unique
- 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
activator dist
cf push
cf apps
- Take a note of the URL ① to where the package has been deployed
- In your YaaS project
- Subscribe to the Persistence (Beta) Package in the YaaS Market.
- 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.
- 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.
- Be sure to deploy the YaaS service with the Deploy Button in the YaaS service's page.
- Modify the configurations in your Scala web service: Search for ADJUSTING and modify those entries to match your YaaS project settings.
- Run the tests with
activator clean compile test
. If these pass, your Scala service is successfully calling the Deployment Service. - Debug through the tests to find how the access-tokens are acquired, and how the document service is being called.
- Repackage and redeploy with:
activator dist
cf push
- 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
- For this bite, navigate into the
(yb)/akka/akka-yaasbite800
folder and execute - 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
- Navigate into the project-directory
(yb)/akka/akka-yaasbite800
- 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
- Locate or create a YaaS client with the Product scope
- Create a new YaaS project.
- Create a new YaaS client within that project and take note of the YaaS client's client_id and client_secret.
- Subscribe your YaaS project to the Product Content (Beta) package.
- This subscription adds the Product menu to your YaaS Project's Builder page. Use this Product menu to add products to your YaaS project.
- Create a client to query your YaaS project for its products.
- Clone the Node.js client and change into that directory.
- Rename the file
yaas-nodejs-client-sdk/examples/test-config-TEMPLATE.json
totest-config.json
, and update the content to suit your scenario. - If you have not installed
node
, download it from the https://nodejs.org website. - Execute the command to list the products in your YaaS project.
- 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
If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.
Use our private help channel. Receive updates over email and contact our specialists directly.
If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.