MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / UpdateGroup

Method UpdateGroup

dgraphapi/acl.go:335–382  ·  view source on GitHub ↗
(name string, setRules []AclRule, removeRules []string)

Source from the content-addressed store, hash-verified

333}
334
335func (hc *HTTPClient) UpdateGroup(name string, setRules []AclRule, removeRules []string) (*AclGroup, error) {
336 const query = `mutation updateGroup($name: String!, $set: SetGroupPatch, $remove: RemoveGroupPatch){
337 updateGroup(input: {filter: {name: {eq: $name}}set: $set remove: $remove}) {
338 group {
339 name
340 rules {
341 predicate
342 permission
343 }
344 }
345 }
346 }`
347 params := GraphQLParams{
348 Query: query,
349 Variables: map[string]interface{}{
350 "name": name,
351 "set": nil,
352 "remove": nil,
353 },
354 }
355 if len(setRules) != 0 {
356 params.Variables["set"] = map[string]interface{}{
357 "rules": setRules,
358 }
359 }
360 if len(removeRules) != 0 {
361 params.Variables["remove"] = map[string]interface{}{
362 "rules": removeRules,
363 }
364 }
365 resp, err := hc.RunGraphqlQuery(params, true)
366 if err != nil {
367 return nil, err
368 }
369
370 var result struct {
371 UpdateGroup struct {
372 Group []AclGroup
373 }
374 }
375 if err := json.Unmarshal(resp, &result); err != nil {
376 return nil, errors.Wrap(err, "error unmarshalling response")
377 }
378 if len(result.UpdateGroup.Group) != 1 {
379 return nil, errACLGroupCountMoreThanOne
380 }
381 return &result.UpdateGroup.Group[0], nil
382}
383
384func (hc *HTTPClient) AddNamespace() (uint64, error) {
385 const createNs = `mutation {

Calls 1

RunGraphqlQueryMethod · 0.95

Tested by 1