2019-11-01 12:01:16 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2022-10-05 19:44:55 +00:00
|
|
|
"time"
|
2019-11-01 12:01:16 +00:00
|
|
|
|
2020-10-17 10:53:42 +00:00
|
|
|
"github.com/google/uuid"
|
|
|
|
|
2020-08-18 01:12:50 +00:00
|
|
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
2022-06-14 15:00:51 +00:00
|
|
|
|
|
|
|
apitypes "github.com/filecoin-project/lotus/api/types"
|
|
|
|
"github.com/filecoin-project/lotus/journal/alerting"
|
2020-05-20 18:23:51 +00:00
|
|
|
)
|
2019-12-09 17:08:32 +00:00
|
|
|
|
2021-04-26 18:36:20 +00:00
|
|
|
// MODIFYING THE API INTERFACE
|
|
|
|
//
|
|
|
|
// When adding / changing methods in this file:
|
|
|
|
// * Do the change here
|
|
|
|
// * Adjust implementation in `node/impl/`
|
|
|
|
// * Run `make gen` - this will:
|
|
|
|
// * Generate proxy structs
|
|
|
|
// * Generate mocks
|
|
|
|
// * Generate markdown docs
|
|
|
|
// * Generate openrpc blobs
|
|
|
|
|
2019-11-01 12:01:16 +00:00
|
|
|
type Common interface {
|
2020-06-18 12:56:00 +00:00
|
|
|
// MethodGroup: Auth
|
|
|
|
|
2021-03-23 12:42:56 +00:00
|
|
|
AuthVerify(ctx context.Context, token string) ([]auth.Permission, error) //perm:read
|
|
|
|
AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) //perm:admin
|
2019-11-01 12:01:16 +00:00
|
|
|
|
2021-06-29 12:07:00 +00:00
|
|
|
// MethodGroup: Log
|
2020-09-02 22:45:57 +00:00
|
|
|
|
2021-06-29 12:07:00 +00:00
|
|
|
LogList(context.Context) ([]string, error) //perm:write
|
|
|
|
LogSetLevel(context.Context, string, string) error //perm:write
|
2020-11-13 10:17:20 +00:00
|
|
|
|
2021-08-17 12:51:54 +00:00
|
|
|
// LogAlerts returns list of all, active and inactive alerts tracked by the
|
|
|
|
// node
|
2021-08-17 13:15:36 +00:00
|
|
|
LogAlerts(ctx context.Context) ([]alerting.Alert, error) //perm:admin
|
2021-08-17 12:51:54 +00:00
|
|
|
|
2020-06-18 12:56:00 +00:00
|
|
|
// MethodGroup: Common
|
|
|
|
|
2019-11-01 12:01:16 +00:00
|
|
|
// Version provides information about API provider
|
2021-03-23 12:42:56 +00:00
|
|
|
Version(context.Context) (APIVersion, error) //perm:read
|
2020-02-15 05:49:54 +00:00
|
|
|
|
2021-06-29 12:07:00 +00:00
|
|
|
// Discover returns an OpenRPC document describing an RPC API.
|
|
|
|
Discover(ctx context.Context) (apitypes.OpenRPCDocument, error) //perm:read
|
2020-06-02 18:54:24 +00:00
|
|
|
|
|
|
|
// trigger graceful shutdown
|
2021-03-23 12:42:56 +00:00
|
|
|
Shutdown(context.Context) error //perm:admin
|
2020-06-17 14:44:59 +00:00
|
|
|
|
2022-10-05 19:44:55 +00:00
|
|
|
// StartTime returns node start time
|
|
|
|
StartTime(context.Context) (time.Time, error) //perm:read
|
|
|
|
|
2020-10-17 10:53:42 +00:00
|
|
|
// Session returns a random UUID of api provider session
|
2021-03-23 12:42:56 +00:00
|
|
|
Session(context.Context) (uuid.UUID, error) //perm:read
|
2020-10-17 10:53:42 +00:00
|
|
|
|
2021-03-23 12:42:56 +00:00
|
|
|
Closing(context.Context) (<-chan struct{}, error) //perm:read
|
2019-11-01 12:01:16 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 21:01:20 +00:00
|
|
|
// APIVersion provides various build-time information
|
|
|
|
type APIVersion struct {
|
2019-11-01 12:01:16 +00:00
|
|
|
Version string
|
|
|
|
|
|
|
|
// APIVersion is a binary encoded semver version of the remote implementing
|
|
|
|
// this api
|
|
|
|
//
|
|
|
|
// See APIVersion in build/version.go
|
2021-03-05 21:01:20 +00:00
|
|
|
APIVersion Version
|
2019-11-01 12:01:16 +00:00
|
|
|
|
|
|
|
// TODO: git commit / os / genesis cid?
|
|
|
|
|
|
|
|
// Seconds
|
|
|
|
BlockDelay uint64
|
|
|
|
}
|
|
|
|
|
2021-03-05 21:01:20 +00:00
|
|
|
func (v APIVersion) String() string {
|
2019-12-17 15:26:16 +00:00
|
|
|
return fmt.Sprintf("%s+api%s", v.Version, v.APIVersion.String())
|
2019-11-01 13:58:48 +00:00
|
|
|
}
|