Product Documentation

Use API to import custom StyleBooks

May 24, 2018

You can now use the StyleBook APIs to import custom StyleBooks into NetScaler MAS. Use REST API to create a configpack from this StyleBook as follows in any tool such as the curl command line tool or the Postman chrome browser extension. For example, you can import a StyleBook named example-lb that can be used to create a load balancer configuration on a NetScaler instance.

HTTP Method: POST 

URL: http://<mas-ip>/stylebook/nitro/v1/config/stylebooks

Headers:

Content-Type: application/json

Accept: application/json

Request Body:

   {

      "stylebook":{

         "file_name": "example-lb.yaml",

         "source":"<base64-contents>",

         "encoding":"base64"

      }

   }

where, the "source" attribute’s value, is the base64 encoding of the contents of your StyleBook file. You can paste the YAML contents of your StyleBook file in an online tool, for example, https://www.browserling.com/tools/file-to-base64 to obtain the base64 string that you can then use as a value for the “source” attribute above.

Using this API call, you can also upload a compressed tarball file (.tgz file) containing multiple StyleBook files in one API operation. To do this, simply change the file_name attribute to the .tgz filename and the value for the source attribute to the base64 encoding of the contents of your .tgz file.

After the API is run successfully in the tool you get the following response that indicates that the StyleBook has been imported into NetScaler MAS.

200 OK

Response Body:

{

  "stylebook": {

    "name": "example-lb",

    "namespace": "com.example.stylebook",

    "version": "1.0"

  }

}