StyleBook configuration

Use APIs to update an existing config pack

You can use the StyleBook API to update the existing config packs in NetScaler Console.

PUT: https://<ADM-endpoint-name>/stylebook/nitro/v2/config/configpacks/<configpack-ID>?mode=async

Payload:

{
    "configpack": {
        "stylebook": {
            "name": "waf-adv",
            "namespace": "com.citrix.adc.stylebooks",
            "version": "1.3"
        },
        "parameters": {
            "name": "TestApp1",
            "lbname": "my-lbv",
            "waf-settings": {
                "rule": "true",
                "type": [
                    "HTML"
                ],
                "profile-settings": {
                    "logeverypolicyhit": false,
                    "enablesignatures": {
                        "signaturename": "waf-sign1"
                    },
                    "sqlinjection-settings": {
                        "sqlinjectionaction": [
                            "log",
                            "stats"
                        ],
                        "sqlinjection-default-settings": {
                            "sqlinjectiontransformspecialchars": true,
                            "sqlinjectionchecksqlwildchars": true,
                            "sqlinjectiontype": "SQLSplCharANDKeyword",
                            "sqlinjectionparsecomments": "checkall",
                            "sqlinjectiongrammar": "OFF"
                        }
                    },
                    "bufferoverflow-settings": {
                        "bufferoverflowaction": [
                            "log"
                        ],
                        "bufferoverflowmaxurllength": "2048",
                        "bufferoverflowmaxheaderlength": "4096",
                        "bufferoverflowmaxcookielength": "4096",
                        "bufferoverflowmaxquerylength": "65535",
                        "bufferoverflowmaxtotalheaderlength": "65535"
                    }
                }
            }
        },
            "targets": [
            {
                "instance_id": "1b322685-3b23-4111-a9ce-56dd1c659e4c"
            }
            ]
    }
}
<!--NeedCopy-->

An HTTP Status 202 and a response body with a job ID is returned. You can use the job ID to track the status of the update operation:

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

You can track this Job ID (in this example, 1092579455) using the jobs polling API:

GET: https://<ADM-endpoint-name>/stylebook/nitro/v2/config/jobs/1092579455

The update operation is successfully completed if the response contains the status set to “completed”. Any other value in this field indicates the failure of the update job. The cause of the failure is available in the progress_info object.

{
    "job": {
        "job_id": "4268148987",
        "status": "completed",
        "progress_info": [
            {
                "is_last": "false",
                "message": "Validated the parameters",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Configuration audit completed",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Computed configuration objects",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Prepared objects for applying configuration on 192.168.153.165",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Retrieved existing data for updatable objects on instance 192.168.153.165",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Applied configuration on instance 192.168.153.165",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Retrieved data for configuration audit on instance 192.168.153.165",
                "status": "success"
            },
            {
                "is_last": "false",
                "message": "Logged out from instance 192.168.153.165",
                "status": "success"
            },
            {
                "is_last": "true",
                "message": "Saved configpack.",
                "status": "completed"
            }
        ],
        "result": {
            "status": "completed",
            "id": "4268148987",
            "config_key": "4268148987",
            "created_by": "nsroot",
            "created_datetime": "2023-01-20 18:57:58.985435",
            "created_datetimestamp": "2023-01-20 18:57:58",
            "last_modified_by": "nsroot",
            "last_modified_datetime": "2023-01-20 19:00:32",
            "name": "sample-dns-stylebook",
            "namespace": "com.citrix.adc.tests",
            "version": "1.0"
        }
    }
}
<!--NeedCopy-->

Use APIs to update target instances

In the update config pack payload, change the targets section to add, remove, or replace a NetScaler instance.

Example:

In the following example, the targets object in the payload is changed to add a new target NetScaler to the configuration:

{
    "targets": [
        {
            "instance_id": "<Existing-ADC-instance-ID>"
        },
        {
            "instance_id": "<New-ADC-instance-ID>"
        }
    ],
}
<!--NeedCopy-->

If the update is successful, the configuration is deployed on the new NetScaler instance. Changing the targets of a configuration is useful if you want to move application configurations between NetScalers. For example, modify the targets object when a NetScaler needs to be removed from a configuration for maintenance.

Note

To remove a configuration from all its current target instances, use an empty targets object. The NetScaler Console configuration is retained but it is removed from the all NetScalers on which it was previously deployed. You can update the configuration again to specify one or several targets, if required.

The following API example removes the configuration from all its existing targets:

PUT: https://<ADM-endpoint-name>/stylebook/nitro/v2/config/configpacks/<configpack-ID>?mode=async

Payload:

{
    "configpack": {
        "stylebook": {
            "name": "waf-adv",
            "namespace": "com.citrix.adc.stylebooks",
            "version": "1.3"
        },
        "parameters": {
            "name": "TestApp1",
            "lbname": "my-lbv",
            "waf-settings": {
                "rule": "true",
                "type": [
                    "HTML"
                ],
                "profile-settings": {
                    "logeverypolicyhit": false,
                    "enablesignatures": {
                        "signaturename": "waf-sign1"
                    },
                    "sqlinjection-settings": {
                        "sqlinjectionaction": [
                            "log",
                            "stats"
                        ],
                        "sqlinjection-default-settings": {
                            "sqlinjectiontransformspecialchars": true,
                            "sqlinjectionchecksqlwildchars": true,
                            "sqlinjectiontype": "SQLSplCharANDKeyword",
                            "sqlinjectionparsecomments": "checkall",
                            "sqlinjectiongrammar": "OFF"
                        }
                    },
                    "bufferoverflow-settings": {
                        "bufferoverflowaction": [
                            "log"
                        ],
                        "bufferoverflowmaxurllength": "2048",
                        "bufferoverflowmaxheaderlength": "4096",
                        "bufferoverflowmaxcookielength": "4096",
                        "bufferoverflowmaxquerylength": "65535",
                        "bufferoverflowmaxtotalheaderlength": "65535"
                    }
                }
            }
        },
        "targets": []
    }
}
<!--NeedCopy-->
Use APIs to update an existing config pack