github.com/go-chef/chef@v0.30.1/principal.go (about)

     1  package chef
     2  
     3  import "fmt"
     4  
     5  type PrincipalService struct {
     6  	client *Client
     7  }
     8  
     9  // Principal represents the native Go version of the deserialized Principal type
    10  type Principal struct {
    11  	Principals []Principals `json:"principals"`
    12  }
    13  
    14  type Principals struct {
    15  	Name      string `json:"name"`
    16  	Type      string `json:"type"`
    17  	PublicKey string `json:"public_key"`
    18  	AuthzId   string `json:"authz_id"`
    19  	OrgMember bool   `json:"org_member"`
    20  }
    21  
    22  // Get gets a principal from the Chef server.
    23  //
    24  // Chef API docs: https://docs.chef.io/api_chef_server.html#principals-name
    25  func (e *PrincipalService) Get(name string) (principal Principal, err error) {
    26  	url := fmt.Sprintf("principals/%s", name)
    27  	err = e.client.magicRequestDecoder("GET", url, nil, &principal)
    28  	return
    29  }