object

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PolicyType = "/policy"
)

Variables

This section is empty.

Functions

func Dump

func Dump(o Object, skipKeys ...string) string

Dump returns the object as pretty-printed json

func Hash

func Hash(o Object) []byte

Hash returns the ObjectHash of the object

func ObjectHash

func ObjectHash(o Object) ([]byte, error)

ObjectHash consistently hashes a map. It is based on Ben Laurie's object hash, but using the same type hints as TJSON instead. TODO add redaction

func ObjectHashWithoutSignature added in v0.4.0

func ObjectHashWithoutSignature(o Object) ([]byte, error)

Types

type Object

type Object map[string]interface{}

Object for everything f12n

func Copy

func Copy(f Object) Object

Copy object

func FromMap

func FromMap(m map[string]interface{}) Object

FromMap returns an object from a map

func New

func New() Object

New returns an object from a map

func (Object) Compact

func (o Object) Compact() (string, error)

func (Object) CompactHash

func (o Object) CompactHash() string

CompactHash returns the object's hash in its (not really) compact format

func (Object) Copy

func (o Object) Copy() Object

Copy creates a copy of the original object

func (*Object) FromMap

func (o *Object) FromMap(m map[string]interface{}) error

FromMap inits the object from a map

func (Object) Get added in v0.4.0

func (o Object) Get(lk string) interface{}

Get -

func (Object) GetParents

func (o Object) GetParents() []string

GetParents returns the object's parent refs

func (Object) GetPolicy

func (o Object) GetPolicy() *Object

GetPolicy returns the object's policy, or nil

func (Object) GetSignature

func (o Object) GetSignature() *Object

GetSignature returns the object's signature, or nil

func (Object) GetType

func (o Object) GetType() string

GetType returns the object's type

func (Object) Hash

func (o Object) Hash() []byte

Hash returns the object's hash

func (Object) HashBase58

func (o Object) HashBase58() string

HashBase58 returns the object's hash base58 encoded

func (Object) Set added in v0.4.0

func (o Object) Set(k string, v interface{})

Set -

func (Object) SetParents

func (o Object) SetParents(v []string)

SetParents sets the object's parents

func (Object) SetPolicy

func (o Object) SetPolicy(v Object)

SetPolicy sets the object's policy

func (Object) SetSignature

func (o Object) SetSignature(v Object)

SetSignature sets the object's signature

func (Object) SetType

func (o Object) SetType(v string)

SetType sets the object's type

func (Object) ToMap

func (o Object) ToMap() map[string]interface{}

ToMap returns the object as a map

func (Object) ToObject

func (o Object) ToObject() Object

ToObject simply returns a copy of the object This is mostly a hack for generated objects

type Policy

type Policy struct {
	Description string   `json:"description:s,omitempty"`
	Subjects    []string `json:"subjects:as,omitempty"`
	Actions     []string `json:"actions:as,omitempty"`
	Effect      string   `json:"effect:s,omitempty"`
}

Policy for object

func (*Policy) FromObject

func (s *Policy) FromObject(o Object) error

FromObject populates the struct from a f12n object

func (Policy) GetType

func (s Policy) GetType() string

GetType returns the object's type

func (Policy) ToObject

func (s Policy) ToObject() Object

ToObject returns a f12n object

type TypeHint

type TypeHint string

TypeHint are the hints of a member's type

const (
	HintUndefined TypeHint = ""
	HintObject    TypeHint = "o"
	HintArray     TypeHint = "a"
	HintBool      TypeHint = "b"
	HintData      TypeHint = "d"
	HintFloat     TypeHint = "f"
	HintInt       TypeHint = "i"
	HintNil       TypeHint = "n"
	HintString    TypeHint = "s"
	HintUint      TypeHint = "u"
)

func DeduceTypeHint

func DeduceTypeHint(o interface{}) TypeHint

DeduceTypeHint returns a TypeHint from a given value

func GetTypeHint

func GetTypeHint(t string) TypeHint

GetTypeHint returns a TypeHint from a string

func (TypeHint) String

func (t TypeHint) String() string

String implements the Stringer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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