https://github.com/chiradeep/go-nitro
A Golang client to the Citrix ADC API
https://github.com/chiradeep/go-nitro
citrix citrix-adc citrix-api citrix-netscaler golang netscaler nitro sdk
Last synced: 5 months ago
JSON representation
A Golang client to the Citrix ADC API
- Host: GitHub
- URL: https://github.com/chiradeep/go-nitro
- Owner: chiradeep
- License: apache-2.0
- Created: 2016-10-28T23:11:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-18T23:30:43.000Z (almost 5 years ago)
- Last Synced: 2024-06-18T18:52:36.843Z (about 2 years ago)
- Topics: citrix, citrix-adc, citrix-api, citrix-netscaler, golang, netscaler, nitro, sdk
- Language: Go
- Homepage:
- Size: 1.86 MB
- Stars: 18
- Watchers: 9
- Forks: 21
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go client for configuring Citrix ADC
## About
The [NITRO](https://developer-docs.citrix.com/projects/citrix-adc-nitro-api-reference/en/12.1/) API is the REST-like API to the Citrix ADC (aka NetScaler). This project provides a Golang SDK that can be used to make configuration API calls to a Citrix ADC.
## Deprecation Notice
The project has an official home at https://github.com/citrix/adc-nitro-go where updates will continue.
There will be no more updates to this repo.
## Versioning
The repository uses tags to identify which version of the NITRO API is used to generate the config packages.
The version scheme follows that of Citrix ADC versioning.
For example the tag v12.1.50.12 signifies that the [jsonconfig](./jsonconfig) files and the generated [config](./config) files
are taken from the same Citrix ADC version. In this instance it is Citrix ADC version 12.1 build 50.12 .
You can checkout a specific tag or download the corresponding release if you would like to use some
version of the API other than the one pointed to by the master branch.
## Usage
Import the SDK from github.com/chiradeep/go-nitro/netscaler. Config objects are available at github.com/chiradeep/go-nitro/config.
Instantiate a client using `NewNitroClient`. To initialize the client from environment variables:
```
export NS_URL=http://
export NS_LOGIN=
export NS_PASSWORD=
```
Config object types can be passed in as strings ("lbvserver"), or looked up from `netscaler..Type()`
The general pattern for NetScaler config objects is some combination of `AddResource`, `UpdateResource`, `BindResource`, `UnbindResource` and `DeleteResource`. See the [NITRO REST docs](https://docs.citrix.com/en-us/netscaler/11-1/nitro-api/nitro-rest/nitro-rest-general.html) for more information.
## Example
```
package main
import (
"github.com/chiradeep/go-nitro/config/lb"
"github.com/chiradeep/go-nitro/netscaler"
)
function main() {
client, _ := netscaler.NewNitroClientFromEnv()
lb1 := lb.Lbvserver{
Name: "sample_lb",
Ipv46: "10.71.136.50",
Lbmethod: "ROUNDROBIN",
Servicetype: "HTTP",
Port: 8000,
}
result, err := client.AddResource(netscaler.Lbvserver.Type(), "sample_lb", &lb1)
if err == nil {
client.SaveConfig()
}
}
```
## Building
The `structs` for the config objects under `config/` used to be generated from JSON declarations in `jsonconfig`. The JSON itself is generated by reverse engineering the official NITRO Java SDK (see [https://github.com/chiradeep/json-nitro](https://github.com/chiradeep/json-nitro)). From 13.0, the go structs are generated and checked in directly to the repository. From 13.0-76.31 the `stats` directory contain the structs for the stats API.
### Unit Tests
The unit tests are invoked with `make unit`. Note that they are actually functional tests and need a running NetScaler. The tests also need the environment variables `NS_URL`, `NS_LOGIN` and `NS_PASSWORD` to be set.
### Using HTTPS
If you specify `https` in the URL then the client will use HTTPS. By default it will verify the presented certificate. If you want to use the default or self-signed certificates without verification, specify `sslVerify=false` in the constructor `NewNitroClientFromParams` or set the environment variable `NS_SSLVERIFY` to `false` and use the `NewNitroClientFromEnv` constructor
## TODO
Some [REST operations](https://developer-docs.citrix.com/projects/netscaler-nitro-api/en/12.0/performing-netscaler-resource-operations/) are not yet supported:
* Pagination & filtering
* Count
* Unset
* Rename
* SSL Certificate operations:
* Link/Unlink
* Import
`