-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstatement.go
More file actions
93 lines (74 loc) · 2.28 KB
/
Copy pathstatement.go
File metadata and controls
93 lines (74 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package iamgo
import (
"encoding/json"
"github.com/liamg/jfather"
)
type Statement struct {
inner innerStatement
r Range
}
type Statements struct {
r Range
inner []Statement
}
type innerStatement struct {
Sid String `json:"Sid,omitempty"`
Effect String `json:"Effect"`
Principal Principals `json:"Principal,omitempty"`
NotPrincipal Principals `json:"NotPrincipal,omitempty"`
Action Strings `json:"Action,omitempty"`
NotAction Strings `json:"NotAction,omitempty"`
Resource Strings `json:"Resource,omitempty"`
NotResource Strings `json:"NotResource,omitempty"`
Condition Conditions `json:"Condition,omitempty"`
}
func (s *Statements) UnmarshalJSONWithMetadata(node jfather.Node) error {
s.r.StartLine = node.Range().Start.Line
s.r.EndLine = node.Range().End.Line
if err := node.Decode(&s.inner); err != nil {
s.inner = append(s.inner, Statement{})
return node.Decode(&s.inner[0])
}
return nil
}
func (s *Statement) UnmarshalJSONWithMetadata(node jfather.Node) error {
s.r.StartLine = node.Range().Start.Line
s.r.EndLine = node.Range().End.Line
return node.Decode(&s.inner)
}
func (s Statements) MarshalJSON() ([]byte, error) {
return json.Marshal(s.inner)
}
func (s Statement) MarshalJSON() ([]byte, error) {
return json.Marshal(s.inner)
}
func (s *Statement) SID() (string, Range) {
return s.inner.Sid.inner, s.inner.Sid.r
}
func (s *Statement) Effect() (string, Range) {
return s.inner.Effect.inner, s.inner.Effect.r
}
func (s *Statement) Actions() ([]string, Range) {
return s.inner.Action.inner, s.inner.Action.r
}
func (s *Statement) NotActions() ([]string, Range) {
return s.inner.NotAction.inner, s.inner.NotAction.r
}
func (s *Statement) Resources() ([]string, Range) {
return s.inner.Resource.inner, s.inner.Resource.r
}
func (s *Statement) NotResource() ([]string, Range) {
return s.inner.NotResource.inner, s.inner.NotResource.r
}
func (s *Statement) Conditions() ([]Condition, Range) {
return s.inner.Condition.inner, s.inner.Condition.r
}
func (s *Statement) Principals() (Principals, Range) {
return s.inner.Principal, s.inner.Principal.r
}
func (s *Statement) NotPrincipals() (Principals, Range) {
return s.inner.NotPrincipal, s.inner.NotPrincipal.r
}
func (s *Statement) Range() Range {
return s.r
}