innGateApi

package
v0.0.0-...-d66b983 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2012 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package innGateApi implements the ANTLabs InnGate API, a structured method of communication with an ANTLabs InnGate. http://www.antlabs.com/

Example:

import("antlabs/innGate")
func main(){
  innGate := innGateApi.Host{Host : "ant.example.com"}
  resp, _ := innGate.ApiVersion()
  fmt.Println("\n\nAPI_Version:", resp.ApiVersion)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Type                             string
	Creator                          string
	UserId                           string
	Code                             string
	Description                      string
	Enable                           bool
	ValidFrom                        time.Time
	ValidUntil                       time.Time
	LoginLimit                       bool
	LoginMax, LoginCount, SharingMax int64
	UserGroupName                    string
	CreateTime                       string
	UpdateTime                       string
	Accounting                       string
	BillingId                        string
}

type AccountAddRequest

type AccountAddRequest struct {

	//Required:
	Creator string

	PlanId string
	//or:
	PlanName string

	//All the following are optional:
	Type string

	UserId string
	//or:
	UserIdFormat string //if !UserId ('alpha|alnum|num' default:alpha)
	UserIdLength int64  //if !UserId (default:5 minimum:3)
	UserIdPrefix string //if !UserId (default:” max_length:20)
	UserIdSuffix string //if !UserId (default:” max_length:20)

	UserIdStart string //a number (expressed as a string) or "auto"

	Password string
	//or
	PasswordLength int64  //if !Password (default:5 minumum:3)
	PasswordFormat string //if !Password ('alpha|alnum|num' default:alnum)

	Code string //between 3 and 10 characters /[a-z0-9]/
	//or:
	CodeFormat string //if !Code ('alpha|'alnum'|'num' defaule:alnum)
	CodeLength int64  //if !Code (default:5 minimum:3)
	CodePrefix string //if !Code (default:” min_length:4)
	CodeSuffix string //if !Code (default:” min_length:4)
	CodeStart  string //if !Code a number (expressed as a string) or 'auto'

	Count            int64     //(default:1 max:100)
	Description      string    //(max_length:255)
	ValidFrom        time.Time //time.Time.Unix() will suffice for 'now'  ?(is that ow you get 'now')
	ValidUntil       time.Time //or nil (or not set)
	LoginMax         string    //(default:'unlimited' otherwise an int expressed as string)
	SharingMax       int64     //default:1
	BillingId        string    //max_length:100; default:”
	AllowedLoginZone int64     //default:0
	// contains filtered or unexported fields
}

type AccountDeleteRequest

type AccountDeleteRequest struct {
	UserId, Code interface{}
	// contains filtered or unexported fields
}

type AccountGetAllRequest

type AccountGetAllRequest struct {
	ValidFromStart, ValidFromEnd, ValidUntilStart, ValidUntilEnd time.Time
	Creator, Description, Type                                   string
	CreatedStart, CreatedEnd, PlanName                           string
	// contains filtered or unexported fields
}

type AccountGetRequest

type AccountGetRequest struct {
	UserId, Code, ClientMac string
	// contains filtered or unexported fields
}

type AccountUpdateRequest

type AccountUpdateRequest struct {

	//Required:
	UserId string
	//or:
	Code string
	//Optional:
	Password         string
	PasswordLength   int64
	PasswordFormat   string //alpha|alnum|num (default alnum)
	Description      string
	ValidUntil       time.Time
	ValidFrom        time.Time
	LoginLimit       bool
	LoginMax         int64
	SharingMax       int64
	AllowedLoginZone int64
	//If account has never logged in (optional):
	PlanId int64
	//or:
	PlanName string
	// contains filtered or unexported fields
}

type AuthAuthenticateRequest

type AuthAuthenticateRequest struct {
	Code             string
	UserId, Password string
	Mode             string
	// contains filtered or unexported fields
}

type AuthInitRequest

type AuthInitRequest struct {

	//Required:
	ClientMac     string
	ClientIp      string
	LocationIndex string
	Ppli          string
	//Optional:
	NewSid int64
	Extra  string //up to you to make it a proper query string!  Start with an &!
	// contains filtered or unexported fields
}

type AuthLoginRequest

type AuthLoginRequest struct {

	//Required:
	Sid string
	//or:
	ClientMac, ClientIp, Ppli string
	LocationIndex             int64
	//Optional:
	Mode             string
	Code             string
	UserId, Password string
	Secret           string
	// contains filtered or unexported fields
}

type AuthLogoutRequest

type AuthLogoutRequest struct {

	//Required:
	Sid string
	//or:
	ClientMac string
	// contains filtered or unexported fields
}

type AuthUpdateRequest

