WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / Automation with the VMware Cloud Services Platform (CSP)

Automation with the VMware Cloud Services Platform (CSP)

07.24.2018 by William Lam // 3 Comments

I was recently doing some work where I needed to access the APIs for the VMware Cloud Services Platform (CSP). As the name suggests, CSP is where customers can manage access, billing and consumption of the various VMware SaaS offerings including VMware Cloud on AWS (VMC) and VMware Hybrid Cloud Extension to just name a couple.

CSP also provides a RESTful API (Swagger documentation here) which enables customers and partners to automate all aspects of the CSP UI. Although my use of the CSP API is quite small, I figure it  would useful to share the overall workflow in case others were interested in consuming the full CSP API.

The first thing you need is to retrieve the API Refresh Token which can be found by going to "My Account" in CSP and then navigating to the API Tokens as shown in the screenshot below. If you do not see a refresh token, simply generate one.


Once you have this refresh token, you will need to perform a POST to /am/api/auth/api-tokens/authorize to get back a CSP Access Token which will be used to authenticate yourself and be able to interact with the CSP APIs. To demonstrate this workflow, I have create two sample scripts below which takes a refresh token and returns the CSP Access Key and then perform a GET on /slc/api/definitions?expand=1 to use the key to list all CSP services (simliar to what you see when you first login to the CSP).

PowerShell

Here is an example PowerShell module VMware.CSP.psm1 which provides two functions: Get-CSPAccessToken and Get-CSPServices to interact with the CSP APIs:

Import-Module VMware.CSP.psm1
Get-CSPAccessToken -RefreshToken $RefreshToken
Get-CSPServices

Bash (cURL)

Here is a Shell script vmware-list-csp-services.sh which leverages cURL and jq to interact with CSP API:

./vmware-list-csp-services.sh $REFRESH_TOKEN

More from my site

  • Integrating VMware Cloud Notification Gateway with VMware Event Broker Appliance (VEBA)
  • Custom notification and automation based on host failure in VMware Cloud on AWS
  • ESX 3.x on VMware Cloud on AWS? 
  • Configuring Standalone vRealize Orchestrator with VMware Cloud on AWS
  • Automating HCX Multi-Site Service Mesh configuration using the new HCX PowerCLI cmdlets

Categories // Automation, PowerCLI, VMware Cloud on AWS Tags // Cloud Services Platform, CSP, VMC, VMware Cloud on AWS

Comments

  1. Kunal Singh says

    06/25/2019 at 3:31 am

    You can find the VMC SDK in the following locations for Java and Python respectively
    https://github.com/vmware/vsphere-automation-sdk-java
    https://github.com/vmware/vsphere-automation-sdk-python

    Reply
  2. airSlate says

    09/10/2020 at 2:22 am

    Excellent solution. Thank you! Now there are dozens of cool process automation tools on the market that can significantly speed up many of the processes of your work with clients. The right software can increase the effectiveness of the entire team or free up time for something new

    Reply
  3. Simple app says

    05/25/2022 at 3:31 am

    Great! thank you for this useful information.
    Good job

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • How to bootstrap ESXi compute only node and connect to vSAN HCI Mesh? 01/31/2023
  • Quick Tip - Easily move or copy VMs between two Free ESXi hosts? 01/30/2023
  • vSphere with Tanzu using Intel Arc GPU 01/26/2023
  • Quick Tip - Automating allowed and not allowed Datastores for use with vSphere Cluster Services (vCLS) 01/25/2023
  • ESXi with Intel Arc 750 / 770 GPU 01/24/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...