| 129 | } |
| 130 | |
| 131 | func (hc *HTTPClient) CreateGroupWithRules(name string, rules []AclRule) (*AclGroup, error) { |
| 132 | const query = `mutation addGroup($name: String!, $rules: [RuleRef]){ |
| 133 | addGroup(input: [{name: $name rules: $rules }]) { |
| 134 | group { |
| 135 | name |
| 136 | rules { |
| 137 | predicate |
| 138 | permission |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | }` |
| 143 | params := GraphQLParams{ |
| 144 | Query: query, |
| 145 | Variables: map[string]interface{}{ |
| 146 | "name": name, |
| 147 | "rules": rules, |
| 148 | }, |
| 149 | } |
| 150 | resp, err := hc.RunGraphqlQuery(params, true) |
| 151 | if err != nil { |
| 152 | return nil, err |
| 153 | } |
| 154 | |
| 155 | var addGroupResp struct { |
| 156 | AddGroup struct { |
| 157 | Group []AclGroup |
| 158 | } |
| 159 | } |
| 160 | if err := json.Unmarshal(resp, &addGroupResp); err != nil { |
| 161 | return nil, errors.Wrap(err, "error while unmarshalling") |
| 162 | } |
| 163 | if len(addGroupResp.AddGroup.Group) != 1 { |
| 164 | return nil, errACLGroupCountMoreThanOne |
| 165 | } |
| 166 | return &addGroupResp.AddGroup.Group[0], nil |
| 167 | } |
| 168 | |
| 169 | func (hc *HTTPClient) DeleteGroup(name string) error { |
| 170 | const query = `mutation deleteGroup($name: String!) { |