api

package
v0.0.0-...-0765a50 Latest Latest
Warning

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

Go to latest
Published: May 14, 2017 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
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

type Server struct {
	Client    string
	BaseURL   string
	TLSConfig *tls.Config
	HTTP      *http.Client
}

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 (api *Server) ChannelList() (list map[string]*channel.Channel, err error)

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) Login

func (api *Server) Login() (loggedUser *user.User, err error)

Login log a user based on his nebulo signed certificate

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 (api *Server) MessageCreate(channelName string, plaintext string) (err error)

func (*Server) MessageList

func (api *Server) MessageList(channelName string, lastRead time.Time) (list []*message.Message, err error)

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

func (api *Server) Register(key crypto.PrivateKey) (newUser *user.User, err error)

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

func (api *Server) UserProfile() (u *user.User, err error)

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

type UserProfileResponse user.User

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

Jump to

Keyboard shortcuts

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