client

package
v0.3.0-dev.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

This package contains a web client for the Cog service.

It's used here for testing, and by cogctl.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CogClient

type CogClient struct {
	// contains filtered or unexported fields
}

CogClient comments to be written...

func Connect

func Connect(profileName string) (*CogClient, error)

Connect creates and returns a configured instance of the client for the specified host. An empty string will use the default profile. If the requested profile doesn't exist, an empty ProfileEntry is returned.

func ConnectWithNewProfile

func ConnectWithNewProfile(entry ProfileEntry) (*CogClient, error)

ConnectWithNewProfile generates a connection using the supplied profile entry data.

func (*CogClient) Authenticate

func (c *CogClient) Authenticate() (rest.Token, error)

Authenticate requests a new authentication token from the Cog service. If a valid token already exists it will be automatically invalidated if this call is successful.

func (*CogClient) Authenticated

func (c *CogClient) Authenticated() (bool, error)

Authenticated looks for any cached tokens associated with the current server. Returns false if no tokens exist or tokens are expired.

func (*CogClient) Bootstrap

func (c *CogClient) Bootstrap(user rest.User) (rest.User, error)

Bootstrap calls the POST /v2/bootstrap endpoint.

func (*CogClient) GroupDelete

func (c *CogClient) GroupDelete(groupname string) error

GroupDelete comments to be written...

func (*CogClient) GroupExists

func (c *CogClient) GroupExists(groupname string) (bool, error)

GroupExists simply returns true if a group exists with the specified groupname; false otherwise.

func (*CogClient) GroupGet

func (c *CogClient) GroupGet(groupname string) (rest.Group, error)

GroupGet comments to be written...

func (*CogClient) GroupList

func (c *CogClient) GroupList() ([]rest.Group, error)

GroupList comments to be written...

func (*CogClient) GroupMemberAdd

func (c *CogClient) GroupMemberAdd(groupname string, username string) error

GroupMemberAdd comments to be written...

func (*CogClient) GroupMemberDelete

func (c *CogClient) GroupMemberDelete(groupname string, username string) error

GroupMemberDelete comments to be written...

func (*CogClient) GroupMemberList

func (c *CogClient) GroupMemberList(groupname string) ([]rest.User, error)

GroupMemberList comments to be written...

func (*CogClient) GroupSave

func (c *CogClient) GroupSave(group rest.Group) error

GroupSave comments to be written...

func (*CogClient) Token

func (c *CogClient) Token() (rest.Token, error)

Token is just a wrapper around a call to Authenticated() followed by a call to Authenticate() if false.

func (*CogClient) UserDelete

func (c *CogClient) UserDelete(username string) error

UserDelete comments to be written...

func (*CogClient) UserExists

func (c *CogClient) UserExists(username string) (bool, error)

UserExists simply returns true if a user exists with the specified username; false otherwise.

func (*CogClient) UserGet

func (c *CogClient) UserGet(username string) (rest.User, error)

UserGet comments to be written...

func (*CogClient) UserGroupList

func (c *CogClient) UserGroupList(username string) ([]rest.Group, error)

UserGroupList comments to be written...

func (*CogClient) UserList

func (c *CogClient) UserList() ([]rest.User, error)

UserList comments to be written...

func (*CogClient) UserSave

func (c *CogClient) UserSave(user rest.User) error

UserSave will create or update a user. Note the the key is the username: if this is called with a user whose username exists that user is updated; otherwise a new user is created.

type Profile

type Profile struct {
	Defaults ProfileDefaults
	Profiles map[string]ProfileEntry `yaml:",inline"`
}

Profile represents a set of user profiles from a $HOME/.cog/profiles file

func (Profile) Default

func (p Profile) Default() ProfileEntry

Default returns this Profile's default entry. If there's no default, or if the default doesn't exist, an empty ProfileEntry is returned.

type ProfileDefaults

type ProfileDefaults struct {
	Profile string
}

ProfileDefaults is used to store default values for a cog client profile.

type ProfileEntry

type ProfileEntry struct {
	Name      string   `yaml:"-"`
	URLString string   `yaml:"url"`
	Password  string   `yaml:"password"`
	URL       *url.URL `yaml:"-"`
	Username  string   `yaml:"user"`
}

ProfileEntry represents a single profile entry.

func (ProfileEntry) User

func (pe ProfileEntry) User() rest.User

User is a convenience method that returns a rest.User pre-set with the entry's username and password.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL