namespace

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: ISC Imports: 11 Imported by: 0

Documentation

Overview

Package namespace contains common workflows between most namespaces.

There are two main structs: Standard and Importable. A modern namespace should use one of these structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnpackageXmlInto

func UnpackageXmlInto(b []byte, res interface{}) error

UnpackageXmlInto wraps XML content into a throw-away wrapper for further unmarshaling. This is basically for retrieving sub-object config from a parent's raw XML field mapping.

Types

type Common

type Common struct {
	Singular   string
	Plural     string
	Client     util.XapiClient
	Predefined bool
}

Common contains the shared methods every namespace has.

func (*Common) AllFromPanosConfig added in v0.7.0

func (n *Common) AllFromPanosConfig(pather Pather, ans interface{}) error

AllFromPanosConfig returns multiple objects' config from the configuration retrieved from PAN-OS and stored in the client's config tree.

path is the xpath function. ans is an interface to unmarshal the found config into.

func (*Common) FromPanosConfig added in v0.7.0

func (n *Common) FromPanosConfig(pather Pather, name string, ans Namer) error

FromPanosConfig returns a single object's config from the configuration retrieved from PAN-OS and stored in the client's config tree.

path is the xpath function. name is the name of the object to retrieve. ans is an interface to unmarshal the found config into.

func (*Common) Listing

func (n *Common) Listing(cmd string, pather Pather, ans Namer) ([]string, error)

Listing returns a list of names.

cmd should be util.Get or util.Show. path is the xpath. ans is an interface to unmarshal the response into.

func (*Common) Object

func (n *Common) Object(cmd string, pather Pather, name string, ans interface{}) error

Object returns a single object's config.

cmd should be util.Get or util.Show. pather creates the xpath to use. name is used for logging only, but is the name of the object to return. ans is an interface to unmarshal the response into.

func (*Common) Objects

func (n *Common) Objects(cmd string, pather Pather, ans interface{}) error

Objects returns multiple object's config.

cmd should be util.Get or util.Show. path is the xpath. ans is an interface to unmarshal the response into.

type ImportSpecifier

type ImportSpecifier interface {
	Specify(version.Number) (string, string, interface{})
}

ImportSpecifier is an object that has a Specify function given the current version number.

There are three items returned:

1) the unique name of this config element 2) the unique name to be used when importing; an empty string means "do not import" 3) a struct specific to this version PAN-OS representing the desired config

type Importable

type Importable struct {
	Common
	ImportPath string
}

Importable is a namespace struct for config that is imported into a vsys.

The current list of importable config is as follows:

  • interfaces
  • virtual routers
  • virtual wires
  • vlans

The ImportPath param should be set to any of the valid Import constants in the util package.

func (*Importable) Delete

func (n *Importable) Delete(tmpl, ts string, pather Pather, names []string, nErr error) error

Delete performs a DELETE to remove one or more objects.

As this is an importable config, first all objects are unimported, then all objects are deleted from the config.

func (*Importable) Edit

func (n *Importable) Edit(tmpl, ts, vsys string, pather Pather, spec ImportSpecifier) error

Edit performs an EDIT to configure one object.

As this is an importable config, first the object is unimported, then the object is configured, and finally the object is imported, if applicable.

func (*Importable) Set

func (n *Importable) Set(tmpl, ts, vsys string, pather Pather, specs []ImportSpecifier) error

Set performs a SET to configure one or more objects.

As this is an importable config, first all objects are unimported, then everything is configured, and finally the config is imported into the specified vsys.

type MoveLister

type MoveLister func() ([]string, error)

MoveLister returns a list of current rules.

type MovePather

type MovePather func(string) []string

MovePather returns an xpath given the name.

type Namer

type Namer interface {
	Names() []string
}

Namer returns the names of objects returned from PAN-OS.

type Pather

type Pather func([]string) ([]string, error)

Pather returns an xpath for the given list of names.

type Plugin added in v0.6.0

type Plugin struct {
	Common
}

Plugin is a namespace struct for config that exists in PAN-OS as a plugin.

func (*Plugin) Delete added in v0.6.0

func (n *Plugin) Delete(pather Pather, names []string, nErr error) error

Delete performs a DELETE to remove config.

func (*Plugin) Edit added in v0.6.0

func (n *Plugin) Edit(pather Pather, spec PluginSpecifier) error

Edit performs an EDIT to modify a single object.

func (*Plugin) Set added in v0.6.0

func (n *Plugin) Set(pather Pather, specs []PluginSpecifier) error

Set performs a SET to configure one or more objects.

type PluginSpecifier added in v0.6.0

type PluginSpecifier interface {
	Specify([]plugin.Info) (string, interface{}, error)
}

PluginSpecifier is an object that has a Specify function given a list of plugins.

There are three items returned:

1) the unique name of this config element 2) a struct specific to this version PAN-OS representing the desired config 3) an error if there is a mismatch between the plugins installed and what is supported

type Policy added in v0.6.0

type Policy struct {
	Standard
}

Policy is a namespace struct for config that is not imported into a vsys.

This struct contains additional operational state functions relevant for policy rules.

func (*Policy) AuditCommentHistory added in v0.6.0

func (n *Policy) AuditCommentHistory(pather Pather, rule, direction string, nlogs, skip int) ([]audit.Comment, error)

AuditCommentHistory retrieves a chunk of historical audit comment logs.

func (*Policy) CurrentAuditComment added in v0.6.0

func (n *Policy) CurrentAuditComment(pather Pather, rule string) (string, error)

CurrentAuditComment gets the uncommitted audit comment for the given rule.

func (*Policy) HitCount added in v0.6.0

func (n *Policy) HitCount(base, vsys string, rules []string) ([]util.HitCount, error)

HitCount gets the rule hit count for the given rules.

If the rules param is nil, then the hit count for all rules is returned.

func (*Policy) SetAuditComment added in v0.6.0

func (n *Policy) SetAuditComment(pather Pather, rule, comment string) error

SetAuditComment sets an audit comment for the given rule.

type Specifier

type Specifier interface {
	Specify(version.Number) (string, interface{})
}

Specifier is an object that has a Specify function given the current version number.

There are two items returned:

1) the unique name of this config element 2) a struct specific to this version PAN-OS representing the desired config

type Standard

type Standard struct {
	Common
}

Standard is a namespace struct for config that is not imported into a vsys.

func (*Standard) Delete

func (n *Standard) Delete(pather Pather, names []string, nErr error) error

Delete performs a DELETE to remove config.

func (*Standard) Edit

func (n *Standard) Edit(pather Pather, spec Specifier) error

Edit performs an EDIT to modify a single object.

func (*Standard) MoveGroup

func (n *Standard) MoveGroup(pather Pather, lister MoveLister, movement int, rule string, grp []string) error

MoveGroup places a logical group of objects in the desired location (rulebase objects).

The `movement` param should be one of the Move constants in the util package.

The `rule` param is the other rule the `movement` param is referencing. If this is an empty string, then the first rule in the group isn't moved anywhere, but all other rules will still be moved to be grouped with the first one.

func (*Standard) Set

func (n *Standard) Set(pather Pather, specs []Specifier) error

Set performs a SET to configure one or more objects.

Jump to

Keyboard shortcuts

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