doc: add API documentation

This commit is contained in:
Cadey Ratio 2017-01-26 07:56:31 -08:00
parent 12fdcfdf55
commit db86f49de2
1 changed files with 104 additions and 0 deletions

104
doc/api.md Normal file
View File

@ -0,0 +1,104 @@
API calls
=========
Host Management
---------------
```go
type HostKind int
const (
KindHTTP HostKind = iota
KindTCP
KindIRC
KindProxy
)
type Host struct {
ID string `gorethink:"id,omitempty"`
Hostname string `gorethink:"hostname"`
OnionHostname string `gorethink:"onionhostname"`
Token string `gorethink:"token"`
OnionKey []byte `gorethink:"onionKey" json:"-"` // PEM-encoded
Kind HostKind `gorethink:"hostKind"`
Port string `gorethink:"port"`
AllowedUsers []string `gorethink:"allowedUsers"`
}
```
### AddHost
This creates a new host in the routing mesh.
```go
type AddHostRequest struct {
BaseAPICall
Hostname string
OnionKey *rsa.PrivateKey
}
type AddHostResponse struct {
ID string
Token string // JWT
Hostname string
OnionHostname string
}
```
### GetHost
### ModifyHost
Token Management
----------------
```go
type Token struct {
ID string `gorethink:"id,omitempty" json:"jti"`
ExpiresAt int64 `json:"exp,omitempty"`
IssuedAt int64 `json:"iat,omitempty"`
Issuer string `json:"iss,omitempty"`
Subject string `json:"sub,omitempty"`
Revoked bool
RevocationID string
Scopes []string `json:"scopes"`
}
```
### CreateInitialToken
### ValidateToken
### CreateToken
### ListTokens
### RevokeToken
Metrics
-------
### Report
Returns the following data for the last minute, the last 5 minutes and the last
10 minutes:
- Number of requests processed
- Total request latency
- Longest request latency
- Shortest request latency
Users
-----
```go
type User struct {
ID string `gorethink:"id,omitempty"`
Email string `gorethink:"email"`
OauthMethod string `gorethink:"oauthMethod"`
}
```