Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!
Labels (1)
avatar
Rising Star

Introduction

Cloudbreak documentation is fairly thorough and can be found on Hortonworks' documentation portal (e.g. here). However, if you are as lazy as I am, you'll appreciate the few quick examples I'm listing in this article.

First and foremost, you can access the documentation of available APIs on your CB instance by using the following URL https://[YOUR_CB_URL]/cb/apidocs; you should see something like this:

95389-screen-shot-2018-12-10-at-95700-am.png

Authenticating

Authentication in cloudbreak is OAuth 2, and getting a detailed in the Cloudbreak API.

Here is simple curl call to get a token:

curl -k -iX POST -H "accept: application/x-www-form-urlencoded" -d 'credentials={"username":"[YOUR_USER]","password":"[YOUR_PWD]"}' "https://[YOUR_CB_URL]/identity/oauth/authorize?response_type=token&client_id=cloudbreak_shell&scope.0=openid&source=login&redirect_uri=http://cloudbreak.shell" | grep location | cut -d'=' -f 3 | cut -d'&' -f 1

GET Example: Listing all blueprints

The biggest trick to the CB API is to know the URL to use and to remember to disable SSL Certificate Verification (using the -k in curl).

Here is an example call that lists all blueprints:

TOKEN=$(curl -k -iX POST -H "accept: application/x-www-form-urlencoded" -d 'credentials={"username":"[YOUR_USER]","password":"[YOUR_PWD]"}' "https://[YOUR_CB_URL]/identity/oauth/authorize?response_type=token&client_id=cloudbreak_shell&scope.0=openid&source=login&redirect_uri=http://cloudbreak.shell" | grep location | cut -d'=' -f 3 | cut -d'&' -f 1)
curl -X GET   https://YOUR_CB_URL]/cb/api/v1/blueprints/account   -H "Authorization: Bearer $TOKEN"   -H 'Content-Type: application/json'   -H 'cache-control: no-cache'   -k

POST Example: Adding an mpack

TOKEN=$(curl -k -iX POST -H "accept: application/x-www-form-urlencoded" -d 'credentials={"username":"[YOUR_USER]","password":"[YOUR_PWD]"}' "https://[YOUR_CB_URL]/identity/oauth/authorize?response_type=token&client_id=cloudbreak_shell&scope.0=openid&source=login&redirect_uri=http://cloudbreak.shell" | grep location | cut -d'=' -f 3 | cut -d'&' -f 1)
curl -X POST   https://[YOUR_CB_URL]/cb/api/v1/mpacks/account   -H "Authorization: Bearer $TOKEN"   -H 'Content-Type: application/json'   -H 'cache-control: no-cache'   -d '{
  "name": "hdf-3-2-aws",
  "description": "HDF 3.2 Mangement Pack for AWS",
  "mpackUrl": "http://public-repo-1.hortonworks.com/HDF/amazonlinux2/3.x/updates/3.2.0.0/tars/hdf_ambari_mp/hdf-ambari-mpack-3.2.0.0-520.tar.gz",
  "purge": false,
  "force": false
}'   -k

POST Example: Uploading a user blueprint

To upload your own blueprints, remember to encode your blueprint in base64

TOKEN=$(curl -k -iX POST -H "accept: application/x-www-form-urlencoded" -d 'credentials={"username":"[YOUR_USER]","password":"[YOUR_PWD]"}' "https://[YOUR_CB_URL]/identity/oauth/authorize?response_type=token&client_id=cloudbreak_shell&scope.0=openid&source=login&redirect_uri=http://cloudbreak.shell" | grep location | cut -d'=' -f 3 | cut -d'&' -f 1)
ENCODED_BLUEPRINT=$(base64 [YOUR_BP_JSON_LOCATION])
  curl -X POST   https://[YOUR_CB_URL]/cb/api/v1/blueprints/user   -H "Authorization: Bearer $TOKEN"   -H 'Content-Type: application/json'   -H 'cache-control: no-cache'   -d " {
        \"ambariBlueprint\": \"$ENCODED_BLUEPRINT\",
        \"description\": \"Blueprint for HWX Data Science Uploaded\",
        \"inputs\": [],
        \"tags\": {},
        \"name\": \"data-science-workshop-upload\",
        \"hostGroupCount\": 1,
        \"status\": \"USER_MANAGED\",
        \"public\": true
    }"   -k
1,763 Views
Version history
Last update:
‎08-17-2019 05:23 AM
Updated by:
Contributors