样书配置

使用 API 更新现有配置包

您可以使用样书 API 来更新 NetScaler 控制台中的现有配置包。

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

有效载荷:

{
    "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-->

返回 HTTP 状态 202 和带有任务 ID 的响应正文。您可以使用任务 ID 来跟踪更新操作的状态:

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

您可以使用任务轮询 API 跟踪这个任务 ID(在本例中为 1092579455):

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

如果响应包含设置为“已完成”的状态,则更新操作成功完成。此字段中的任何其他值都表示更新任务失败。失败的原因可在 progress_info 对象中找到。

{
    "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-->

使用 API 更新目标实例

在更新配置包有效负载中,将 targets 部分更改为添加、删除或替换 NetScaler 实例。

示例

在以下示例中,更改了有效负载中的 targets 对象,为配置添加了新的目标 NetScaler:

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

如果更新成功,则配置将部署在新的 NetScaler 实例上。如果您想在 NetScalers 之间移动应用程序配置,则更改配置的目标很有用。例如,当需要从配置中删除 NetScaler 进行维护时,修改 targets 对象。

注意

要从其所有当前目标实例中删除配置,请使用空 targets 对象。保留了 NetScaler 控制台配置,但已将其从先前部署的所有 NetScaler 中删除。如果需要,您可以再次更新配置以指定一个或多个目标。

以下 API 示例从其所有现有目标中删除了配置:

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

有效载荷:

{
    "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-->
使用 API 更新现有配置包