opentofu/vendor/github.com/go-chef/chef/acl.go
Paul Hinze 6fe2703665 Vendor all dependencies w/ Godep
* Remove `make updatedeps` from Travis build. We'll follow up with more
   specific plans around dependency updating in subsequent PRs.
 * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to
   filter out `/vendor/` from `./...` where appropriate.
 * Temporarily remove `vet` from the `make test` target until we can
   figure out how to get it to not vet `vendor/`. (Initial
   experimentation failed to yield the proper incantation.)

Everything is pinned to current master, with the exception of:

 * Azure/azure-sdk-for-go which is pinned before the breaking change today
 * aws/aws-sdk-go which is pinned to the most recent tag

The documentation still needs to be updated, which we can do in a follow
up PR. The goal here is to unblock release.
2016-01-29 15:08:48 -06:00

53 lines
1.0 KiB
Go

package chef
import "fmt"
type ACLService struct {
client *Client
}
// ACL represents the native Go version of the deserialized ACL type
type ACL map[string]ACLitems
// ACLitems
type ACLitems struct {
Groups ACLitem `json:"groups"`
Actors ACLitem `json:"actors"`
}
// ACLitem
type ACLitem []string
func NewACL(acltype string, actors, groups ACLitem) (acl *ACL) {
acl = &ACL{
acltype: ACLitems{
Actors: actors,
Groups: groups,
},
}
return
}
// Get gets an ACL from the Chef server.
//
// Chef API docs: lol
func (a *ACLService) Get(subkind string, name string) (acl ACL, err error) {
url := fmt.Sprintf("%s/%s/_acl", subkind, name)
err = a.client.magicRequestDecoder("GET", url, nil, &acl)
return
}
// Put updates an ACL on the Chef server.
//
// Chef API docs: rofl
func (a *ACLService) Put(subkind, name string, acltype string, item *ACL) (err error) {
url := fmt.Sprintf("%s/%s/_acl/%s", subkind, name, acltype)
body, err := JSONReader(item)
if err != nil {
return
}
err = a.client.magicRequestDecoder("PUT", url, body, nil)
return
}