route/doc/api.md

116 lines
1.8 KiB
Markdown

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"`
IsAdmin bool `gorethink:"isADmin"`
}
```
### Login
### Logout
### Promote
### Demote
### AddNewLoginMethod