The REST API uses the Swagger-UI for documentation.


Information about Swagger can be found here: https://swagger.io/


Swagger is a powerful tool for visualizing and testing REST APIs and requires manual steps to get everything working.


  1. Download the Swagger UI client zip from here: https://github.com/swagger-api/swagger-ui/archive/v2.0.24.zip
  2. Unzip to a local folder. The Swagger-UI needs to authenticate to the switch using Basic Authentication.
  3. To enable Basic Authentication for Swagger-UI, edit the file: swagger-ui-2.0.24/dist/index.html




  1. Insert the line highlighted in red in the code snippet below:


<script type="text/javascript">

$(function () { window.authorizations.add("authorization", new ApiKeyAuthorization("authorization", "Basic bmV0d29yay1hZG1pbjpwbHVyaWJ1c19wYXNzd29yZA==", "header"))

window.swaggerUi = new SwaggerUi({

url: "http://petstore.swagger.wordnik.com/api/api-docs", dom_id: "swagger-ui-container",

supportedSubmitMethods: ['get', 'post', 'put', 'delete'], onComplete: function(swaggerApi, swaggerUi){

log("Loaded SwaggerUI");



Note: The text in red must be inserted into the code as a single line with no breaks.










Examples


  • This is the base 64 coded credential for network-admin:pluribus_password - bmV0d29yay1hZG1pbjpwbHVyaWJ1c19wYXNzd29yZA==
  • This is the base 64 coded credential for network-admin:p1zz@2015 - bmV0d29yay1hZG1pbjpwMXp6QDIwMTU=


To use another credential, use a base-64 encoding application such as https://www.base64encode.org/ to encode your username:password and substitute it in the above line.


  1. To access the Swagger REST API documentation:
    1. Load the file, swagger-ui-2.0.24/dist/index.html, into your browser.
    2. Paste the URL http://<your-switch-mgmt-ip>/vRest/api-docs into the Swagger URL field. To use secure HTTPS access refer to the REST API Switch Configurations Settings section for more information.
    3. Click Explore.



You can now browse the various APIs such as vnets.



Note: Though the Swagger UI displays the list of API commands, it may take several minutes before you can perform REST API operations.






Test them using the Swagger “Try it out!” feature.




Authentication


The REST API uses Basic Authentication. The username and password sent in Basic Authentication should allow you to log into the CLI. 


The out-of-box username and password for the switch is network-admin/admin


The following is the corresponding code snippet for Swagger-ui using: network-admin:pluribus_admin (example) credentials:


window.authorizations.add("authorization", new ApiKeyAuthorization("authorization", "Basic bmV0d29yay1hZG1pbjpwbHVyaWJ1c19hZG1pbg==", "header"))



north
    keyboard_arrow_up
    keyboard_arrow_down
    description
    print
    feedback
    support
    business
    rss_feed
    south