phpipam

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package phpipam contains any top-level configuration structures necessary to work with the rest of the SDK and API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolIntString

type BoolIntString bool

BoolIntString is a type for representing a boolean in an IntString form, such as "0" for false and "1" for true.

This is technically a binary string as per the PHPIPAM spec, however in test JSON and the spec itself, boolean values seem to be represented by the actual string values as shown above.

func (BoolIntString) MarshalJSON

func (bis BoolIntString) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for the BoolIntString type.

func (*BoolIntString) UnmarshalJSON

func (bis *BoolIntString) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler for the BoolIntString type.

type Config

type Config struct {
	// The application ID required for API requests. This needs to be created in
	// the PHPIPAM console.
	AppID string

	// The API endpoint.
	Endpoint string

	// The password for the PHPIPAM account.
	Password string

	// The user name for the PHPIPAM account.
	Username string

	// Allow HTTPS connection without verification issuer
	Insecure bool
}

Config contains the configuration for connecting to the PHPIPAM API.

Supplying Configuration to Controllers

All controller constructors (ie: VLANs, subnets, addresses, etc) take zero or more of these structs as configuration, like so:

cfg := phpipam.Config{
  Username:     "jdoe",
  Password:     "password",
  AppID:        "appid",
}
sess := session.New(cfg)
ctlr := ipaddr.New(sess)

Note that default options are set for EmailAddress, Password, and AppKey. See the DefaultConfigProvider method for more details.

func DefaultConfigProvider

func DefaultConfigProvider() Config

DefaultConfigProvider supplies a default configuration:

  • AppID defaults to PHPIPAM_APP_ID, if set, otherwise empty
  • Endpoint defaults to PHPIPAM_ENDPOINT_ADDR, otherwise http://localhost/api
  • Password defaults to PHPIPAM_PASSWORD, if set, otherwise empty
  • Username defaults to PHPIPAM_USER_NAME, if set, otherwise empty

This essentially loads an initial config state for any given API service.

type CustomField

type CustomField struct {
	// The name of the custom field.
	Name string `json:"name"`

	// The type of custom field. This directly translates to its MySQL data type
	// in the applicable resource table.
	Type string `json:"type"`

	// The the description of the custom field. This shows up as a tooltip in the
	// UI when working with the custom field.
	Comment string `json:"Comment,omitempty"`

	// If this is true, this field is required. This translates to the NOT NULL
	// attribute on the respective field's column. Should be one of YES or NO.
	Null string `json:"Null,omitempty"`

	// The default entry for this custom field. Note that this is always
	// stringified and will need to be parsed appropriately when you reading the
	// actual custom field.
	Default string `json:"Default,omitempty"`
}

CustomField represents a PHPIPAM custom field schema entry.

Custom fields are currently embedded in a resource's table (such as subnets or IP addresses) directly. Hence, in order to know what custom fields are currently present for a specific resource, the /custom_fields/ method of a controller needs to be queried first before attempting to fetch these custom fields individually.

type JSONIntString

type JSONIntString int

JSONIntString is a type for representing an IntString JSON value, but with "" also representing a zero value.

func (JSONIntString) MarshalJSON

func (jis JSONIntString) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for the JSONIntString type.

func (*JSONIntString) UnmarshalJSON

func (jis *JSONIntString) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler for the JSONIntString type.

Directories

Path Synopsis
Package client contains generic client structs and methods that are designed to be used by specific PHPIPAM services and resources.
Package client contains generic client structs and methods that are designed to be used by specific PHPIPAM services and resources.
Package request provides the HTTP request functionality for the PHPIPAM API.
Package request provides the HTTP request functionality for the PHPIPAM API.
Package session provides session management utility and token storage.
Package session provides session management utility and token storage.

Jump to

Keyboard shortcuts

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