Thursday, September 29, 2022
HomeHealthcareLet's Make Some BCS Magic!

Let’s Make Some BCS Magic!


Howdy on the market in automation land! It has been some time since my final weblog, and new and thrilling issues proceed to occur. (Therefore the shortage of blogs.) I’m hopeful this kicks off the summer season on a sizzling foot and we get lots on the market. To let you realize about a number of the new work I’ve been taking up, I wished to carry you one thing from the land of Enterprise Important Providers (BCS). It is a new enviornment I’ve entered so I wished to share with you some foundational items of automation goodness! So we’re going to take a stab at a number of issues on this weblog…

  1. Constructing some wonderful Atomics for an API in SecureX Orchestration!
  2. Constructing workflows geared in the direction of our BCS Operational Insights API!
  3. Having the ability to map given code (on this case python) to SXO workflows
  4. Giving some finest practices round workflow and atomic creation
  5. Sharing with the readers a ton of pre-built content material you need to use to speed up your BCS automation work

Earlier than I get to our nice content material of the day, I’ve a number of issues to share. The primary one is that Cisco Stay is again and will probably be in particular person in fabulous Las Vegas! And sure readers, I will probably be there prepared to show you all about automation and orchestration. I will probably be instructing a 4 hour lab that yow will discover at LTRATO-1000. Within the lab I will probably be instructing alongside my superior buddy and co-automation skilled, Mohammed Hamzeh. Area is proscribed and some spots are nonetheless there so enroll at the moment! Secondly, one other cool factor I’ve began to work on is a podcast that we’ve began (once more, therefore much less blogs). This podcast is round bringing one of the best Cisco minds to you the listening viewers and our prospects. The podcast is named Cisco Tech Insiders and yow will discover it on SoundCloud (search for our brand… its a microphone with Cisco Tech Insiders subsequent to it) or on Spotify. I extremely would counsel some listens and see if something we discuss excites you. As at all times, you may counsel issues through e-mail to me or feedback on the weblog.

Like I stated… let’s make some magic! So time to focus on what we’re going to do at the moment and that’s to construct some atomics off of some python code from DevNet and assist us begin to construct out an API set or “Atomic Adapter” for BCS Operational Insights API.

To start out with any API, we have to discover Authentication and Documentation on the API Spec. Fortunately, this can be a properly achieved API and we’ve each! Authentication is completed through Shopper Secret+Shopper ID right into a JWT token…. we will discover the knowledge we want right here…

  1. Authentication
  2. OpenAPI Spec

Observe: Previous to doing a number of the API greatness you have to to undergo the On-boarding Course of and Software Registration so you will get your Shopper ID and Shopper Secret to authenticate with the API. Registration will make use of the CX Cloud API Gateway! Extra thrilling know-how so that you can use. If in case you have any points getting on boarded or within the software registration course of please attain out to your BCS Account Venture Supervisor and/or related Consulting Engineers in your undertaking.

So let’s check out the Authentication half first and a few pattern Python code. We’re going to semi-map this code to SXO actions in a workflow. The python code doesn’t belong to me and I’m not the writer, so I’m linking it right here on your reference.

The steps we want for Authentication (assuming you have got your consumer id and consumer secret) are…

  1. Make API name to the token endpoint
  2. Extract and maintain token from API return

In python to name the API we would do one thing like this (in python):

url = f'https://{server}/torii-auth/v1/token'

    knowledge = {
        "grantType": "client_credentials",
        "clientId": client_id,
        "secret": client_secret,
        "scope": "api.bcs.handle"
    }

    strive:
        resp = httpx.Shopper().put up(url=url, json=knowledge)
        resp.raise_for_status()
    besides (httpx.HTTPStatusError, httpx.RequestError) as err:
        logger.error(
            f'Didn't JSON Internet Token(JWT): {err}'
        )
        elevate err
    else:
        return resp.json().get('accessToken')

To map this to SXO we have to…







Step Python SXO
1 url = f’https://{server}/torii-auth/v1/token’ Create a Goal configuration
2 resp = httpx.Shopper().put up(url=url, json=knowledge) Add a HTTP Request Exercise to a workflow
3 return resp.json().get(‘accessToken’) Use a JSON Path Question Exercise in workflow


So let’s stroll by means of constructing these items…

How To Construct a JWT Token Atomic

  1. Go to SXO and choose Targets on the left menu
  2. Click on NEW TARGET and choose HTTP Endpoint. Name it BCS Operational Insights Auth API
  3. Set NO ACCOUNT KEYS to true. Set PROTOCOL to HTTPS, HOST/IP to api-cx.cisco.com and PATH to /torii-auth/v1/. You may see all of those values within the Python script as properly. Click on SUBMIT.
  4. Click on the Workflows on the left menu after which click on NEW WORKFLOW
  5. On the far proper underneath VARIABLES, click on ADD VARIABLE and add a STRING referred to as I_client_id, make it required and make its SCOPE to be enter. Add a SECURE STRING referred to as I_client_secret, make it required and make its SCOPE to be enter.
  6. Then add one other variable SECURE STRING. Name it O_jwt_token and make its SCOPE to be output.
  7. Within the TARGET part, choose EXECUTE ON THIS TARGET and choose the goal sort of HTTP ENDPOINT after which choose the goal you created above.
  8. That is half the place we deal with step 2 and three above from the python to SXO conversion desk. On the toolbar seek for HTTP Request, then drag and drop one onto your workflow canvas.
  9. Click on on the exercise you simply dragged and dropped and it is possible for you to to configure it on the fitting facet of your window.
  10. On the exercise set the RELATIVE URL to token , the METHOD to put up, and the REQUEST BODY ought to mirror what’s within the instance. It ought to like this…
    {"grantType": "client_credentials", "clientId": "", "secret": "", "scope": "api.bcs.handle" }
  11. As you see I left the clientId and secret clean. It is because we wish to go variables into these fields, so you may copy the above into the REQUEST BODY area and hit the format button to make it look good!
  12. To go within the variables we have to click on the puzzle piece icon in that area. That is the insert variable reference icon. When you click on that, navigate to Workflow->input->I_client_id for the consumer id area and Workflow->input->I_client_secret for the key. Set the content material sort to JSON.
  13. Subsequent we wish to parse the token out and put it aside to a safe string. Seek for the JSONPath Question exercise and drag and drop it beneath your HTTP Request exercise.
  14. Click on on the JSONPath exercise. Within the SOURCE JSON TO QUERY, click on the puzzle piece icon and choose Actions->Your HTTP Request ->Physique and save. Click on +ADD beneath that area after which within the JSONPATH QUERY area enter $..accessToken after which simply accessToken for the PROPERTY NAME. Set it to sort SECURE STRING.
  15. Lastly, search for the SET VARIABLE exercise and drag and drop it beneath the JSONPath question. Click on +ADD and within the VARIABLE TO UPDATE, click on the puzzle piece icon and choose Workflow->output->O_jwt_token. Within the NEW VALUE area, click on the puzzle piece icon and choose Activities->JSONPATH Question Exercise->accessToken.
  16. Your workflow is full! It is best to be capable of validate it and click on run. Enter your consumer id and secret and it’ll generate a token for you!

Now I’d be a poor teacher if I didn’t embrace a last consequence so that you can view alongside what we simply stepped by means of… so I’ve loads of that upcoming for you. As they are saying in cooking exhibits, “at all times have a pre-baked turkey to go together with the one you’re baking.” To assist everybody out I’ve constructed a whole atomic adapter so that you can use for BCS Operational Insights! (not only a JWT generator). Identical to you importing a bundle or copying and pasting pattern code you’ll have all of my workflows so that you can use and construct cool BCS automations. (or MAGIC!) Yow will discover them on the Shared CX SXO Repo and in time they are going to be revealed to the official SXO atomics git. To make this *even* higher you’ll discover some pattern utilization workflows on the Shared CX SXO Repo that can assist you get began. These embrace the demo I’ll present within the weblog video (you didn’t assume you wouldn’t get a video proper???) and an instance workflow that will refresh your JWT token within the background as an alternative of you having to re-call it every time you wish to use the API. These are nonetheless an opensource fashion nature workflows and atomics so if in case you have points, please let me know!

 

So I do know I simply spoiled the enjoyable… however as at all times…

On to the Video!!!

Pondering Automation Demo of BCS Operational Insights API

Password: There isn’t a password!

Normal Finish-O-Weblog Disclaimer:

Thanks as at all times to all my great readers and people who proceed to stay with and use SXO! I’ve at all times wished to search out good questions, eventualities, tales, and so on… if in case you have a query, please ask, if you wish to see extra, please ask… if in case you have matter concepts that you really want me to weblog on, Please ask! I’m comfortable to cater to the readers and make this one of the best weblog you’ll discover 🙂

AUTOMATION BLOG DISCLAIMER: As at all times, this can be a weblog and my (Shaun Roberts) ideas on SXO, orchestration, improvement, devops, and automation, my ideas on finest practices, and my experiences with the merchandise and prospects. The above views are by no means consultant of Cisco or any of it’s companions, and so on. None of those views, and so on are supported and this isn’t a spot to search out customary product assist. For those who want customary product assist please achieve this through the present name in numbers on Cisco.com or e-mail tac@cisco.com

Thanks and Glad Automating!!!

— Shaun Roberts,  shaurobe@cisco.com 

 

We’d love to listen to what you assume. Ask a query or go away a remark beneath.
And keep linked with Cisco DevNet on social!

LinkedIn | Twitter @CiscoDevNet | Fb | Developer Video Channel

 

Share:



Positive Recharge
Positive Rechargehttp://allthingsrelief.com
Hi, and welcome to allthingsrelief.com. Your all inclusive blog where we post about all things health, sports health, healthcare, weight loss, gym, nutrition, hiking, and so much more. Enjoy and make sure to leave a comment if you like the content. Have a beautiful day!
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments