Documentation ¶
Index ¶
- Constants
- type Server
- func (api *Server) ChannelCreate(name string, membersPublicKey []string) (c *channel.Channel, err error)
- func (api *Server) ChannelList() (list map[string]*channel.Channel, err error)
- func (api *Server) Get(endpoint string, expectedStatus int, queryParams url.Values) (response *http.Response, err error)
- func (api *Server) Login() (loggedUser *user.User, err error)
- func (api *Server) LoginWithCertsFilename(certFilepath string, keyFilePath string, keyPassword []byte) (_ *user.User, err error)
- func (api *Server) MessageCreate(channelName string, plaintext string) (err error)
- func (api *Server) MessageList(channelName string, lastRead time.Time) (list []*message.Message, err error)
- func (api *Server) Post(endpoint string, expectedStatus int, contentType string, body io.Reader) (response *http.Response, err error)
- func (api *Server) Register(key crypto.PrivateKey) (newUser *user.User, err error)
- func (api *Server) RegisterWithKeyPairFilename(privateKeyFilepath string, privateKeyPassword []byte) (_ *user.User, err error)
- func (api *Server) Request(request *http.Request, expectedStatus int) (response *http.Response, err error)
- func (api *Server) UserProfile() (u *user.User, err error)
- func (api *Server) Version() (version *VersionResponse, err error)
- type UserProfileResponse
- type VersionResponse
Constants ¶
const ( CONTENT_TYPE_JSON = "application/json" CONTENT_TYPE_PEM = "application/x-pem-file" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
Server store informations to make the communication with the API server easier
var API *Server
API is the current configuration to contact the api server
func (*Server) ChannelCreate ¶
func (api *Server) ChannelCreate(name string, membersPublicKey []string) (c *channel.Channel, err error)
ChannelCreate return the wanted channel profile informations
func (*Server) ChannelList ¶
func (*Server) Get ¶
func (api *Server) Get(endpoint string, expectedStatus int, queryParams url.Values) (response *http.Response, err error)
Get create and send a GET request and return the response
func (*Server) LoginWithCertsFilename ¶
func (api *Server) LoginWithCertsFilename(certFilepath string, keyFilePath string, keyPassword []byte) (_ *user.User, err error)
LoginWithCertsFilename do the Login call but with the cert and key path
func (*Server) MessageCreate ¶
func (*Server) MessageList ¶
func (*Server) Post ¶
func (api *Server) Post(endpoint string, expectedStatus int, contentType string, body io.Reader) (response *http.Response, err error)
Post create and send a POST request and return the response
func (*Server) Register ¶
Register send a certificate signing request and store the signed certificate
func (*Server) RegisterWithKeyPairFilename ¶
func (api *Server) RegisterWithKeyPairFilename(privateKeyFilepath string, privateKeyPassword []byte) (_ *user.User, err error)
RegisterWithKeyPairFilename do the same thing as Register but with key path and password
func (*Server) Request ¶
func (api *Server) Request(request *http.Request, expectedStatus int) (response *http.Response, err error)
Request add things every requests need, do the request, check the status code and return the response
func (*Server) UserProfile ¶
UserProfile return the user profile informations
func (*Server) Version ¶
func (api *Server) Version() (version *VersionResponse, err error)
Version return the server versions informations
type UserProfileResponse ¶
UserProfileResponse is the response format wanted from a /user call
type VersionResponse ¶
type VersionResponse struct { Version string `json:"build_version"` Time string `json:"build_time"` }
VersionResponse is the response format wanted from a /version call
func Initialize ¶
func Initialize(version string, baseurl string, tlsOptions *config.TLSOptions) (serverVersion *VersionResponse, err error)
Initialize create a new Server{} base url and certificate configuration