backup

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 9 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Str string
}

Body wraps SJSON for building JSON body strings. Example:

Body{}.Set("fvTenant.attributes.name", "mytenant").Str

Creates:

{
  "fvTenant":
    "attributes": {
      "name": "mytenant"
    }
}

These can also be chained:

Body{}.
  Set("fvTenant.attributes.name", "mytenant").
  Set("fvTenant.attributes.descr", "This is my tenant").
  Str

Creates:

{
  "fvTenant":
    "attributes": {
      "name": "mytenant",
      "descr": "This is my tenant"
    }
}

func (Body) Res added in v0.3.3

func (body Body) Res() Res

Res generates a backup.Res (gjson.Result) object. Use the .Str struct property to access the string data, or .Res() to generate a GJSON result.

func (Body) Set

func (body Body) Set(path, value string) Body

Set sets a JSON path to a value. These can be a single key or nested path.

func (Body) SetRaw

func (body Body) SetRaw(path, rawValue string) Body

SetRaw sets a JSON path to a raw string value. Use this for nesting JSON, e.g.: Body{}.SetRaw("fvTenant.attributes", Body{}.Set("name", "mytenant").Str).Str

type Client

type Client struct {
	// DNs is the DN to object mapping index.
	DNs map[string]*Res
	// Classes is the class to object(s) mapping index.
	Classes map[string][]*Res
}

Client is a ACI backup file client. Inititate with backup.NewClient

func NewClient

func NewClient(src string) (Client, error)

NewClient creates a new backup file client.

func (Client) GetClass

func (client Client) GetClass(class string, mods ...func(*Req)) (Res, error)

GetClass queries the backup file for an MO class. This returns a list of objects, i.e. the contents of imdata:

[
  { "moClass":
    "attributes": {
      ...
    }
  }
]

func (Client) GetDn

func (client Client) GetDn(dn string, mods ...func(*Req)) (Res, error)

GetDn queries the backup for a specific DN. This returns a single object of the format:

{ "moClass":
    "attributes": {
      ...
    }
}

For unknown class types, retrieve the attributes with a wildcard:

res.Get("*.attributes")

type Req

type Req struct{}

Req is a backup.Req request object.

type Res

type Res = gjson.Result

Res is an API response returned by client requests. This is a gjson.Result. https://github.com/tidwall/gjson

Jump to

Keyboard shortcuts

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