StyleBook configuration

Use APIs to import custom StyleBooks

Use the StyleBook API to import custom StyleBooks into NetScaler Console. Use REST APIs to create a configuration pack from this StyleBook 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: https://<ADM-endpoint-name>/stylebook/nitro/v2/config/stylebooks/actions/import?mode=async

{
    "import": {
        "file_name": "add_dnssoarec.yaml",
        "source": "<base 64 encoded content of the sb definition>",
        "encoding": "base64"
    }
}
<!--NeedCopy-->

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, use 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.

Using this API call, you can also upload a compressed tarball file (.tgz file) having multiple StyleBook files in one API operation. Do the following:

  • Change the file_name attribute to the .tgz file
  • Change 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 a response with a job ID. Use this job ID to track the operation to completion:

200 ACCEPTED
<!--NeedCopy-->

Response Body:

{
    "job": {
        "job_id": "12345678"
    }
}
<!--NeedCopy-->

Use the Job ID to track the status of the operation:

HTTP Method: GET

URL: https://<ADM-endpoint-name>/stylebook/nitro/v2/config/jobs/<job-id>

The status of the job is returned:

200 OK
<!--NeedCopy-->

Response Body:

{
    "job": {
        "job_id": "<job-id>",
        "progress_info": [
            {
                "is_last": "true",
                "message": "No job found",
                "status": "failed"
            }
        ],
        "status": "completed"
    }
}
<!--NeedCopy-->

The status value of “completed” indicates that the StyleBook has been successfully imported. Confirm the status of the operations by getting information on the StyleBook:

HTTP Method: GET

URL: https://<ADM-endpoint-name>/stylebook/nitro/v2/config/stylebooks/samples/1.0/demo-helper-object

The details of the imported StyleBook are displayed:

200 OK
<!--NeedCopy-->

Response Body:

{
    "stylebook": {
        "builtin_namespaces": {},
        "created_datetime": "2023-01-14 00:13:59",
        "custom": true,
        "dependencies": [],
        "deprecate": "false",
        "description": "This Stylebook is a test",
        "display_name": "Test StyleBooks",
        "encoding": "BASE64",
        "header": "Test StyleBooks",
        "icon": "''",
        "id": "demo575731aacbfc20b4ff00b3b60ea59855",
        "is_updatable": true,
        "name": "demo-helper-object",
        "namespace": "samples",
        "primary_keys": {},
        "private": false,
        "repository_name": "",
        "reverse_dependencies": [],
        "schema_version": "1.0",
        "source": "<base 64 encoded content of the stylebook definition>",
        "tenant_id": "1a45fd70-7ce3-4bff-8642-1bd7f7e97673",
        "username": "abc",
        "version": "1.0"
    }
}
<!--NeedCopy-->
Use APIs to import custom StyleBooks

In this article