Introduction
POST /mgmt/api/nextgen/v1/applications
{
"application": {
"name": "app1",
"virtual_ip": "70.122.23.11",
"default_certificate_ref": "app1_cert",
"servers": [
"192.168.10.11",
"192.168.10.14"
]
}
}
PUT /mgmt/api/nextgen/v1/applications/app1
{
"application": {
"name": "app1",
"virtual_ip": "70.122.23.11",
"default_certificate_ref": "app1_cert",
"servers": [
"192.168.10.11",
"192.168.10.14",
"192.168.10.15",
"192.168.10.16"
]
}
}
Comparison to Nitro API
Configuration Views
switch ns configview NEXTGENAPI
ALL, which provides a read-only view of Next-Gen API configurations along with an unrestricted view of configurations created using NetScaler CLI, GUI, or Nitro API. Additionally, there is the CLASSIC config view, where you can view and modify configurations created using the NetScaler CLI, GUI, or Nitro API.
ns.conf when you run the save ns config command. Next-Gen API configuration is persistent and remains intact after a reboot.
clear ns config <level> command:
| Level | Description |
|---|---|
| basic | Configuration created through Next-Gen API is not cleared. |
| extended | Configuration created through Next-Gen API is not cleared. |
| full | Configuration created through Next-Gen API is cleared. |
clear ns nextgenapi
System Requirements
Enabling Next-Gen API on NetScaler
> enable ns nextgenapi
ERROR: Operation not permitted [To use nextgenapi you need to enable SSL defaultprofile. CLI CMD: set ssl parameter -defaultProfile ENABLED]
> show ns nextgenapi
Next-Gen API State: STARTED
>
API reference
Authentication
POST /mgmt/api/nextgen/v1/login
{
"login": {
"username": "user1",
"password": "verysecret"
}
}
200 OK
Set-Cookie: sessionid=%23%23B2A100C6D1F36AAE2......A50FA2C576171;
Path=/mgmt/api/nextgen/v1
POST /mgmt/api/nextgen/v1/login
{
"login": {
"username": "user1",
"password": "verysecret",
"timeout": "5min"
}
}
GET /mgmt/api/nextgen/v1/applications
Cookie: sessionid=%23%23B2A100C6D1F36AAE2......A50FA2C576171
POST /mgmt/api/nextgen/v1/logout
Cookie: sessionid=%23%23B2A100C6D1F36AAE2......A50FA2C576171
200 OK
Set-Cookie: sessionid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; Path=/mgmt/api/nextgen/v1
Role-Based Access
POST mgmt/api/nextgen/v1/roles/apps-admin-role
{
"role": {
"name": "apps-admin-role",
"permissions": [
{
"method": "ALL",
"resources": "/applications/.+"
}
]
}
}
POST mgmt/api/nextgen/v1/groups/apps-admin-grp/roles
{
"role": "apps-admin-role"
}
DELETE mgmt/api/nextgen/v1/groups/apps-admin-grp/roles/apps-admin-role
Configuration Paradigms
-
Application-Centric Model: The application-centric approach groups all configuration elements related to an application together, making it easy to manage complete application configurations atomically. This model is ideal for common use cases and provides a simplified, high-level abstraction.
-
Entity-Centric Model (Config Sets): For scenarios requiring full access to NetScaler's feature set or granular control over individual Nitro entities, Config Sets provide a declarative mechanism to define any NetScaler configuration. This bridges the gap between the power of Nitro and the simplicity of Next-Gen API's desired-state model.
API Calls Structure
<http_verb> /mgmt/api/nextgen/v1/<resource_type>/<resource_name>
GET /mgmt/api/nextgen/v1/applications/my_app
GET /mgmt/api/nextgen/v1/applications
<http_verb> /mgmt/api/nextgen/v1/<resource_type>/<resource_name>/<subresource_type>/<subresource_name>
GET /mgmt/api/nextgen/v1/applications/my_app/backends
GET /mgmt/api/nextgen/v1/applications/my_app/backends/metadata_servers
| Verb | description |
|---|---|
| GET | This verb is used to retrieve a specific resource by name or a list of resources for a certain type. |
| POST | This verb is used to create or update the "desired state" of a resource. If a resource is successfully created, the returned status code is 201. If an existing resource was updated, the returned status code is 200. |
| PUT | This verb is used to update the "desired state" of an existing resource. |
| DELETE | This verb is used to delete an existing resource. |
Resource Types and Resources
-
Application
-
Backend
-
Server
-
-
Frontend
-
Listener
-
-
Route
-
-
Certificate
-
Filter Value Set
-
Responder HTMLPage
-
HTTP Callouts
-
Config Sets
/mgmt/api/nextgen/v1/applications/{application_name}/backends/{backend_name}/servers
| Resource | Parent Resource | Description |
|---|---|---|
| Application | N/A | The application resource is the top resource that represents a complete configuration. |
| Frontend | Application | An application can have multiple frontends. Each frontend represents a virtual IP. For example, an application can have an internal virtual IP and an external virtual IP. Most applications have only one virtual IP, in which case the frontend is implicit. |
| Listener | Frontend | A Listener represents a port on the virtual IP. Some applications can listen on multiple ports (for example, HTTP/80 and HTTPS/443) and therefore need multiple listeners. Often, applications listen only on one port, in which case the listener is implicit. |
| Backend | Application | A Backend represent a set of servers that serve the same traffic and for which incoming client requests can be load-balanced between them. |
| Servers | Backend | The list of server IPs/Ports that make up a backend. |
| Certificate | N/A | A certificate is a top resource. A certificate represents a public/private key pair and any certificate chain (intermediate and root certificates). |
Listeners
| Attribute Name | Attribute Type | Description | Required? |
|---|---|---|---|
| name | name | The name of the listener. | Yes |
| port | port | The port number of the listener | Yes |
| protocol | protocol | Protocol for this port. If not specified, defaults to HTTP | No |
| default_certificate_ref | reference | The name of a server certificate to be used on this port. | Depends. If protocol is HTTPS, a certificate must be specified. |
| certificate_refs | List of references | The names of a server SNI certificates to be used on this port. | If protocol is HTTPS. Can be used with default_certificate_ref. |
Applications
| Attribute Name | Attribute Type | Description | Required? |
|---|---|---|---|
| virtual_ip | ipaddress | The VIP of the application | Yes |
| port | port | The port number of this VIP. Defaults to either 443 or 80 based on the protocol. | No |
| protocol | protocol | The protocol of the VIP. Defaults to HTTPS if not specified | No |
| default_certificate_ref | reference | The name of a server certificate to be used on this port. | Depends. If protocol is HTTPS, a certificate must be specified. |
| certificate_refs | List of references | The names of a server SNI certificates to be used on this port. | If protocol is HTTPS. Can be used with default_certificate_ref. |
| servers_port | port | The port number for the backend servers. Defaults to 80 | No |
| servers_protocol | protocol | The protocol of the servers. Defaults to HTTP if protocol is HTTP or HTTPS. | No |
| servers | server list | A list of backend servers that will server requests of this application | Yes |
References between resources
<resource_type>_ref for attribute names that carry a reference to an existing resource. For plural references, the naming convention is <resource_type>_refs. For example, the attribute certificate_refs of an application resource.
Desired State Semantics
POST /mgmt/api/nextgen/v1/applications/app1
{
"application": {
"name": "app1",
"virtual_ip": "70.122.23.11",
"protocol": "HTTP",
"servers": [
"192.168.10.11",
"192.168.10.14"
]
}
}
PUT /mgmt/api/nextgen/v1/applications/app1/backends/tier1/servers
{
"servers": [
"192.168.10.11",
"192.168.10.14",
"192.168.10.15",
"192.168.10.16",
"192.168.10.17"
]
}
Incremental Change Semantics
POST /mgmt/api/nextgen/v1/applications/app1/backends/tier1/servers
{
"server": "192.168.10.17"
}
POST /mgmt/api/nextgen/v1/applications
{
"application": {
"name": "app1",
"virtual_ip": "70.122.23.11",
"protocol": "HTTP",
"servers": [
"192.168.10.11",
"192.168.10.14"
]
}
}
POST /mgmt/api/nextgen/v1/applications/app1
Application actions
Disable/Enable Application
POST /mgmt/api/nextgen/v1/applications/{application-name}/actions/disable
POST /mgmt/api/nextgen/v1/applications/{application-name}/actions/enable
configured_state parameter in the application health response.
Uninstall/Install Application
POST /mgmt/api/nextgen/v1/applications/{application-name}/actions/uninstall
POST /mgmt/api/nextgen/v1/applications/{application-name}/actions/install
Error Handling
| HTTP Status Code | Description |
|---|---|
| 200 | This status code indicates that the operation is successful. This can be returned for GET, POST and PUT API calls. |
| 201 | This status code indicates that the resource creation is successful. This can be returned for POST API calls. |
| 400 | This status code indicates an error in the request. The response body will contain details about the type of the error. |
| 401 | This status code indicates a failure in authenticating the user. This could also be because of the existing user session has expired and the user needs to logon again. The response contains details about the error. |
| 403 | This status code indicates that the user does not have permission to make this API call on the resource referred to in the URL. |
| 404 | This status code indicates the referred resource in the GET, POST, PUT or DELETE URL doesn't exist. |
| 409 | This status code indicates a failure because of a conflict. For example, if a user tries to create a resource which already exists on NetScaler, this status code is used to indicate the conflict. The response body will contain details of the error. |
| 500 | This status code indicates an internal error on NetScaler. The response body contains details onto the nature of the error. User needs to troubleshoot further and return NetScaler to a working condition. |
{
"errorcode": 400,
"errormessage": "Validation Error",
"details": [
{
"instance": "{'name': 'color_app', 'virtual_ip': '10.102.201.171', 'protocol': 'HTTPS', 'service_port': 8010, 'servers': ['10.102.201.166', '10.102.201.167']}",
"message": "'certificate_ref' is a required property for 'protocol':'HTTPS'"
}
]
}
| HTTP Status Code | Internal Error Code | Internal Error Message |
|---|---|---|
| 400 | 1000 | Bad Request |
| 400 | 1001 | Invalid JSON data |
| 400 | 1002 | Resource name is different in URL and payload |
| 400 | 1003 | Missing query parameters |
| 401 | 1100 | Unauthorized Request |
| 401 | 1101 | Session expired or killed. Please login again |
| 401 | 1102 | User not authorized for this operation |
| 401 | 1103 | Authentication failed - Please provide sessionid in the cookie |
| 401 | 1104 | Invalid username or password |
| 401 | 1105 | Operation not permitted on HA secondary node |
| 404 | 1200 | Resource not found |
| 404 | 1201 | Application not found |
| 404 | 1202 | Frontend not found |
| 404 | 1203 | Listener not found |
| 404 | 1204 | Backend not found |
| 404 | 1205 | Server not found |
| 404 | 1206 | Route not found |
| 404 | 1207 | Certificate not found |
| 404 | 1208 | Role not found |
| 404 | 1209 | Roles not found |
| 404 | 1210 | No Role associations found for group |
| 404 | 1211 | Value set not found |
| 404 | 1212 | Application not installed |
| 404 | 1213 | Responder HTML page not found |
| 404 | 1214 | HTTP callout not found |
| 406 | 1300 | We only support sending responses in JSON format |
| 409 | 1400 | Resource already exists |
| 409 | 1401 | Delete of resource already in progress |
| 409 | 1402 | Delete of this resource is not possible as it is being referenced by other resources |
| 409 | 1403 | Uninstall of this resource is not possible as it is being referenced by other resources |
| 409 | 1410 | Application already exists |
| 409 | 1411 | Frontend already exists |
| 409 | 1412 | Listener already exists |
| 409 | 1413 | Backend already exists |
| 409 | 1414 | Server already exists |
| 409 | 1415 | Route already exists |
| 409 | 1416 | Certificate already exists |
| 409 | 1417 | Role already exists |
| 409 | 1418 | Group Role association already exists |
| 409 | 1419 | Value set already exists |
| 409 | 1420 | Blocking operation is in Progress, please try after sometime |
| 409 | 1421 | Responder HTML page already exists |
| 409 | 1422 | HTTP callout already exists |
| 415 | 1500 | We only support requests in JSON format |
| 422 | 2000 | Validation Failed |
| 422 | 3001 | The resource cannot be deleted because it is the last remaining resource of its kind |
| 500 | 1600 | Internal Server Error |