Add docs for internal cluster API at /v1/swagger/index.html
This commit is contained in:
parent
cefc03bcb2
commit
3adf5fd7d4
3
Makefile
3
Makefile
@ -23,7 +23,8 @@ build_linux:
|
|||||||
|
|
||||||
## swagger: Update swagger API documentation (requires github.com/swaggo/swag)
|
## swagger: Update swagger API documentation (requires github.com/swaggo/swag)
|
||||||
swagger:
|
swagger:
|
||||||
swag init -g http/server.go
|
swag init -g http/server.go -o ./docs --exclude ./cluster
|
||||||
|
swag init -g cluster/api.go -o ./cluster/docs --exclude ./http --instanceName ClusterAPI
|
||||||
|
|
||||||
## gqlgen: Regenerate GraphQL server from schema
|
## gqlgen: Regenerate GraphQL server from schema
|
||||||
gqlgen:
|
gqlgen:
|
||||||
|
|||||||
767
cluster/api.go
767
cluster/api.go
File diff suppressed because it is too large
Load Diff
@ -19,23 +19,16 @@ type JoinRequest struct {
|
|||||||
RaftAddress string `json:"raft_address"`
|
RaftAddress string `json:"raft_address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LeaveRequest struct {
|
|
||||||
ID string `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddProcessRequest struct {
|
type AddProcessRequest struct {
|
||||||
Config app.Config `json:"config"`
|
Config app.Config `json:"config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateProcessRequest struct {
|
type UpdateProcessRequest struct {
|
||||||
ID app.ProcessID `json:"id"`
|
Config app.Config `json:"config"`
|
||||||
Config app.Config `json:"config"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetProcessMetadataRequest struct {
|
type SetProcessMetadataRequest struct {
|
||||||
ID app.ProcessID `json:"id"`
|
Metadata interface{} `json:"metadata"`
|
||||||
Key string `json:"key"`
|
|
||||||
Metadata interface{} `json:"metadata"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddIdentityRequest struct {
|
type AddIdentityRequest struct {
|
||||||
@ -43,12 +36,10 @@ type AddIdentityRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateIdentityRequest struct {
|
type UpdateIdentityRequest struct {
|
||||||
Name string `json:"name"`
|
|
||||||
Identity iamidentity.User `json:"identity"`
|
Identity iamidentity.User `json:"identity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetPoliciesRequest struct {
|
type SetPoliciesRequest struct {
|
||||||
Name string `json:"name"`
|
|
||||||
Policies []iamaccess.Policy `json:"policies"`
|
Policies []iamaccess.Policy `json:"policies"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,24 +97,24 @@ func (c *APIClient) RemoveProcess(origin string, id app.ProcessID) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIClient) UpdateProcess(origin string, r UpdateProcessRequest) error {
|
func (c *APIClient) UpdateProcess(origin string, id app.ProcessID, r UpdateProcessRequest) error {
|
||||||
data, err := json.Marshal(r)
|
data, err := json.Marshal(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.call(http.MethodPut, "/process/"+r.ID.ID+"?domain="+r.ID.Domain, "application/json", bytes.NewReader(data), origin)
|
_, err = c.call(http.MethodPut, "/process/"+id.ID+"?domain="+id.Domain, "application/json", bytes.NewReader(data), origin)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIClient) SetProcessMetadata(origin string, r SetProcessMetadataRequest) error {
|
func (c *APIClient) SetProcessMetadata(origin string, id app.ProcessID, key string, r SetProcessMetadataRequest) error {
|
||||||
data, err := json.Marshal(r)
|
data, err := json.Marshal(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.call(http.MethodPut, "/process/"+r.ID.ID+"/metadata/"+r.Key+"?domain="+r.ID.Domain, "application/json", bytes.NewReader(data), origin)
|
_, err = c.call(http.MethodPut, "/process/"+id.ID+"/metadata/"+key+"?domain="+id.Domain, "application/json", bytes.NewReader(data), origin)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,26 +25,6 @@ import (
|
|||||||
"github.com/datarhei/core/v16/restream/app"
|
"github.com/datarhei/core/v16/restream/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
|
||||||
/api/v3:
|
|
||||||
GET /cluster/store/node - list all nodes that are stored in the FSM - Cluster.Store.ListNodes()
|
|
||||||
POST /cluster/store/node - add a node to the FSM - Cluster.Store.AddNode()
|
|
||||||
DELETE /cluster/store/node/:id - remove a node from the FSM - Cluster.Store.RemoveNode()
|
|
||||||
|
|
||||||
GET /cluster/store/process - list all process configs that are stored in the FSM - Cluster.Store.ListProcesses()
|
|
||||||
POST /cluster/store/process - add a process config to the FSM - Cluster.Store.AddProcess()
|
|
||||||
PUT /cluster/store/process/:id - update a process config in the FSM - Cluster.Store.UpdateProcess()
|
|
||||||
DELETE /cluster/store/process/:id - remove a process config from the FSM - Cluster.Store.RemoveProcess()
|
|
||||||
|
|
||||||
** for the processes, the leader will decide where to actually run them. the process configs will
|
|
||||||
also be added to the regular process DB of each core.
|
|
||||||
|
|
||||||
POST /cluster/join - join the cluster - Cluster.Join()
|
|
||||||
DELETE /cluster/:id - leave the cluster - Cluster.Leave()
|
|
||||||
|
|
||||||
** all these endpoints will forward the request to the leader.
|
|
||||||
*/
|
|
||||||
|
|
||||||
type Cluster interface {
|
type Cluster interface {
|
||||||
// Address returns the raft address of this node
|
// Address returns the raft address of this node
|
||||||
Address() string
|
Address() string
|
||||||
|
|||||||
961
cluster/docs/ClusterAPI_docs.go
Normal file
961
cluster/docs/ClusterAPI_docs.go
Normal file
File diff suppressed because it is too large
Load Diff
935
cluster/docs/ClusterAPI_swagger.json
Normal file
935
cluster/docs/ClusterAPI_swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
625
cluster/docs/ClusterAPI_swagger.yaml
Normal file
625
cluster/docs/ClusterAPI_swagger.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -161,7 +161,6 @@ func (f *forwarder) UpdateProcess(origin string, id app.ProcessID, config *app.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := apiclient.UpdateProcessRequest{
|
r := apiclient.UpdateProcessRequest{
|
||||||
ID: id,
|
|
||||||
Config: *config,
|
Config: *config,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +168,7 @@ func (f *forwarder) UpdateProcess(origin string, id app.ProcessID, config *app.C
|
|||||||
client := f.client
|
client := f.client
|
||||||
f.lock.RUnlock()
|
f.lock.RUnlock()
|
||||||
|
|
||||||
return client.UpdateProcess(origin, r)
|
return client.UpdateProcess(origin, id, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *forwarder) SetProcessMetadata(origin string, id app.ProcessID, key string, data interface{}) error {
|
func (f *forwarder) SetProcessMetadata(origin string, id app.ProcessID, key string, data interface{}) error {
|
||||||
@ -178,8 +177,6 @@ func (f *forwarder) SetProcessMetadata(origin string, id app.ProcessID, key stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := apiclient.SetProcessMetadataRequest{
|
r := apiclient.SetProcessMetadataRequest{
|
||||||
ID: id,
|
|
||||||
Key: key,
|
|
||||||
Metadata: data,
|
Metadata: data,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +184,7 @@ func (f *forwarder) SetProcessMetadata(origin string, id app.ProcessID, key stri
|
|||||||
client := f.client
|
client := f.client
|
||||||
f.lock.RUnlock()
|
f.lock.RUnlock()
|
||||||
|
|
||||||
return client.SetProcessMetadata(origin, r)
|
return client.SetProcessMetadata(origin, id, key, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *forwarder) RemoveProcess(origin string, id app.ProcessID) error {
|
func (f *forwarder) RemoveProcess(origin string, id app.ProcessID) error {
|
||||||
@ -224,7 +221,6 @@ func (f *forwarder) UpdateIdentity(origin, name string, identity iamidentity.Use
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := apiclient.UpdateIdentityRequest{
|
r := apiclient.UpdateIdentityRequest{
|
||||||
Name: name,
|
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +237,6 @@ func (f *forwarder) SetPolicies(origin, name string, policies []iamaccess.Policy
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := apiclient.SetPoliciesRequest{
|
r := apiclient.SetPoliciesRequest{
|
||||||
Name: name,
|
|
||||||
Policies: policies,
|
Policies: policies,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user