Skip to content
lakshmi-enjeti edited this page Jan 11, 2018 · 28 revisions

go-pulse-vtm - Go Bindings for the Pulse Secure Virtual Traffic Manager (vTM)

Overview

This is the GoLang API wrapper for Pulse Secure Virtual Traffic Manager (vTM). Starting from version 0.4 the API has been heavily redesigned. This wiki page refers to the new (and current) design of the API. For proper use of API release 0.3.x (not supported any more) please refer to this wiki page. This wiki page refers to the API version 0.4.2.

For any information related with the Pulse Secure vTM resources and attributes please refer to the official Pulse Secure Virtual Traffic Manager REST API Guide consistent with your server release.

Key features of the API

  • Resources for any CRUD operation can be defined either as structs (for a subset of all resources supported by the 3.8 version of the REST API Server) or as maps, hence basically CRUD operations on any resource is supported.
  • Any PulsevTM REST API Server version is supported. A specific version can be passed at connection time. If no version is specified, the API wrapper connects to the PulsevTM REST API Server, retrieves the list of all supported versions and use the highest available one.
  • Support for all resource types, including information and statistics resources.

Resources defined in the schema

The following is the list of the resources managed by the API as structs (but any resource can be managed as map as well). The list is a limited subset of all the resources exposed by the Pulse vTM REST API Server and, moreover, for some of them the set of defined attributes is far from being complete (though representing the minimal subset that provides most of the resource usage). The schema is bond to version 3.8 of the Pulse vTM REST API Server. The schema is not going to be upgraded to current and future releases of the Brocade vTM REST API Server schema. All schema resources can be found under the api/model/3.8 folder.

Resource Name Resource URI Create Read Update Delete
DNS Zone dns_server/zones Y Y Y Y
DNS Zone File dns_server/zone_files Y Y Y Y
GLB Service glb_services Y Y Y Y
Location locations Y Y Y Y
Monitor monitors Y Y Y Y
Pool pools Y Y Y Y
Rule rules Y Y Y Y
SSL Key Pair ssl/server_keys Y Y Y Y
Traffic IP Group traffic_ip_groups Y Y Y Y
Traffic Manager traffic_managers Y Y Y Y
User Authenticator user_authenticators Y Y Y Y
User Group user_groups Y Y Y Y
Virtual Server virtual_servers Y Y Y Y

Importing the API

    import("github.com/sky-uk/go-pulse-vtm/api")

Connecting to a PulsevTM server

The Connect API returns a client object or an error in case of issues. The APIVersion parameter can be used to specify a server API version to use; in case it is not provided, the list of available API versions is retrieved from the server and the highest available is used. Custom headers can be passed at connection time, if not passed the content type is anyhow set to "application/json"

    headers := make(map[string]string)
    // set your custom headers...
    params := Params{
	APIVersion: "3.8",
	Server:    server,
	Username:  username,
	Password:  password,
	IgnoreSSL: true,
	Debug:     true,
        Headers:   headers,
	}

    client, err := api.Connect(params)

Dealing with configuration resources

All API return an error or nil in case of success.

Setting (creating/updating) a resource

The Set API is provided to both create and update a configuration resource. The last input paramenter is a pointer to a map (or struct) where the new created/updated resource is provided back.

Synopsys

    err := client.Set(<resource type>,<resource name>, <resource profile as map/struct>, <pointer to map/struct>)

Example

    profile := make(map[string]interface{})
    updatedRes := make(map[string]interface{})
    name := "new_virtual_server_8347"
    // fill the profile...
    //...

    err = client.Set("virtual_servers", name, profile, &updatedRes)

Getting a resource

Retrieve a resource by its name

Synopsys
    err := client.GetByName(<resource type>, <resource name>, <pointer to map/struct>)

Retrieve a resource by its url

Synopsys
    err := client.GetByURL(<resource type>, <resource url>, <pointer to map/struct>)

Deleting a resource

Synopsys
    err := client.Delete(<resource type>, <resource name>)

Getting all resource types

The GetAllResourceTypes returns the list of all resource types

    types, err := client.GetAllResourceTypes()

Getting all resources of a type

The GetAllResources API returns a list of maps containing names/urls of all resources of the provided type.

    objs, err := client.GetAllResources(<resource type>)

Dealing with information resources

The GetInformation API returns the information section for the passed server name

    info, err := client.GetInformation(<server name>)

Dealing with statistics

The GetStatistics API returns all the statistics resources for a server node name

    stats, err := client.GetStatistics(<server name>)

Getting the server state

The GetState API returns the current state for the passed server node name

    state, err := client.GetState(<server name>)

Functions useful to traverse the tree of resources

As resources are hierarchically organized as a tree, the next functions are provided to help browse the tree content.

Set the configuration resources tree root as current root path

client.WorkWithConfigurationResources()

Set the status resources tree root as current root path

client.WorkWithStatus()

Traversing the resource tree from a given tree location

The TraverseTree function traverses the tree of resources starting from the given root. It returns a map with all resources found keyed by their url.

err = client.TraverseTree(<root path>, <pointer to map>)

Example

Traversing all information resources:

        // get a client...
        client, err := api.Connect(...)

	client.WorkWithStatus()
	resources := make(map[string]interface{})
	err = client.TraverseTree(client.RootPath, resources)
	if err != nil {
		t.Fatal("Error traversing tree: ", err)
	}

	for url := range resources {
		log.Println("Found Resource URL: ", url)
	}
Clone this wiki locally