lotus/api/api_common.go

81 lines
2.1 KiB
Go
Raw Normal View History

2019-11-01 12:01:16 +00:00
package api
import (
"context"
"fmt"
"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
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
// MethodGroup: Log
2020-09-02 22:45:57 +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
Version(context.Context) (APIVersion, error) //perm:read
// Discover returns an OpenRPC document describing an RPC API.
Discover(ctx context.Context) (apitypes.OpenRPCDocument, error) //perm:read
// trigger graceful shutdown
Shutdown(context.Context) error //perm:admin
2020-06-17 14:44:59 +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
Session(context.Context) (uuid.UUID, error) //perm:read
2020-10-17 10:53:42 +00:00
Closing(context.Context) (<-chan struct{}, error) //perm:read
2019-11-01 12:01:16 +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
APIVersion Version
2019-11-01 12:01:16 +00:00
// TODO: git commit / os / genesis cid?
// Seconds
BlockDelay uint64
}
func (v APIVersion) String() string {
return fmt.Sprintf("%s+api%s", v.Version, v.APIVersion.String())
2019-11-01 13:58:48 +00:00
}