terraform/vendor/github.com/go-chef/chef/principal.go

34 lines
818 B
Go
Raw Normal View History

2016-08-23 00:58:31 +02:00
package chef
import "fmt"
type PrincipalService struct {
client *Client
}
// Principal represents the native Go version of the deserialized Principal type
type Principal struct {
Name string `json:"name"`
Type string `json:"type"`
PublicKey string `json:"public_key"`
AuthzId string `json:"authz_id"`
OrgMember bool `json:"org_member"`
}
func NewPrincipal(name, typ, publicKey string) Principal {
return Principal{
Name: name,
Type: typ,
PublicKey: publicKey,
}
}
// Get gets a principal from the Chef server.
//
// Chef API docs: https://docs.chef.io/api_chef_server.html#id64
func (e *PrincipalService) Get(name string) (principal Principal, err error) {
url := fmt.Sprintf("principals/%s", name)
err = e.client.magicRequestDecoder("GET", url, nil, &principal)
return
}