type AuthUpdateRequest struct {

	//Required:
	ClientMac string
	//Optional:
	Duration string //minutes.(int) expressed as string
	Volume   string //bytes.(int) expressed as string
	// contains filtered or unexported fields
}

type Host

type Host struct {
	Host, Pass string
	Port       int
}

func (*Host) AccountAdd

func (api *Host) AccountAdd(request AccountAddRequest) (result *accountAddResponse, err error)
AccountAdd performs the an API request for op=account_add

This method requires one argument of type innGateApi.AccountAddRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AccountAdd(innGateApi.AccountAddRequest{})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nLogin result:", resp.Result)

func (*Host) AccountDelete

func (api *Host) AccountDelete(request AccountDeleteRequest) (result *accountDeleteResponse, err error)
AccountDelete performs the an API request for op=account_delete

This method requires one argument of type innGateApi.AccountDeleteRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AccountDelete(innGateApi.AccountDeleteRequest{Code : "abc123"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nDeleted:", resp.Deleted)

 resp2, err := ant.AccountDelete(innGateApi.AccountDeleteRequest{Code : []string{"abc123", "xyz456"}})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nDeleted:", resp2.Deleted)

NOTICE:

Database errors can be common.  If the API cannot find any of the accounts requested for deletion in
the database, it will return an error with resultcode 98 (database error).  If it finds at least one
match, the request should reply with success.  Furthermore, the ANTLabs database/API seems bugarrific;
frequently an account can be seen through the admin portal, but not found when making an API request.
If a database error occurs with the API, that result will be passed along.

func (*Host) AccountGet

func (api *Host) AccountGet(request AccountGetRequest) (result *accountGetResponse, err error)
AccountGet performs an API request for op=account_get

This method requires one argument of type innGateApi.AccountGetRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AccountGet(innGateApi.AccountGetRequest{Code : "abc123"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nAccount:", resp)

func (*Host) AccountGetAll

func (api *Host) AccountGetAll(arg interface{}) (result *accountGetAllResponse, err error)
AccountGetAll performs an API request for op=account_get_all

This method requires one argument of type innGateApi.AccountGetAllRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

  ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
  }
  resp, err := ant.AccountGetAll(nil)
  if(err != nil){ panic(err) }
  fmt.Println("\n\nAccounts (", resp.Count, "):\n", resp.Header)
  fmt.Println(resp.Accounts)

  resp2, err := ant.AccountGetAll(innGateApi.AccountGetAllRequest{Creator : "admin"})
  if(err != nil){ panic(err) }
  fmt.Println("\n\n", resp2.Count, "accounts created by admin.")
  fmt.Println(resp2.Accounts)

NOTICE:

If you submit something that returns an empty result (like specifying a "creator"
that didn't create any accounts), the API might return an error 90.  This is a
bug in the API that has not been worked-around in this package.

func (*Host) AccountUpdate

func (api *Host) AccountUpdate(request AccountUpdateRequest) (result *accountUpdateResponse, err error)
AuthLogin performs the an API request for op=auth_login

This method requires one argument of type innGateApi.AuthLoginRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AuthLogin(innGateApi.AuthLoginRequest{Sid : "86cb1a5deb036467a9c2bc36e13971ef"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nLogin result:", resp.Result)

func (*Host) ApiVersion

func (api *Host) ApiVersion() (result *versionResponse, err error)
ApiVersion performs the an API request for op=api_version

No optional or required arguments.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.ApiVersion()
 if(err != nil){ panic(err) }
 fmt.Println("\n\nAPI_Version:", resp.ApiVersion)

 we understand it might be misleading to call this method "ApiVersion"
 instead of just "Version."  But this comes from the op, and we chose
 to keep it in long form so the result.ApiVersion is distinct from
 the common version (of the op, not the API).

func (*Host) AuthAuthenticate

func (api *Host) AuthAuthenticate(request AuthAuthenticateRequest) (result *authAuthenticateResponse, err error)
AuthAuthenticate performs an API request for op=auth_authenticate

This method requires one argument of type innGateApi.AuthAuthenticateRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AuthAuthenticate(innGateApi.AuthAuthenticateRequest{Code: "abc123"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nResult of authentication request:", resp.Result)

func (*Host) AuthInit

func (api *Host) AuthInit(request AuthInitRequest) (result *authInitResponse, err error)
AuthInit performs the an API request for op=auth_init

This method requires one argument of type innGateApi.AuthInitRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AuthInit(innGateApi.AuthInitRequest{
    ClientMac     : "00:00:00:00:00:00",  //TODO: unknown formatting
    ClientIP      : "10.1.1.42",          //TODO: confirm formatting
    LocationIndex : 0,
    Ppli          : ""                    //TODO: I forget what this is.
 })
 if(err != nil){ panic(err) }
 fmt.Println("\n\nInit result:", resp.Result)

func (*Host) AuthLogin

func (api *Host) AuthLogin(request AuthLoginRequest) (result *authLoginResponse, err error)
AuthLogin performs the an API request for op=auth_login

This method requires one argument of type innGateApi.AuthLoginRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AuthLogin(innGateApi.AuthLoginRequest{Sid : "86cb1a5deb036467a9c2bc36e13971ef"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nLogin result:", resp.Result)

func (*Host) AuthLogout

func (api *Host) AuthLogout(request AuthLogoutRequest) (result *authLogoutResponse, err error)
AuthLogout performs the an API request for op=auth_logout

This method requires one argument of type innGateApi.AuthLoginRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AuthLogout(innGateApi.AuthLogoutRequest{Sid : "86cb1a5deb036467a9c2bc36e13971ef"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nLogout result:", resp.Result)

func (*Host) AuthUpdate

func (api *Host) AuthUpdate(request AuthUpdateRequest) (result *authUpdateResponse, err error)
AuthUpdate performs the an API request for op=auth_update

This method requires one argument of type innGateApi.AuthUpdateRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.AuthUpdate(innGateApi.AuthUpdateRequest{ClientMac : "00:00:00:00:00:00"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nUpdate result:", resp.Result)

func (*Host) Module

func (api *Host) Module(request ModuleRequest) (result *moduleResponse, err error)
Module performs an API request for op=api_module

This method requires one argument of type innGateApi.ModuleRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.Module(innGateApi.ModuleRequest{Module : "api_modules"})
 if(err != nil){ panic(err) }
 fmt.Println("\n\nAPI Module:", resp.Version)

func (*Host) Modules

func (api *Host) Modules() (result *modulesResponse, err error)
Modules performs an API request for op=api_modules

This module does not require or accept any arguments.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.Modules()
 if(err != nil){ panic(err) }
 fmt.Println("\n\nAPI_Version:", resp.ApiModules)

func (*Host) PlanAll

func (api *Host) PlanAll() (result *planAllResponse, err error)
PlanAll performs the an API request for op=plan_get_all

This method neither requires nor accepts any arguments.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.PlanAll()
 if(err != nil){ panic(err) }
 fmt.Println("Result:", resp.Result)

func (*Host) PlanId

func (api *Host) PlanId(request PlanIdRequest) (result *planIdResponse, err error)
PlanId performs the an API request for op=plan_get_id

This method requires one argument of type innGateApi.PlanIdRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.PlanId(innGateApi.PlanIdRequest{Name : "Guest"})
 if(err != nil){ panic(err) }
 fmt.Println("Id:", resp.Id)

func (*Host) PublicIp

func (api *Host) PublicIp(request PublicIpRequest) (result *publicIpResponse, err error)
PublicIp performs the an API request for op=publicip_get

This method requires one argument of type innGateApi.PublicIpRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.PublicIp(innGateApi.PublicIpRequest{Sid : "86cb1a5deb036467a9c2bc36e13971ef"})
 if(err != nil){ panic(err) }
 fmt.Println("IP:", resp.Ip)

func (*Host) SidGet

func (api *Host) SidGet(request SidGetRequest) (result *sidGetResponse, err error)
SidGet performs the an API request for op=sid_get

This method requires one argument of type innGateApi.SidGetRequest.
See the ANTLabs API for more information regarding elements of the argument.
The example below demonstrates how to send a request.

Example:

 ant := innGateApi.Host{
	   Host : "ant.example.com", //can be an IP or hostname
 }
 resp, err := ant.SidGet(innGateApi.SidGetRequest{sid : "86cb1a5deb036467a9c2bc36e13971ef"})
 if(err != nil){ panic(err) }
 fmt.Println("Client MAC:", resp.ClientMac)

type ModuleRequest

type ModuleRequest struct {
	Module string
	// contains filtered or unexported fields
}

type Plan

type Plan struct {
	Id                  int64
	Price               string
	AuthenticationType  string
	DurationLimit       bool
	ValidDuration       int64 //in minutes
	VolumeLimit         bool
	ValidVolume         int64 //in MB
	VolumeExpiredAction string
	DownloadLimit       bool
	DownloadBandwidth   int64
	DownloadUnits       string
	UploadLimit         bool
	UploadBandwidth     int64
	UploadUnit          string
	PublicIp            string
	Relogin             bool
	FairUse             bool
	Name                string
}

type PlanIdRequest

type PlanIdRequest struct {
	Name string
	// contains filtered or unexported fields
}

type PublicIpRequest

type PublicIpRequest struct {
	Sid             string
	ClientMac, Ppli string
	// contains filtered or unexported fields
}

type SidGetRequest

type SidGetRequest struct {

	//Required:
	Sid string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL