Documentation ¶
Index ¶
- type Path
- func (p *Path) At(index int) string
- func (p *Path) Back() string
- func (p *Path) Copy() *Path
- func (p *Path) CopyAt(index int) *Path
- func (p *Path) Empty() bool
- func (p *Path) Front() string
- func (p *Path) HasPrefix(subject string) bool
- func (p *Path) HasPrefixFold(subject string) bool
- func (p *Path) IterShapeRefs(subject *awssdkmodel.ShapeRef) []*awssdkmodel.ShapeRef
- func (p *Path) MarshalJSON() ([]byte, error)
- func (p *Path) Pop() (part string)
- func (p *Path) PopFront() (part string)
- func (p *Path) PushBack(part string)
- func (p *Path) ShapeRef(subject *awssdkmodel.ShapeRef) *awssdkmodel.ShapeRef
- func (p *Path) ShapeRefAt(subject *awssdkmodel.ShapeRef, index int) *awssdkmodel.ShapeRef
- func (p *Path) Size() int
- func (p *Path) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path provides a JSONPath-like struct and field-member "route" to a particular field within a resource. Path implements json.Marshaler interface.
func FromString ¶
FromString returns a new Path from a dotted-notation string, e.g. "Author.Name".
func (*Path) At ¶
At returns the part of the Path at the supplied index, or empty string if index exceeds boundary.
func (*Path) Back ¶
Back returns the last part of the Path or empty string if the Path has no parts.
func (*Path) CopyAt ¶
CopyAt returns a new Path that is a copy of this Path up to the supplied index.
e.g. given Path $A containing "X.Y", $A.CopyAt(0) would return a new Path containing just "X". $A.CopyAt(1) would return a new Path containing "X.Y".
func (*Path) Front ¶
Front returns the first part of the Path or empty string if the Path has no parts.
func (*Path) HasPrefix ¶
HasPrefix returns true if the supplied string, delimited on ".", matches p.parts up to the length of the supplied string. e.g. if the Path p represents "A.B":
subject "A" -> true subject "A.B" -> true subject "A.B.C" -> false subject "B" -> false subject "A.C" -> false
func (*Path) HasPrefixFold ¶
HasPrefixFold is the same as HasPrefix but uses case-insensitive comparisons
func (*Path) IterShapeRefs ¶
func (p *Path) IterShapeRefs( subject *awssdkmodel.ShapeRef, ) []*awssdkmodel.ShapeRef
IterShapeRefs returns a slice of ShapeRef pointers representing each part of the path
func (*Path) MarshalJSON ¶
MarshalJSON returns the JSON encoding of a Path object.
func (*Path) ShapeRef ¶
func (p *Path) ShapeRef( subject *awssdkmodel.ShapeRef, ) *awssdkmodel.ShapeRef
ShapeRef returns an aws-sdk-go ShapeRef within the supplied ShapeRef that matches the Path. Returns nil if no matching ShapeRef could be found.
Assume a ShapeRef that looks like this:
authShapeRef := &awssdkmodel.ShapeRef{ ShapeName: "Author", Shape: &awssdkmodel.Shape{ Type: "structure", MemberRefs: map[string]*awssdkmodel.ShapeRef{ "Name": &awssdkmodel.ShapeRef{ ShapeName: "Name", Shape: &awssdkmodel.Shape{ Type: "string", }, }, "Address": &awssdkmodel.ShapeRef{ ShapeName: "Address", Shape: &awssdkmodel.Shape{ Type: "structure", MemberRefs: map[string]*awssdkmodel.ShapeRef{ "State": &awssdkmodel.ShapeRef{ ShapeName: "StateCode", Shape: &awssdkmodel.Shape{ Type: "string", }, }, "Country": &awssdkmodel.ShapeRef{ ShapeName: "CountryCode", Shape: &awssdkmodel.Shape{ Type: "string", }, }, }, }, }, }, }, }
If I have the following Path:
p := fieldpath.FromString("Author.Address.Country")
calling p.ShapeRef(authShapeRef) would return the following:
&awssdkmodel.ShapeRef{ ShapeName: "CountryCode", Shape: &awssdkmodel.Shape{ Type: "string", }, },
func (*Path) ShapeRefAt ¶
func (p *Path) ShapeRefAt( subject *awssdkmodel.ShapeRef, index int, ) *awssdkmodel.ShapeRef
ShapeRefAt returns an aws-sdk-go ShapeRef within the supplied ShapeRef that matches the Path at the supplied index. Returns nil if no matching ShapeRef could be found or index out of bounds.