diff --git a/Taskfile.yaml b/Taskfile.yaml index af24631e..7022375a 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -25,61 +25,32 @@ tasks: - protoc --proto_path=. --go_out=. --go_opt=paths=source_relative *.proto all-code-gen: - deps: [gen-schema, proto] + deps: [gen-schema-api, proto] - gen-schema: - deps: [gen-schema-nodecontrol, gen-schema-agent] - - gen-schema-agent: - dir: api/agent + gen-schema-api: + dir: api cmds: - go-jsonschema - --package=gen --tags json - --schema-package=https://github.com/synadia-io/nex/api/agent/register-agent-request=github.com/synadia-io/nex/agentapi/go/gen - --schema-output=https://github.com/synadia-io/nex/api/agent/register-agent-request=go/gen/register_agent_request.go - --schema-package=https://github.com/synadia-io/nex/api/agent/start-workload-request=github.com/synadia-io/nex/api/agent/go/gen - --schema-output=https://github.com/synadia-io/nex/api/agent/start-workload-request=go/gen/start_workload_request.go - --schema-package=https://github.com/synadia-io/nex/api/agent/stop-workload-request=github.com/synadia-io/nex/agentapi/go/gen - --schema-output=https://github.com/synadia-io/nex/api/agent/stop-workload-request=go/gen/stop_workload_request.go - *.json - - gen-schema-nodecontrol: - dir: api/nodecontrol - cmds: - - go-jsonschema - --package=gen --tags json - --schema-package=io.nats.nex.v2.start_workload_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.start_workload_response=gen/start_workload_response.go - --schema-package=io.nats.nex.v2.stop_workload_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.stop_workload_response=gen/stop_workload_response.go - --schema-package=io.nats.nex.v2.stop_workload_request=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.stop_workload_request=gen/stop_workload_request.go - --schema-package=io.nats.nex.v2.node_info_request=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.node_info_request=gen/node_info_request.go - --schema-package=io.nats.nex.v2.node_info_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.node_info_response=gen/node_info_response.go - --schema-package=io.nats.nex.v2.lameduck_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.lameduck_response=gen/lameduck_response.go - --schema-package=io.nats.nex.v2.lameduck_request=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.lameduck_request=gen/lameduck_request.go - --schema-package=io.nats.nex.v2.workload_ping_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.workload_ping_response=gen/workload_ping_response.go - --schema-package=io.nats.nex.v2.agent_ping_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.agent_ping_response=gen/agent_ping_response.go - --schema-package=io.nats.nex.v2.node_ping_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.node_ping_response=gen/node_ping_response.go - --schema-package=io.nats.nex.v2.auction_request=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.auction_request=gen/auction_request.go - --schema-package=io.nats.nex.v2.auction_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.auction_response=gen/auction_response.go - --schema-package=io.nats.nex.v2.start_workload_request=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.start_workload_request=gen/start_workload_request.go - --schema-package=io.nats.nex.v2.clone_workload_request=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.clone_workload_request=gen/clone_workload_request.go - --schema-package=io.nats.nex.v2.clone_workload_response=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=io.nats.nex.v2.clone_workload_response=gen/clone_workload_response.go - --schema-package=shared=github.com/synadia-io/nex/api/nodecontrol/gen - --schema-output=shared=gen/shared.go + --package api --tags json + --schema-output=io.nats.nex.v2.agent_register_request=go/agent.go + --schema-output=io.nats.nex.v2.agent_register_response=go/agent.go + --schema-output=io.nats.nex.v2.agent_heartbeat=go/agent.go + --schema-output=io.nats.nex.v2.start_workload_request=go/shared.go + --schema-output=io.nats.nex.v2.start_workload_response=go/shared.go + --schema-output=io.nats.nex.v2.stop_workload_request=go/shared.go + --schema-output=io.nats.nex.v2.stop_workload_response=go/shared.go + --schema-output=io.nats.nex.v2.lameduck_request=go/shared.go + --schema-output=io.nats.nex.v2.lameduck_response=go/shared.go + --schema-output=io.nats.nex.v2.agent_ping_response=go/shared.go + --schema-output=io.nats.nex.v2.workload_ping_response=go/shared.go + --schema-output=shared=go/shared.go + --schema-output=io.nats.nex.v2.node_info_request=go/node.go + --schema-output=io.nats.nex.v2.node_info_response=go/node.go + --schema-output=io.nats.nex.v2.node_ping_response=go/node.go + --schema-output=io.nats.nex.v2.auction_request=go/node.go + --schema-output=io.nats.nex.v2.auction_response=go/node.go + --schema-output=io.nats.nex.v2.clone_workload_request=go/node.go + --schema-output=io.nats.nex.v2.clone_workload_response=go/node.go *.json nex: diff --git a/api/nodecontrol/agent-ping-response.json b/api/agent-ping-response.json similarity index 100% rename from api/nodecontrol/agent-ping-response.json rename to api/agent-ping-response.json diff --git a/api/agent/go/gen/start_workload_request.go b/api/agent/go/gen/start_workload_request.go deleted file mode 100644 index dd2f861b..00000000 --- a/api/agent/go/gen/start_workload_request.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type StartWorkloadRequestJson struct { - // Command line arguments to be passed when the workload is a native/service type - Argv []string `json:"argv,omitempty"` - - // A map containing environment variables, applicable for native workload types - Env StartWorkloadRequestJsonEnv `json:"env,omitempty"` - - // A hex encoded SHA-256 hash of the artifact file bytes - Hash string `json:"hash"` - - // Name of the workload - Name string `json:"name"` - - // Namespace of the workload - Namespace string `json:"namespace"` - - // Byte size of the workload artifact - TotalBytes int `json:"totalBytes"` - - // A list of trigger subjects for the workload, if applicable. Note these are NOT - // subscribed to by the agent, only used for information and validation - TriggerSubjects []string `json:"triggerSubjects,omitempty"` - - // The unique identifier of the workload to start. - WorkloadId string `json:"workloadId"` - - // Type of the workload - WorkloadType string `json:"workloadType"` -} - -// A map containing environment variables, applicable for native workload types -type StartWorkloadRequestJsonEnv map[string]interface{} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *StartWorkloadRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["hash"]; raw != nil && !ok { - return fmt.Errorf("field hash in StartWorkloadRequestJson: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in StartWorkloadRequestJson: required") - } - if _, ok := raw["namespace"]; raw != nil && !ok { - return fmt.Errorf("field namespace in StartWorkloadRequestJson: required") - } - if _, ok := raw["totalBytes"]; raw != nil && !ok { - return fmt.Errorf("field totalBytes in StartWorkloadRequestJson: required") - } - if _, ok := raw["workloadId"]; raw != nil && !ok { - return fmt.Errorf("field workloadId in StartWorkloadRequestJson: required") - } - if _, ok := raw["workloadType"]; raw != nil && !ok { - return fmt.Errorf("field workloadType in StartWorkloadRequestJson: required") - } - type Plain StartWorkloadRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - if 1 > plain.TotalBytes { - return fmt.Errorf("field %s: must be >= %v", "totalBytes", 1) - } - *j = StartWorkloadRequestJson(plain) - return nil -} diff --git a/api/agent/go/gen/stop_workload_request.go b/api/agent/go/gen/stop_workload_request.go deleted file mode 100644 index f48ac3d9..00000000 --- a/api/agent/go/gen/stop_workload_request.go +++ /dev/null @@ -1,35 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type StopWorkloadRequestJson struct { - // Indicates whether the stoppage should be immediate or graceful - Immediate *bool `json:"immediate,omitempty"` - - // Optional reason for stopping the workload - Reason *string `json:"reason,omitempty"` - - // The unique identifier of the workload to stop. - WorkloadId string `json:"workloadId"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *StopWorkloadRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["workloadId"]; raw != nil && !ok { - return fmt.Errorf("field workloadId in StopWorkloadRequestJson: required") - } - type Plain StopWorkloadRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = StopWorkloadRequestJson(plain) - return nil -} diff --git a/api/agent/start-workload-request.json b/api/agent/start-workload-request.json deleted file mode 100644 index 8af0b840..00000000 --- a/api/agent/start-workload-request.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://github.com/synadia-io/nex/api/agent/start-workload-request", - "title": "StartWorkloadRequest", - "type": "object", - "properties": { - "workloadId": { - "type": "string", - "format": "uuid", - "description": "The unique identifier of the workload to start." - }, - "name": { - "type": "string", - "description": "Name of the workload" - }, - "namespace": { - "type": "string", - "description": "Namespace of the workload" - }, - "totalBytes": { - "type": "integer", - "description": "Byte size of the workload artifact", - "minimum": 1 - }, - "hash": { - "type": "string", - "description": "A hex encoded SHA-256 hash of the artifact file bytes" - }, - "triggerSubjects": { - "type": "array", - "description": "A list of trigger subjects for the workload, if applicable. Note these are NOT subscribed to by the agent, only used for information and validation", - "items": { - "type": "string" - } - }, - "workloadType": { - "type": "string", - "description": "Type of the workload" - }, - "argv": { - "type": "array", - "description": "Command line arguments to be passed when the workload is a native/service type", - "items": { - "type": "string" - } - }, - "env": { - "type": "object", - "description": "A map containing environment variables, applicable for native workload types" - } - }, - "required": ["workloadId", "name", "namespace", "totalBytes", "hash", "workloadType"], - "additionalProperties": false - } - diff --git a/api/agent/stop-workload-request.json b/api/agent/stop-workload-request.json deleted file mode 100644 index 4ca25e28..00000000 --- a/api/agent/stop-workload-request.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://github.com/synadia-io/nex/api/agent/stop-workload-request", - "title": "StopWorkloadRequest", - "type": "object", - "properties": { - "workloadId": { - "type": "string", - "format": "uuid", - "description": "The unique identifier of the workload to stop." - }, - "reason": { - "type": "string", - "description": "Optional reason for stopping the workload" - }, - "immediate": { - "type": "boolean", - "description": "Indicates whether the stoppage should be immediate or graceful" - } - }, - "required": ["workloadId"], - "additionalProperties": false -} - diff --git a/api/nodecontrol/auction-request.json b/api/auction-request.json similarity index 100% rename from api/nodecontrol/auction-request.json rename to api/auction-request.json diff --git a/api/nodecontrol/auction-response.json b/api/auction-response.json similarity index 100% rename from api/nodecontrol/auction-response.json rename to api/auction-response.json diff --git a/api/nodecontrol/client.go b/api/client.go similarity index 99% rename from api/nodecontrol/client.go rename to api/client.go index 619d8f69..cb7cb9d8 100644 --- a/api/nodecontrol/client.go +++ b/api/client.go @@ -1,4 +1,4 @@ -package nodecontrol +package api import ( "encoding/json" @@ -7,7 +7,7 @@ import ( "github.com/nats-io/nats.go" "github.com/nats-io/nuid" - nodegen "github.com/synadia-io/nex/api/nodecontrol/gen" + nodegen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" ) diff --git a/api/nodecontrol/client_test.go b/api/client_test.go similarity index 97% rename from api/nodecontrol/client_test.go rename to api/client_test.go index ce839280..1f79b231 100644 --- a/api/nodecontrol/client_test.go +++ b/api/client_test.go @@ -1,4 +1,4 @@ -package nodecontrol +package api import ( "bytes" @@ -17,7 +17,7 @@ import ( "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" - "github.com/synadia-io/nex/api/nodecontrol/gen" + gen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" "github.com/synadia-io/nex/test" ) @@ -181,7 +181,7 @@ func TestAuctionDeployAndFindWorkload(t *testing.T) { encEnv, err := tAKey.Seal(envB, auctionResp[0].TargetXkey) be.NilErr(t, err) - binPath := test.BuildTestBinary(t, "../../test/testdata/forever/main.go", workingDir) + binPath := test.BuildTestBinary(t, "../test/testdata/forever/main.go", workingDir) resp, err := control.AuctionDeployWorkload(models.NodeSystemNamespace, auctionResp[0].BidderId, gen.StartWorkloadRequestJson{ Description: "Test Workload", @@ -253,7 +253,7 @@ func TestDirectDeployAndListWorkloads(t *testing.T) { encEnv, err := tAKey.Seal(envB, test.Node1XkeyPublicKey) be.NilErr(t, err) - binPath := test.BuildTestBinary(t, "../../test/testdata/forever/main.go", workingDir) + binPath := test.BuildTestBinary(t, "../test/testdata/forever/main.go", workingDir) resp, err := control.DeployWorkload(models.NodeSystemNamespace, test.Node1ServerPublicKey, gen.StartWorkloadRequestJson{ Description: "Test Workload", @@ -326,7 +326,7 @@ func TestUndeployWorkload(t *testing.T) { encEnv, err := tAKey.Seal(envB, test.Node1XkeyPublicKey) be.NilErr(t, err) - binPath := test.BuildTestBinary(t, "../../test/testdata/forever/main.go", workingDir) + binPath := test.BuildTestBinary(t, "../test/testdata/forever/main.go", workingDir) resp, err := control.DeployWorkload(models.NodeSystemNamespace, test.Node1ServerPublicKey, gen.StartWorkloadRequestJson{ Description: "Test Workload", @@ -485,7 +485,7 @@ func TestCopyWorkload(t *testing.T) { encEnv, err := tAKey.Seal(envB, test.Node1XkeyPublicKey) be.NilErr(t, err) - binPath := test.BuildTestBinary(t, "../../test/testdata/forever/main.go", workingDir) + binPath := test.BuildTestBinary(t, "../test/testdata/forever/main.go", workingDir) resp, err := control.DeployWorkload(models.NodeSystemNamespace, test.Node1ServerPublicKey, gen.StartWorkloadRequestJson{ Description: "Test Workload", diff --git a/api/nodecontrol/clone-workload-request.json b/api/clone-workload-request.json similarity index 100% rename from api/nodecontrol/clone-workload-request.json rename to api/clone-workload-request.json diff --git a/api/nodecontrol/clone-workload-response.json b/api/clone-workload-response.json similarity index 100% rename from api/nodecontrol/clone-workload-response.json rename to api/clone-workload-response.json diff --git a/api/agent/go/gen/register_agent_request.go b/api/go/agent.go similarity index 90% rename from api/agent/go/gen/register_agent_request.go rename to api/go/agent.go index 46e7122e..889714d4 100644 --- a/api/agent/go/gen/register_agent_request.go +++ b/api/go/agent.go @@ -1,10 +1,12 @@ // Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. -package gen +package api import "encoding/json" import "fmt" +type HeartbeatAgentJson map[string]interface{} + type RegisterAgentRequestJson struct { // A user friendly description of the agent Description *string `json:"description,omitempty"` @@ -39,3 +41,5 @@ func (j *RegisterAgentRequestJson) UnmarshalJSON(b []byte) error { *j = RegisterAgentRequestJson(plain) return nil } + +type RegisterAgentResponseJson map[string]interface{} diff --git a/api/go/node.go b/api/go/node.go new file mode 100644 index 00000000..d77422a9 --- /dev/null +++ b/api/go/node.go @@ -0,0 +1,357 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package api + +import "encoding/json" +import "fmt" + +type AuctionRequestJson struct { + // The type of agent to auction for + AgentType []NexWorkload `json:"agent_type,omitempty"` + + // A unique identifier for the auction + AuctionId string `json:"auction_id"` + + // A list of tags to associate with the node during auction. To be returned, node + // must satisfy ALL tags + Tags AuctionRequestJsonTags `json:"tags"` +} + +// A list of tags to associate with the node during auction. To be returned, node +// must satisfy ALL tags +type AuctionRequestJsonTags struct { + // Tags corresponds to the JSON schema field "tags". + Tags AuctionRequestJsonTagsTags `json:"tags,omitempty"` +} + +type AuctionRequestJsonTagsTags map[string]string + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AuctionRequestJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["auction_id"]; raw != nil && !ok { + return fmt.Errorf("field auction_id in AuctionRequestJson: required") + } + if _, ok := raw["tags"]; raw != nil && !ok { + return fmt.Errorf("field tags in AuctionRequestJson: required") + } + type Plain AuctionRequestJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = AuctionRequestJson(plain) + return nil +} + +type AuctionResponseJson struct { + // A one-time identifier used to target deployments + BidderId string `json:"bidder_id"` + + // The number of agents running and their workload counts + Status AuctionResponseJsonStatus `json:"status"` + + // Tags corresponds to the JSON schema field "tags". + Tags AuctionResponseJsonTags `json:"tags"` + + // The target nodes xkey + TargetXkey string `json:"target_xkey"` + + // The uptime of the node + Uptime string `json:"uptime"` + + // The version of the node + Version string `json:"version"` +} + +// The number of agents running and their workload counts +type AuctionResponseJsonStatus struct { + // Status corresponds to the JSON schema field "status". + Status AuctionResponseJsonStatusStatus `json:"status,omitempty"` +} + +type AuctionResponseJsonStatusStatus map[string]int + +type AuctionResponseJsonTags struct { + // Tags corresponds to the JSON schema field "tags". + Tags AuctionResponseJsonTagsTags `json:"tags,omitempty"` +} + +type AuctionResponseJsonTagsTags map[string]string + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AuctionResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["bidder_id"]; raw != nil && !ok { + return fmt.Errorf("field bidder_id in AuctionResponseJson: required") + } + if _, ok := raw["status"]; raw != nil && !ok { + return fmt.Errorf("field status in AuctionResponseJson: required") + } + if _, ok := raw["tags"]; raw != nil && !ok { + return fmt.Errorf("field tags in AuctionResponseJson: required") + } + if _, ok := raw["target_xkey"]; raw != nil && !ok { + return fmt.Errorf("field target_xkey in AuctionResponseJson: required") + } + if _, ok := raw["uptime"]; raw != nil && !ok { + return fmt.Errorf("field uptime in AuctionResponseJson: required") + } + if _, ok := raw["version"]; raw != nil && !ok { + return fmt.Errorf("field version in AuctionResponseJson: required") + } + type Plain AuctionResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = AuctionResponseJson(plain) + return nil +} + +type CloneWorkloadRequestJson struct { + // NewTargetXkey corresponds to the JSON schema field "new_target_xkey". + NewTargetXkey string `json:"new_target_xkey"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *CloneWorkloadRequestJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["new_target_xkey"]; raw != nil && !ok { + return fmt.Errorf("field new_target_xkey in CloneWorkloadRequestJson: required") + } + type Plain CloneWorkloadRequestJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = CloneWorkloadRequestJson(plain) + return nil +} + +type CloneWorkloadResponseJson struct { + // StartWorkloadRequest corresponds to the JSON schema field + // "start_workload_request". + StartWorkloadRequest *StartWorkloadRequestJson `json:"start_workload_request,omitempty"` +} + +type NexWorkload string + +type NodeInfoRequestJson struct { + // Namespace of the node + Namespace string `json:"namespace"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *NodeInfoRequestJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["namespace"]; raw != nil && !ok { + return fmt.Errorf("field namespace in NodeInfoRequestJson: required") + } + type Plain NodeInfoRequestJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = NodeInfoRequestJson(plain) + return nil +} + +type NodeInfoResponseJson struct { + // The unique identifier of the node + NodeId string `json:"node_id"` + + // Tags corresponds to the JSON schema field "tags". + Tags NodeInfoResponseJsonTags `json:"tags"` + + // The target nodes xkey + TargetXkey string `json:"target_xkey"` + + // The uptime of the node + Uptime string `json:"uptime"` + + // The version of the node + Version string `json:"version"` + + // WorkloadSummaries corresponds to the JSON schema field "workload_summaries". + WorkloadSummaries []WorkloadSummary `json:"workload_summaries"` +} + +type NodeInfoResponseJsonTags struct { + // Tags corresponds to the JSON schema field "tags". + Tags NodeInfoResponseJsonTagsTags `json:"tags,omitempty"` +} + +type NodeInfoResponseJsonTagsTags map[string]string + +// UnmarshalJSON implements json.Unmarshaler. +func (j *NodeInfoResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["node_id"]; raw != nil && !ok { + return fmt.Errorf("field node_id in NodeInfoResponseJson: required") + } + if _, ok := raw["tags"]; raw != nil && !ok { + return fmt.Errorf("field tags in NodeInfoResponseJson: required") + } + if _, ok := raw["target_xkey"]; raw != nil && !ok { + return fmt.Errorf("field target_xkey in NodeInfoResponseJson: required") + } + if _, ok := raw["uptime"]; raw != nil && !ok { + return fmt.Errorf("field uptime in NodeInfoResponseJson: required") + } + if _, ok := raw["version"]; raw != nil && !ok { + return fmt.Errorf("field version in NodeInfoResponseJson: required") + } + if _, ok := raw["workload_summaries"]; raw != nil && !ok { + return fmt.Errorf("field workload_summaries in NodeInfoResponseJson: required") + } + type Plain NodeInfoResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = NodeInfoResponseJson(plain) + return nil +} + +type NodePingResponseJson struct { + // The unique identifier of the node + NodeId string `json:"node_id"` + + // The number of agents running with workload count + RunningAgents NodePingResponseJsonRunningAgents `json:"running_agents"` + + // Tags corresponds to the JSON schema field "tags". + Tags NodePingResponseJsonTags `json:"tags"` + + // The target nodes xkey + TargetXkey string `json:"target_xkey"` + + // The uptime of the node + Uptime string `json:"uptime"` + + // The version of the node + Version string `json:"version"` +} + +// The number of agents running with workload count +type NodePingResponseJsonRunningAgents struct { + // Status corresponds to the JSON schema field "status". + Status NodePingResponseJsonRunningAgentsStatus `json:"status,omitempty"` +} + +type NodePingResponseJsonRunningAgentsStatus map[string]int + +type NodePingResponseJsonTags struct { + // Tags corresponds to the JSON schema field "tags". + Tags NodePingResponseJsonTagsTags `json:"tags,omitempty"` +} + +type NodePingResponseJsonTagsTags map[string]string + +// UnmarshalJSON implements json.Unmarshaler. +func (j *NodePingResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["node_id"]; raw != nil && !ok { + return fmt.Errorf("field node_id in NodePingResponseJson: required") + } + if _, ok := raw["running_agents"]; raw != nil && !ok { + return fmt.Errorf("field running_agents in NodePingResponseJson: required") + } + if _, ok := raw["tags"]; raw != nil && !ok { + return fmt.Errorf("field tags in NodePingResponseJson: required") + } + if _, ok := raw["target_xkey"]; raw != nil && !ok { + return fmt.Errorf("field target_xkey in NodePingResponseJson: required") + } + if _, ok := raw["uptime"]; raw != nil && !ok { + return fmt.Errorf("field uptime in NodePingResponseJson: required") + } + if _, ok := raw["version"]; raw != nil && !ok { + return fmt.Errorf("field version in NodePingResponseJson: required") + } + type Plain NodePingResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = NodePingResponseJson(plain) + return nil +} + +type WorkloadSummary struct { + // The unique identifier of the workload + Id string `json:"id"` + + // The name of the workload + Name string `json:"name"` + + // The runtime of the workload + Runtime string `json:"runtime"` + + // The start time of the workload + StartTime string `json:"start_time"` + + // The runtype/lifecycle of the workload + WorkloadRuntype string `json:"workload_runtype"` + + // The state of the workload + WorkloadState string `json:"workload_state"` + + // The type of the workload + WorkloadType string `json:"workload_type"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *WorkloadSummary) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in WorkloadSummary: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in WorkloadSummary: required") + } + if _, ok := raw["runtime"]; raw != nil && !ok { + return fmt.Errorf("field runtime in WorkloadSummary: required") + } + if _, ok := raw["start_time"]; raw != nil && !ok { + return fmt.Errorf("field start_time in WorkloadSummary: required") + } + if _, ok := raw["workload_runtype"]; raw != nil && !ok { + return fmt.Errorf("field workload_runtype in WorkloadSummary: required") + } + if _, ok := raw["workload_state"]; raw != nil && !ok { + return fmt.Errorf("field workload_state in WorkloadSummary: required") + } + if _, ok := raw["workload_type"]; raw != nil && !ok { + return fmt.Errorf("field workload_type in WorkloadSummary: required") + } + type Plain WorkloadSummary + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = WorkloadSummary(plain) + return nil +} diff --git a/api/go/shared.go b/api/go/shared.go new file mode 100644 index 00000000..8911d249 --- /dev/null +++ b/api/go/shared.go @@ -0,0 +1,506 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package api + +import "encoding/json" +import "fmt" + +type AgentPingResponseJson struct { + // The unique identifier of the node on which the agent is running + NodeId string `json:"node_id"` + + // RunningWorkloads corresponds to the JSON schema field "running_workloads". + RunningWorkloads []WorkloadPingMachineSummary `json:"running_workloads"` + + // Tags corresponds to the JSON schema field "tags". + Tags AgentPingResponseJsonTags `json:"tags"` + + // The target agents xkey + TargetXkey string `json:"target_xkey"` + + // The uptime of the node + Uptime string `json:"uptime"` + + // The target agents version + Version string `json:"version"` +} + +type AgentPingResponseJsonTags struct { + // Tags corresponds to the JSON schema field "tags". + Tags AgentPingResponseJsonTagsTags `json:"tags,omitempty"` +} + +type AgentPingResponseJsonTagsTags map[string]string + +// UnmarshalJSON implements json.Unmarshaler. +func (j *AgentPingResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["node_id"]; raw != nil && !ok { + return fmt.Errorf("field node_id in AgentPingResponseJson: required") + } + if _, ok := raw["running_workloads"]; raw != nil && !ok { + return fmt.Errorf("field running_workloads in AgentPingResponseJson: required") + } + if _, ok := raw["tags"]; raw != nil && !ok { + return fmt.Errorf("field tags in AgentPingResponseJson: required") + } + if _, ok := raw["target_xkey"]; raw != nil && !ok { + return fmt.Errorf("field target_xkey in AgentPingResponseJson: required") + } + if _, ok := raw["uptime"]; raw != nil && !ok { + return fmt.Errorf("field uptime in AgentPingResponseJson: required") + } + if _, ok := raw["version"]; raw != nil && !ok { + return fmt.Errorf("field version in AgentPingResponseJson: required") + } + type Plain AgentPingResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = AgentPingResponseJson(plain) + return nil +} + +type LameduckRequestJson struct { + // Time delay before lameduck mode is set + Delay string `json:"delay"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *LameduckRequestJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["delay"]; raw != nil && !ok { + return fmt.Errorf("field delay in LameduckRequestJson: required") + } + type Plain LameduckRequestJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = LameduckRequestJson(plain) + return nil +} + +type LameduckResponseJson struct { + // Indicates lameduck mode successfully set + Success bool `json:"success"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *LameduckResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["success"]; raw != nil && !ok { + return fmt.Errorf("field success in LameduckResponseJson: required") + } + type Plain LameduckResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = LameduckResponseJson(plain) + return nil +} + +type SharedEncEnvJson struct { + // Base64EncryptedEnv corresponds to the JSON schema field "base64_encrypted_env". + Base64EncryptedEnv string `json:"base64_encrypted_env"` + + // EncryptedBy corresponds to the JSON schema field "encrypted_by". + EncryptedBy string `json:"encrypted_by"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SharedEncEnvJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["base64_encrypted_env"]; raw != nil && !ok { + return fmt.Errorf("field base64_encrypted_env in SharedEncEnvJson: required") + } + if _, ok := raw["encrypted_by"]; raw != nil && !ok { + return fmt.Errorf("field encrypted_by in SharedEncEnvJson: required") + } + type Plain SharedEncEnvJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = SharedEncEnvJson(plain) + return nil +} + +type SharedHostServiceJson struct { + // NatsUrl corresponds to the JSON schema field "nats_url". + NatsUrl string `json:"nats_url"` + + // NatsUserJwt corresponds to the JSON schema field "nats_user_jwt". + NatsUserJwt string `json:"nats_user_jwt"` + + // NatsUserSeed corresponds to the JSON schema field "nats_user_seed". + NatsUserSeed string `json:"nats_user_seed"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *SharedHostServiceJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["nats_url"]; raw != nil && !ok { + return fmt.Errorf("field nats_url in SharedHostServiceJson: required") + } + if _, ok := raw["nats_user_jwt"]; raw != nil && !ok { + return fmt.Errorf("field nats_user_jwt in SharedHostServiceJson: required") + } + if _, ok := raw["nats_user_seed"]; raw != nil && !ok { + return fmt.Errorf("field nats_user_seed in SharedHostServiceJson: required") + } + type Plain SharedHostServiceJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = SharedHostServiceJson(plain) + return nil +} + +type StartWorkloadRequestJson struct { + // Arguments to be passed to the binary + Argv []string `json:"argv"` + + // A description of the workload + Description string `json:"description"` + + // The base64-encoded byte array of the encrypted environment with public key of + // encryptor + EncEnvironment SharedEncEnvJson `json:"enc_environment"` + + // The hash of the workload + Hash string `json:"hash"` + + // The NATS configuration for the host services + HostServiceConfig SharedHostServiceJson `json:"host_service_config"` + + // The NATS JSDomain for the workload + Jsdomain string `json:"jsdomain"` + + // The namespace of the workload + Namespace string `json:"namespace"` + + // The number of times the workload has been retried + RetryCount int `json:"retry_count"` + + // The public key of the sender + SenderPublicKey string `json:"sender_public_key"` + + // The xkey of the target node + TargetPubXkey string `json:"target_pub_xkey"` + + // The subject that triggers the workload + TriggerSubject string `json:"trigger_subject"` + + // The URI of the workload + Uri string `json:"uri"` + + // The JWT for the workload + WorkloadJwt string `json:"workload_jwt"` + + // The name of the workload + WorkloadName string `json:"workload_name"` + + // The runtype of the workload + WorkloadRuntype string `json:"workload_runtype"` + + // The type of the workload + WorkloadType string `json:"workload_type"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *StartWorkloadRequestJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["argv"]; raw != nil && !ok { + return fmt.Errorf("field argv in StartWorkloadRequestJson: required") + } + if _, ok := raw["description"]; raw != nil && !ok { + return fmt.Errorf("field description in StartWorkloadRequestJson: required") + } + if _, ok := raw["enc_environment"]; raw != nil && !ok { + return fmt.Errorf("field enc_environment in StartWorkloadRequestJson: required") + } + if _, ok := raw["hash"]; raw != nil && !ok { + return fmt.Errorf("field hash in StartWorkloadRequestJson: required") + } + if _, ok := raw["host_service_config"]; raw != nil && !ok { + return fmt.Errorf("field host_service_config in StartWorkloadRequestJson: required") + } + if _, ok := raw["jsdomain"]; raw != nil && !ok { + return fmt.Errorf("field jsdomain in StartWorkloadRequestJson: required") + } + if _, ok := raw["namespace"]; raw != nil && !ok { + return fmt.Errorf("field namespace in StartWorkloadRequestJson: required") + } + if _, ok := raw["retry_count"]; raw != nil && !ok { + return fmt.Errorf("field retry_count in StartWorkloadRequestJson: required") + } + if _, ok := raw["sender_public_key"]; raw != nil && !ok { + return fmt.Errorf("field sender_public_key in StartWorkloadRequestJson: required") + } + if _, ok := raw["target_pub_xkey"]; raw != nil && !ok { + return fmt.Errorf("field target_pub_xkey in StartWorkloadRequestJson: required") + } + if _, ok := raw["trigger_subject"]; raw != nil && !ok { + return fmt.Errorf("field trigger_subject in StartWorkloadRequestJson: required") + } + if _, ok := raw["uri"]; raw != nil && !ok { + return fmt.Errorf("field uri in StartWorkloadRequestJson: required") + } + if _, ok := raw["workload_jwt"]; raw != nil && !ok { + return fmt.Errorf("field workload_jwt in StartWorkloadRequestJson: required") + } + if _, ok := raw["workload_name"]; raw != nil && !ok { + return fmt.Errorf("field workload_name in StartWorkloadRequestJson: required") + } + if _, ok := raw["workload_runtype"]; raw != nil && !ok { + return fmt.Errorf("field workload_runtype in StartWorkloadRequestJson: required") + } + if _, ok := raw["workload_type"]; raw != nil && !ok { + return fmt.Errorf("field workload_type in StartWorkloadRequestJson: required") + } + type Plain StartWorkloadRequestJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = StartWorkloadRequestJson(plain) + return nil +} + +type StartWorkloadResponseJson struct { + // Id corresponds to the JSON schema field "id". + Id string `json:"id"` + + // Issuer corresponds to the JSON schema field "issuer". + Issuer string `json:"issuer"` + + // Message corresponds to the JSON schema field "message". + Message string `json:"message"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name"` + + // Started corresponds to the JSON schema field "started". + Started bool `json:"started"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *StartWorkloadResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in StartWorkloadResponseJson: required") + } + if _, ok := raw["issuer"]; raw != nil && !ok { + return fmt.Errorf("field issuer in StartWorkloadResponseJson: required") + } + if _, ok := raw["message"]; raw != nil && !ok { + return fmt.Errorf("field message in StartWorkloadResponseJson: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in StartWorkloadResponseJson: required") + } + if _, ok := raw["started"]; raw != nil && !ok { + return fmt.Errorf("field started in StartWorkloadResponseJson: required") + } + type Plain StartWorkloadResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = StartWorkloadResponseJson(plain) + return nil +} + +type StopWorkloadRequestJson struct { + // Namespace corresponds to the JSON schema field "namespace". + Namespace string `json:"namespace"` + + // WorkloadId corresponds to the JSON schema field "workload_id". + WorkloadId string `json:"workload_id"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *StopWorkloadRequestJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["namespace"]; raw != nil && !ok { + return fmt.Errorf("field namespace in StopWorkloadRequestJson: required") + } + if _, ok := raw["workload_id"]; raw != nil && !ok { + return fmt.Errorf("field workload_id in StopWorkloadRequestJson: required") + } + type Plain StopWorkloadRequestJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = StopWorkloadRequestJson(plain) + return nil +} + +type StopWorkloadResponseJson struct { + // Id corresponds to the JSON schema field "id". + Id string `json:"id"` + + // Issuer corresponds to the JSON schema field "issuer". + Issuer string `json:"issuer"` + + // Message corresponds to the JSON schema field "message". + Message string `json:"message"` + + // Stopped corresponds to the JSON schema field "stopped". + Stopped bool `json:"stopped"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *StopWorkloadResponseJson) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in StopWorkloadResponseJson: required") + } + if _, ok := raw["issuer"]; raw != nil && !ok { + return fmt.Errorf("field issuer in StopWorkloadResponseJson: required") + } + if _, ok := raw["message"]; raw != nil && !ok { + return fmt.Errorf("field message in StopWorkloadResponseJson: required") + } + if _, ok := raw["stopped"]; raw != nil && !ok { + return fmt.Errorf("field stopped in StopWorkloadResponseJson: required") + } + type Plain StopWorkloadResponseJson + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = StopWorkloadResponseJson(plain) + return nil +} + +type Workload struct { + // The unique identifier of the workload + Id string `json:"id"` + + // The name of the workload + Name string `json:"name"` + + // The runtime of the workload + Runtime string `json:"runtime"` + + // The start time of the workload + StartTime string `json:"start_time"` + + // The runtype/lifecycle of the workload + WorkloadRuntype string `json:"workload_runtype"` + + // The state of the workload + WorkloadState string `json:"workload_state"` + + // The type of the workload + WorkloadType string `json:"workload_type"` +} + +type WorkloadPingMachineSummary struct { + // Id corresponds to the JSON schema field "id". + Id string `json:"id"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name"` + + // Namespace corresponds to the JSON schema field "namespace". + Namespace string `json:"namespace"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *WorkloadPingMachineSummary) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in WorkloadPingMachineSummary: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in WorkloadPingMachineSummary: required") + } + if _, ok := raw["namespace"]; raw != nil && !ok { + return fmt.Errorf("field namespace in WorkloadPingMachineSummary: required") + } + type Plain WorkloadPingMachineSummary + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = WorkloadPingMachineSummary(plain) + return nil +} + +type WorkloadPingResponseJson struct { + // WorkloadSummary corresponds to the JSON schema field "workload_summary". + WorkloadSummary *Workload `json:"workload_summary,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *Workload) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if _, ok := raw["id"]; raw != nil && !ok { + return fmt.Errorf("field id in Workload: required") + } + if _, ok := raw["name"]; raw != nil && !ok { + return fmt.Errorf("field name in Workload: required") + } + if _, ok := raw["runtime"]; raw != nil && !ok { + return fmt.Errorf("field runtime in Workload: required") + } + if _, ok := raw["start_time"]; raw != nil && !ok { + return fmt.Errorf("field start_time in Workload: required") + } + if _, ok := raw["workload_runtype"]; raw != nil && !ok { + return fmt.Errorf("field workload_runtype in Workload: required") + } + if _, ok := raw["workload_state"]; raw != nil && !ok { + return fmt.Errorf("field workload_state in Workload: required") + } + if _, ok := raw["workload_type"]; raw != nil && !ok { + return fmt.Errorf("field workload_type in Workload: required") + } + type Plain Workload + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = Workload(plain) + return nil +} diff --git a/api/heartbeat-agent.json b/api/heartbeat-agent.json new file mode 100644 index 00000000..453cc6c0 --- /dev/null +++ b/api/heartbeat-agent.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "io.nats.nex.v2.agent_heartbeat", + "title": "AgentHeartbeat", + "type": "object", + "properties": { + }, + "required": [], + "additionalProperties": false +} diff --git a/api/nodecontrol/lameduck-request.json b/api/lameduck-request.json similarity index 100% rename from api/nodecontrol/lameduck-request.json rename to api/lameduck-request.json diff --git a/api/nodecontrol/lameduck-response.json b/api/lameduck-response.json similarity index 100% rename from api/nodecontrol/lameduck-response.json rename to api/lameduck-response.json diff --git a/api/nodecontrol/node-info-request.json b/api/node-info-request.json similarity index 100% rename from api/nodecontrol/node-info-request.json rename to api/node-info-request.json diff --git a/api/nodecontrol/node-info-response.json b/api/node-info-response.json similarity index 100% rename from api/nodecontrol/node-info-response.json rename to api/node-info-response.json diff --git a/api/nodecontrol/node-ping-response.json b/api/node-ping-response.json similarity index 100% rename from api/nodecontrol/node-ping-response.json rename to api/node-ping-response.json diff --git a/api/nodecontrol/gen/agent_ping_response.go b/api/nodecontrol/gen/agent_ping_response.go deleted file mode 100644 index 9c238874..00000000 --- a/api/nodecontrol/gen/agent_ping_response.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type AgentPingResponseJson struct { - // The unique identifier of the node on which the agent is running - NodeId string `json:"node_id"` - - // RunningWorkloads corresponds to the JSON schema field "running_workloads". - RunningWorkloads []WorkloadPingMachineSummary `json:"running_workloads"` - - // Tags corresponds to the JSON schema field "tags". - Tags AgentPingResponseJsonTags `json:"tags"` - - // The target agents xkey - TargetXkey string `json:"target_xkey"` - - // The uptime of the node - Uptime string `json:"uptime"` - - // The target agents version - Version string `json:"version"` -} - -type AgentPingResponseJsonTags struct { - // Tags corresponds to the JSON schema field "tags". - Tags AgentPingResponseJsonTagsTags `json:"tags,omitempty"` -} - -type AgentPingResponseJsonTagsTags map[string]string - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AgentPingResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["node_id"]; raw != nil && !ok { - return fmt.Errorf("field node_id in AgentPingResponseJson: required") - } - if _, ok := raw["running_workloads"]; raw != nil && !ok { - return fmt.Errorf("field running_workloads in AgentPingResponseJson: required") - } - if _, ok := raw["tags"]; raw != nil && !ok { - return fmt.Errorf("field tags in AgentPingResponseJson: required") - } - if _, ok := raw["target_xkey"]; raw != nil && !ok { - return fmt.Errorf("field target_xkey in AgentPingResponseJson: required") - } - if _, ok := raw["uptime"]; raw != nil && !ok { - return fmt.Errorf("field uptime in AgentPingResponseJson: required") - } - if _, ok := raw["version"]; raw != nil && !ok { - return fmt.Errorf("field version in AgentPingResponseJson: required") - } - type Plain AgentPingResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = AgentPingResponseJson(plain) - return nil -} - -type WorkloadPingMachineSummary struct { - // Id corresponds to the JSON schema field "id". - Id string `json:"id"` - - // Name corresponds to the JSON schema field "name". - Name string `json:"name"` - - // Namespace corresponds to the JSON schema field "namespace". - Namespace string `json:"namespace"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *WorkloadPingMachineSummary) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in WorkloadPingMachineSummary: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in WorkloadPingMachineSummary: required") - } - if _, ok := raw["namespace"]; raw != nil && !ok { - return fmt.Errorf("field namespace in WorkloadPingMachineSummary: required") - } - type Plain WorkloadPingMachineSummary - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = WorkloadPingMachineSummary(plain) - return nil -} diff --git a/api/nodecontrol/gen/auction_request.go b/api/nodecontrol/gen/auction_request.go deleted file mode 100644 index e2c6f713..00000000 --- a/api/nodecontrol/gen/auction_request.go +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type AuctionRequestJson struct { - // The type of agent to auction for - AgentType []NexWorkload `json:"agent_type,omitempty"` - - // A unique identifier for the auction - AuctionId string `json:"auction_id"` - - // A list of tags to associate with the node during auction. To be returned, node - // must satisfy ALL tags - Tags AuctionRequestJsonTags `json:"tags"` -} - -// A list of tags to associate with the node during auction. To be returned, node -// must satisfy ALL tags -type AuctionRequestJsonTags struct { - // Tags corresponds to the JSON schema field "tags". - Tags AuctionRequestJsonTagsTags `json:"tags,omitempty"` -} - -type AuctionRequestJsonTagsTags map[string]string - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AuctionRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["auction_id"]; raw != nil && !ok { - return fmt.Errorf("field auction_id in AuctionRequestJson: required") - } - if _, ok := raw["tags"]; raw != nil && !ok { - return fmt.Errorf("field tags in AuctionRequestJson: required") - } - type Plain AuctionRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = AuctionRequestJson(plain) - return nil -} - -type NexWorkload string diff --git a/api/nodecontrol/gen/auction_response.go b/api/nodecontrol/gen/auction_response.go deleted file mode 100644 index e886d346..00000000 --- a/api/nodecontrol/gen/auction_response.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type AuctionResponseJson struct { - // A one-time identifier used to target deployments - BidderId string `json:"bidder_id"` - - // The number of agents running and their workload counts - Status AuctionResponseJsonStatus `json:"status"` - - // Tags corresponds to the JSON schema field "tags". - Tags AuctionResponseJsonTags `json:"tags"` - - // The target nodes xkey - TargetXkey string `json:"target_xkey"` - - // The uptime of the node - Uptime string `json:"uptime"` - - // The version of the node - Version string `json:"version"` -} - -// The number of agents running and their workload counts -type AuctionResponseJsonStatus struct { - // Status corresponds to the JSON schema field "status". - Status AuctionResponseJsonStatusStatus `json:"status,omitempty"` -} - -type AuctionResponseJsonStatusStatus map[string]int - -type AuctionResponseJsonTags struct { - // Tags corresponds to the JSON schema field "tags". - Tags AuctionResponseJsonTagsTags `json:"tags,omitempty"` -} - -type AuctionResponseJsonTagsTags map[string]string - -// UnmarshalJSON implements json.Unmarshaler. -func (j *AuctionResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["bidder_id"]; raw != nil && !ok { - return fmt.Errorf("field bidder_id in AuctionResponseJson: required") - } - if _, ok := raw["status"]; raw != nil && !ok { - return fmt.Errorf("field status in AuctionResponseJson: required") - } - if _, ok := raw["tags"]; raw != nil && !ok { - return fmt.Errorf("field tags in AuctionResponseJson: required") - } - if _, ok := raw["target_xkey"]; raw != nil && !ok { - return fmt.Errorf("field target_xkey in AuctionResponseJson: required") - } - if _, ok := raw["uptime"]; raw != nil && !ok { - return fmt.Errorf("field uptime in AuctionResponseJson: required") - } - if _, ok := raw["version"]; raw != nil && !ok { - return fmt.Errorf("field version in AuctionResponseJson: required") - } - type Plain AuctionResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = AuctionResponseJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/clone_workload_request.go b/api/nodecontrol/gen/clone_workload_request.go deleted file mode 100644 index 8abfea97..00000000 --- a/api/nodecontrol/gen/clone_workload_request.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type CloneWorkloadRequestJson struct { - // NewTargetXkey corresponds to the JSON schema field "new_target_xkey". - NewTargetXkey string `json:"new_target_xkey"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *CloneWorkloadRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["new_target_xkey"]; raw != nil && !ok { - return fmt.Errorf("field new_target_xkey in CloneWorkloadRequestJson: required") - } - type Plain CloneWorkloadRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = CloneWorkloadRequestJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/clone_workload_response.go b/api/nodecontrol/gen/clone_workload_response.go deleted file mode 100644 index da33f6c0..00000000 --- a/api/nodecontrol/gen/clone_workload_response.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -type CloneWorkloadResponseJson struct { - // StartWorkloadRequest corresponds to the JSON schema field - // "start_workload_request". - StartWorkloadRequest *StartWorkloadRequestJson `json:"start_workload_request,omitempty"` -} diff --git a/api/nodecontrol/gen/lameduck_request.go b/api/nodecontrol/gen/lameduck_request.go deleted file mode 100644 index bda678d2..00000000 --- a/api/nodecontrol/gen/lameduck_request.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type LameduckRequestJson struct { - // Time delay before lameduck mode is set - Delay string `json:"delay"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *LameduckRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["delay"]; raw != nil && !ok { - return fmt.Errorf("field delay in LameduckRequestJson: required") - } - type Plain LameduckRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = LameduckRequestJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/lameduck_response.go b/api/nodecontrol/gen/lameduck_response.go deleted file mode 100644 index 61f6bea1..00000000 --- a/api/nodecontrol/gen/lameduck_response.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type LameduckResponseJson struct { - // Indicates lameduck mode successfully set - Success bool `json:"success"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *LameduckResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["success"]; raw != nil && !ok { - return fmt.Errorf("field success in LameduckResponseJson: required") - } - type Plain LameduckResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = LameduckResponseJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/node_info_request.go b/api/nodecontrol/gen/node_info_request.go deleted file mode 100644 index c69de131..00000000 --- a/api/nodecontrol/gen/node_info_request.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type NodeInfoRequestJson struct { - // Namespace of the node - Namespace string `json:"namespace"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *NodeInfoRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["namespace"]; raw != nil && !ok { - return fmt.Errorf("field namespace in NodeInfoRequestJson: required") - } - type Plain NodeInfoRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = NodeInfoRequestJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/node_info_response.go b/api/nodecontrol/gen/node_info_response.go deleted file mode 100644 index 597f43c4..00000000 --- a/api/nodecontrol/gen/node_info_response.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type NodeInfoResponseJson struct { - // The unique identifier of the node - NodeId string `json:"node_id"` - - // Tags corresponds to the JSON schema field "tags". - Tags NodeInfoResponseJsonTags `json:"tags"` - - // The target nodes xkey - TargetXkey string `json:"target_xkey"` - - // The uptime of the node - Uptime string `json:"uptime"` - - // The version of the node - Version string `json:"version"` - - // WorkloadSummaries corresponds to the JSON schema field "workload_summaries". - WorkloadSummaries []WorkloadSummary `json:"workload_summaries"` -} - -type NodeInfoResponseJsonTags struct { - // Tags corresponds to the JSON schema field "tags". - Tags NodeInfoResponseJsonTagsTags `json:"tags,omitempty"` -} - -type NodeInfoResponseJsonTagsTags map[string]string - -// UnmarshalJSON implements json.Unmarshaler. -func (j *NodeInfoResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["node_id"]; raw != nil && !ok { - return fmt.Errorf("field node_id in NodeInfoResponseJson: required") - } - if _, ok := raw["tags"]; raw != nil && !ok { - return fmt.Errorf("field tags in NodeInfoResponseJson: required") - } - if _, ok := raw["target_xkey"]; raw != nil && !ok { - return fmt.Errorf("field target_xkey in NodeInfoResponseJson: required") - } - if _, ok := raw["uptime"]; raw != nil && !ok { - return fmt.Errorf("field uptime in NodeInfoResponseJson: required") - } - if _, ok := raw["version"]; raw != nil && !ok { - return fmt.Errorf("field version in NodeInfoResponseJson: required") - } - if _, ok := raw["workload_summaries"]; raw != nil && !ok { - return fmt.Errorf("field workload_summaries in NodeInfoResponseJson: required") - } - type Plain NodeInfoResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = NodeInfoResponseJson(plain) - return nil -} - -type WorkloadSummary struct { - // The unique identifier of the workload - Id string `json:"id"` - - // The name of the workload - Name string `json:"name"` - - // The runtime of the workload - Runtime string `json:"runtime"` - - // The start time of the workload - StartTime string `json:"start_time"` - - // The runtype/lifecycle of the workload - WorkloadRuntype string `json:"workload_runtype"` - - // The state of the workload - WorkloadState string `json:"workload_state"` - - // The type of the workload - WorkloadType string `json:"workload_type"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *WorkloadSummary) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in WorkloadSummary: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in WorkloadSummary: required") - } - if _, ok := raw["runtime"]; raw != nil && !ok { - return fmt.Errorf("field runtime in WorkloadSummary: required") - } - if _, ok := raw["start_time"]; raw != nil && !ok { - return fmt.Errorf("field start_time in WorkloadSummary: required") - } - if _, ok := raw["workload_runtype"]; raw != nil && !ok { - return fmt.Errorf("field workload_runtype in WorkloadSummary: required") - } - if _, ok := raw["workload_state"]; raw != nil && !ok { - return fmt.Errorf("field workload_state in WorkloadSummary: required") - } - if _, ok := raw["workload_type"]; raw != nil && !ok { - return fmt.Errorf("field workload_type in WorkloadSummary: required") - } - type Plain WorkloadSummary - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = WorkloadSummary(plain) - return nil -} diff --git a/api/nodecontrol/gen/node_ping_response.go b/api/nodecontrol/gen/node_ping_response.go deleted file mode 100644 index bff541d2..00000000 --- a/api/nodecontrol/gen/node_ping_response.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type NodePingResponseJson struct { - // The unique identifier of the node - NodeId string `json:"node_id"` - - // The number of agents running with workload count - RunningAgents NodePingResponseJsonRunningAgents `json:"running_agents"` - - // Tags corresponds to the JSON schema field "tags". - Tags NodePingResponseJsonTags `json:"tags"` - - // The target nodes xkey - TargetXkey string `json:"target_xkey"` - - // The uptime of the node - Uptime string `json:"uptime"` - - // The version of the node - Version string `json:"version"` -} - -// The number of agents running with workload count -type NodePingResponseJsonRunningAgents struct { - // Status corresponds to the JSON schema field "status". - Status NodePingResponseJsonRunningAgentsStatus `json:"status,omitempty"` -} - -type NodePingResponseJsonRunningAgentsStatus map[string]int - -type NodePingResponseJsonTags struct { - // Tags corresponds to the JSON schema field "tags". - Tags NodePingResponseJsonTagsTags `json:"tags,omitempty"` -} - -type NodePingResponseJsonTagsTags map[string]string - -// UnmarshalJSON implements json.Unmarshaler. -func (j *NodePingResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["node_id"]; raw != nil && !ok { - return fmt.Errorf("field node_id in NodePingResponseJson: required") - } - if _, ok := raw["running_agents"]; raw != nil && !ok { - return fmt.Errorf("field running_agents in NodePingResponseJson: required") - } - if _, ok := raw["tags"]; raw != nil && !ok { - return fmt.Errorf("field tags in NodePingResponseJson: required") - } - if _, ok := raw["target_xkey"]; raw != nil && !ok { - return fmt.Errorf("field target_xkey in NodePingResponseJson: required") - } - if _, ok := raw["uptime"]; raw != nil && !ok { - return fmt.Errorf("field uptime in NodePingResponseJson: required") - } - if _, ok := raw["version"]; raw != nil && !ok { - return fmt.Errorf("field version in NodePingResponseJson: required") - } - type Plain NodePingResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = NodePingResponseJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/shared.go b/api/nodecontrol/gen/shared.go deleted file mode 100644 index d1975064..00000000 --- a/api/nodecontrol/gen/shared.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type SharedEncEnvJson struct { - // Base64EncryptedEnv corresponds to the JSON schema field "base64_encrypted_env". - Base64EncryptedEnv string `json:"base64_encrypted_env"` - - // EncryptedBy corresponds to the JSON schema field "encrypted_by". - EncryptedBy string `json:"encrypted_by"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SharedEncEnvJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["base64_encrypted_env"]; raw != nil && !ok { - return fmt.Errorf("field base64_encrypted_env in SharedEncEnvJson: required") - } - if _, ok := raw["encrypted_by"]; raw != nil && !ok { - return fmt.Errorf("field encrypted_by in SharedEncEnvJson: required") - } - type Plain SharedEncEnvJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = SharedEncEnvJson(plain) - return nil -} - -type SharedHostServiceJson struct { - // NatsUrl corresponds to the JSON schema field "nats_url". - NatsUrl string `json:"nats_url"` - - // NatsUserJwt corresponds to the JSON schema field "nats_user_jwt". - NatsUserJwt string `json:"nats_user_jwt"` - - // NatsUserSeed corresponds to the JSON schema field "nats_user_seed". - NatsUserSeed string `json:"nats_user_seed"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *SharedHostServiceJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["nats_url"]; raw != nil && !ok { - return fmt.Errorf("field nats_url in SharedHostServiceJson: required") - } - if _, ok := raw["nats_user_jwt"]; raw != nil && !ok { - return fmt.Errorf("field nats_user_jwt in SharedHostServiceJson: required") - } - if _, ok := raw["nats_user_seed"]; raw != nil && !ok { - return fmt.Errorf("field nats_user_seed in SharedHostServiceJson: required") - } - type Plain SharedHostServiceJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = SharedHostServiceJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/start_workload_request.go b/api/nodecontrol/gen/start_workload_request.go deleted file mode 100644 index e6901d65..00000000 --- a/api/nodecontrol/gen/start_workload_request.go +++ /dev/null @@ -1,120 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type StartWorkloadRequestJson struct { - // Arguments to be passed to the binary - Argv []string `json:"argv"` - - // A description of the workload - Description string `json:"description"` - - // The base64-encoded byte array of the encrypted environment with public key of - // encryptor - EncEnvironment SharedEncEnvJson `json:"enc_environment"` - - // The hash of the workload - Hash string `json:"hash"` - - // The NATS configuration for the host services - HostServiceConfig SharedHostServiceJson `json:"host_service_config"` - - // The NATS JSDomain for the workload - Jsdomain string `json:"jsdomain"` - - // The namespace of the workload - Namespace string `json:"namespace"` - - // The number of times the workload has been retried - RetryCount int `json:"retry_count"` - - // The public key of the sender - SenderPublicKey string `json:"sender_public_key"` - - // The xkey of the target node - TargetPubXkey string `json:"target_pub_xkey"` - - // The subject that triggers the workload - TriggerSubject string `json:"trigger_subject"` - - // The URI of the workload - Uri string `json:"uri"` - - // The JWT for the workload - WorkloadJwt string `json:"workload_jwt"` - - // The name of the workload - WorkloadName string `json:"workload_name"` - - // The runtype of the workload - WorkloadRuntype string `json:"workload_runtype"` - - // The type of the workload - WorkloadType string `json:"workload_type"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *StartWorkloadRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["argv"]; raw != nil && !ok { - return fmt.Errorf("field argv in StartWorkloadRequestJson: required") - } - if _, ok := raw["description"]; raw != nil && !ok { - return fmt.Errorf("field description in StartWorkloadRequestJson: required") - } - if _, ok := raw["enc_environment"]; raw != nil && !ok { - return fmt.Errorf("field enc_environment in StartWorkloadRequestJson: required") - } - if _, ok := raw["hash"]; raw != nil && !ok { - return fmt.Errorf("field hash in StartWorkloadRequestJson: required") - } - if _, ok := raw["host_service_config"]; raw != nil && !ok { - return fmt.Errorf("field host_service_config in StartWorkloadRequestJson: required") - } - if _, ok := raw["jsdomain"]; raw != nil && !ok { - return fmt.Errorf("field jsdomain in StartWorkloadRequestJson: required") - } - if _, ok := raw["namespace"]; raw != nil && !ok { - return fmt.Errorf("field namespace in StartWorkloadRequestJson: required") - } - if _, ok := raw["retry_count"]; raw != nil && !ok { - return fmt.Errorf("field retry_count in StartWorkloadRequestJson: required") - } - if _, ok := raw["sender_public_key"]; raw != nil && !ok { - return fmt.Errorf("field sender_public_key in StartWorkloadRequestJson: required") - } - if _, ok := raw["target_pub_xkey"]; raw != nil && !ok { - return fmt.Errorf("field target_pub_xkey in StartWorkloadRequestJson: required") - } - if _, ok := raw["trigger_subject"]; raw != nil && !ok { - return fmt.Errorf("field trigger_subject in StartWorkloadRequestJson: required") - } - if _, ok := raw["uri"]; raw != nil && !ok { - return fmt.Errorf("field uri in StartWorkloadRequestJson: required") - } - if _, ok := raw["workload_jwt"]; raw != nil && !ok { - return fmt.Errorf("field workload_jwt in StartWorkloadRequestJson: required") - } - if _, ok := raw["workload_name"]; raw != nil && !ok { - return fmt.Errorf("field workload_name in StartWorkloadRequestJson: required") - } - if _, ok := raw["workload_runtype"]; raw != nil && !ok { - return fmt.Errorf("field workload_runtype in StartWorkloadRequestJson: required") - } - if _, ok := raw["workload_type"]; raw != nil && !ok { - return fmt.Errorf("field workload_type in StartWorkloadRequestJson: required") - } - type Plain StartWorkloadRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = StartWorkloadRequestJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/start_workload_response.go b/api/nodecontrol/gen/start_workload_response.go deleted file mode 100644 index edd866a0..00000000 --- a/api/nodecontrol/gen/start_workload_response.go +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type StartWorkloadResponseJson struct { - // Id corresponds to the JSON schema field "id". - Id string `json:"id"` - - // Issuer corresponds to the JSON schema field "issuer". - Issuer string `json:"issuer"` - - // Message corresponds to the JSON schema field "message". - Message string `json:"message"` - - // Name corresponds to the JSON schema field "name". - Name string `json:"name"` - - // Started corresponds to the JSON schema field "started". - Started bool `json:"started"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *StartWorkloadResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in StartWorkloadResponseJson: required") - } - if _, ok := raw["issuer"]; raw != nil && !ok { - return fmt.Errorf("field issuer in StartWorkloadResponseJson: required") - } - if _, ok := raw["message"]; raw != nil && !ok { - return fmt.Errorf("field message in StartWorkloadResponseJson: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in StartWorkloadResponseJson: required") - } - if _, ok := raw["started"]; raw != nil && !ok { - return fmt.Errorf("field started in StartWorkloadResponseJson: required") - } - type Plain StartWorkloadResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = StartWorkloadResponseJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/stop_workload_request.go b/api/nodecontrol/gen/stop_workload_request.go deleted file mode 100644 index 21b83327..00000000 --- a/api/nodecontrol/gen/stop_workload_request.go +++ /dev/null @@ -1,35 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type StopWorkloadRequestJson struct { - // Namespace corresponds to the JSON schema field "namespace". - Namespace string `json:"namespace"` - - // WorkloadId corresponds to the JSON schema field "workload_id". - WorkloadId string `json:"workload_id"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *StopWorkloadRequestJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["namespace"]; raw != nil && !ok { - return fmt.Errorf("field namespace in StopWorkloadRequestJson: required") - } - if _, ok := raw["workload_id"]; raw != nil && !ok { - return fmt.Errorf("field workload_id in StopWorkloadRequestJson: required") - } - type Plain StopWorkloadRequestJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = StopWorkloadRequestJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/stop_workload_response.go b/api/nodecontrol/gen/stop_workload_response.go deleted file mode 100644 index b0c5d76a..00000000 --- a/api/nodecontrol/gen/stop_workload_response.go +++ /dev/null @@ -1,47 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type StopWorkloadResponseJson struct { - // Id corresponds to the JSON schema field "id". - Id string `json:"id"` - - // Issuer corresponds to the JSON schema field "issuer". - Issuer string `json:"issuer"` - - // Message corresponds to the JSON schema field "message". - Message string `json:"message"` - - // Stopped corresponds to the JSON schema field "stopped". - Stopped bool `json:"stopped"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *StopWorkloadResponseJson) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in StopWorkloadResponseJson: required") - } - if _, ok := raw["issuer"]; raw != nil && !ok { - return fmt.Errorf("field issuer in StopWorkloadResponseJson: required") - } - if _, ok := raw["message"]; raw != nil && !ok { - return fmt.Errorf("field message in StopWorkloadResponseJson: required") - } - if _, ok := raw["stopped"]; raw != nil && !ok { - return fmt.Errorf("field stopped in StopWorkloadResponseJson: required") - } - type Plain StopWorkloadResponseJson - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = StopWorkloadResponseJson(plain) - return nil -} diff --git a/api/nodecontrol/gen/workload_ping_response.go b/api/nodecontrol/gen/workload_ping_response.go deleted file mode 100644 index 951b97f8..00000000 --- a/api/nodecontrol/gen/workload_ping_response.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. - -package gen - -import "encoding/json" -import "fmt" - -type Workload struct { - // The unique identifier of the workload - Id string `json:"id"` - - // The name of the workload - Name string `json:"name"` - - // The runtime of the workload - Runtime string `json:"runtime"` - - // The start time of the workload - StartTime string `json:"start_time"` - - // The runtype/lifecycle of the workload - WorkloadRuntype string `json:"workload_runtype"` - - // The state of the workload - WorkloadState string `json:"workload_state"` - - // The type of the workload - WorkloadType string `json:"workload_type"` -} - -type WorkloadPingResponseJson struct { - // WorkloadSummary corresponds to the JSON schema field "workload_summary". - WorkloadSummary *Workload `json:"workload_summary,omitempty"` -} - -// UnmarshalJSON implements json.Unmarshaler. -func (j *Workload) UnmarshalJSON(b []byte) error { - var raw map[string]interface{} - if err := json.Unmarshal(b, &raw); err != nil { - return err - } - if _, ok := raw["id"]; raw != nil && !ok { - return fmt.Errorf("field id in Workload: required") - } - if _, ok := raw["name"]; raw != nil && !ok { - return fmt.Errorf("field name in Workload: required") - } - if _, ok := raw["runtime"]; raw != nil && !ok { - return fmt.Errorf("field runtime in Workload: required") - } - if _, ok := raw["start_time"]; raw != nil && !ok { - return fmt.Errorf("field start_time in Workload: required") - } - if _, ok := raw["workload_runtype"]; raw != nil && !ok { - return fmt.Errorf("field workload_runtype in Workload: required") - } - if _, ok := raw["workload_state"]; raw != nil && !ok { - return fmt.Errorf("field workload_state in Workload: required") - } - if _, ok := raw["workload_type"]; raw != nil && !ok { - return fmt.Errorf("field workload_type in Workload: required") - } - type Plain Workload - var plain Plain - if err := json.Unmarshal(b, &plain); err != nil { - return err - } - *j = Workload(plain) - return nil -} diff --git a/api/agent/register-agent-request.json b/api/register-agent-request.json similarity index 90% rename from api/agent/register-agent-request.json rename to api/register-agent-request.json index 6aac0f5d..037e2700 100644 --- a/api/agent/register-agent-request.json +++ b/api/register-agent-request.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://github.com/synadia-io/nex/api/agent/register-agent-request", + "$id": "io.nats.nex.v2.agent_register_request", "title": "RegisterAgentRequest", "type": "object", "properties": { diff --git a/api/register-agent-response.json b/api/register-agent-response.json new file mode 100644 index 00000000..65bd5d5c --- /dev/null +++ b/api/register-agent-response.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "io.nats.nex.v2.agent_register_response", + "title": "RegisterAgentResponse", + "type": "object", + "properties": { + }, + "required": [], + "additionalProperties": false +} diff --git a/api/nodecontrol/shared-enc-env.json b/api/shared-enc-env.json similarity index 100% rename from api/nodecontrol/shared-enc-env.json rename to api/shared-enc-env.json diff --git a/api/nodecontrol/shared-host-service.json b/api/shared-host-service.json similarity index 100% rename from api/nodecontrol/shared-host-service.json rename to api/shared-host-service.json diff --git a/api/nodecontrol/start-workload-request.json b/api/start-workload-request.json similarity index 100% rename from api/nodecontrol/start-workload-request.json rename to api/start-workload-request.json diff --git a/api/nodecontrol/start-workload-response.json b/api/start-workload-response.json similarity index 100% rename from api/nodecontrol/start-workload-response.json rename to api/start-workload-response.json diff --git a/api/nodecontrol/stop-workload-request.json b/api/stop-workload-request.json similarity index 100% rename from api/nodecontrol/stop-workload-request.json rename to api/stop-workload-request.json diff --git a/api/nodecontrol/stop-workload-response.json b/api/stop-workload-response.json similarity index 100% rename from api/nodecontrol/stop-workload-response.json rename to api/stop-workload-response.json diff --git a/api/nodecontrol/workload-ping-response.json b/api/workload-ping-response.json similarity index 100% rename from api/nodecontrol/workload-ping-response.json rename to api/workload-ping-response.json diff --git a/cmd/nex/monitor.go b/cmd/nex/monitor.go index 72ce4a27..53480b05 100644 --- a/cmd/nex/monitor.go +++ b/cmd/nex/monitor.go @@ -7,7 +7,7 @@ import ( "os/signal" "time" - "github.com/synadia-io/nex/api/nodecontrol" + "github.com/synadia-io/nex/api" "golang.org/x/net/context" ) @@ -42,7 +42,7 @@ func (e *Events) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } @@ -100,7 +100,7 @@ func (l *Logs) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } diff --git a/cmd/nex/node.go b/cmd/nex/node.go index 136877a1..b4928657 100644 --- a/cmd/nex/node.go +++ b/cmd/nex/node.go @@ -16,8 +16,8 @@ import ( "github.com/nats-io/nkeys" "github.com/nats-io/natscli/columns" - "github.com/synadia-io/nex/api/nodecontrol" - "github.com/synadia-io/nex/api/nodecontrol/gen" + "github.com/synadia-io/nex/api" + gen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" options "github.com/synadia-io/nex/models" "github.com/synadia-io/nex/node" @@ -140,7 +140,7 @@ func (l LameDuck) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdout, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdout, nil))) if err != nil { return err } @@ -185,7 +185,7 @@ func (l List) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdout, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdout, nil))) if err != nil { return err } @@ -278,7 +278,7 @@ func (i Info) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdout, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdout, nil))) if err != nil { return err } diff --git a/cmd/nex/workload.go b/cmd/nex/workload.go index c0248707..69b412cb 100644 --- a/cmd/nex/workload.go +++ b/cmd/nex/workload.go @@ -21,8 +21,8 @@ import ( "time" "github.com/jedib0t/go-pretty/v6/table" - "github.com/synadia-io/nex/api/nodecontrol" - "github.com/synadia-io/nex/api/nodecontrol/gen" + "github.com/synadia-io/nex/api" + gen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" "github.com/nats-io/nats.go" @@ -130,7 +130,7 @@ func (r RunWorkload) Run(ctx context.Context, globals *Globals, w *Workload) err return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } @@ -278,7 +278,7 @@ func (s StopWorkload) Run(ctx context.Context, globals *Globals, w *Workload) er return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } @@ -330,7 +330,7 @@ func (i InfoWorkload) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } @@ -404,7 +404,7 @@ func (l ListWorkload) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } @@ -485,7 +485,7 @@ func (c CopyWorkload) Run(ctx context.Context, globals *Globals) error { return err } - controller, err := nodecontrol.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) + controller, err := api.NewControlApiClient(nc, slog.New(slog.NewTextHandler(os.Stdin, nil))) if err != nil { return err } diff --git a/node/internal/actors/control_api.go b/node/internal/actors/control_api.go index 322048ec..8acb7b03 100644 --- a/node/internal/actors/control_api.go +++ b/node/internal/actors/control_api.go @@ -18,7 +18,7 @@ import ( "github.com/tochemey/goakt/v2/goaktpb" "google.golang.org/protobuf/reflect/protoreflect" - nodegen "github.com/synadia-io/nex/api/nodecontrol/gen" + nodegen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" actorproto "github.com/synadia-io/nex/node/internal/actors/pb" ) diff --git a/node/internal/actors/control_api_conversions.go b/node/internal/actors/control_api_conversions.go index 42b29fb8..fabcf5de 100644 --- a/node/internal/actors/control_api_conversions.go +++ b/node/internal/actors/control_api_conversions.go @@ -3,8 +3,7 @@ package actors import ( "time" - "github.com/synadia-io/nex/api/nodecontrol/gen" - api "github.com/synadia-io/nex/api/nodecontrol/gen" + api "github.com/synadia-io/nex/api/go" actorproto "github.com/synadia-io/nex/node/internal/actors/pb" ) @@ -78,7 +77,7 @@ func stopResponseFromProto(response *actorproto.WorkloadStopped) *api.StopWorklo func infoResponseFromProto(response *actorproto.NodeInfo) *api.NodeInfoResponseJson { ret := new(api.NodeInfoResponseJson) ret.NodeId = response.Id - ret.Tags = gen.NodeInfoResponseJsonTags{Tags: response.Tags} + ret.Tags = api.NodeInfoResponseJsonTags{Tags: response.Tags} ret.TargetXkey = response.TargetXkey ret.Uptime = response.Uptime ret.Version = response.Version @@ -107,7 +106,7 @@ func auctionResponseFromProto(response *actorproto.AuctionResponse) *api.Auction return &api.AuctionResponseJson{ BidderId: response.BidderId, - Status: gen.AuctionResponseJsonStatus{Status: convertedStatus}, + Status: api.AuctionResponseJsonStatus{Status: convertedStatus}, Tags: api.AuctionResponseJsonTags{Tags: response.Tags}, TargetXkey: response.TargetXkey, Uptime: time.Since(response.StartedAt.AsTime()).String(), diff --git a/test/auction_workload_start_test.go b/test/auction_workload_start_test.go index 987bbfc2..e8077cd6 100644 --- a/test/auction_workload_start_test.go +++ b/test/auction_workload_start_test.go @@ -10,7 +10,7 @@ import ( "time" "github.com/carlmjohnson/be" - "github.com/synadia-io/nex/api/nodecontrol/gen" + gen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" ) diff --git a/test/copy_workload_test.go b/test/copy_workload_test.go index eb417aef..b42140b3 100644 --- a/test/copy_workload_test.go +++ b/test/copy_workload_test.go @@ -14,7 +14,7 @@ import ( "github.com/carlmjohnson/be" "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" - "github.com/synadia-io/nex/api/nodecontrol/gen" + gen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" ) diff --git a/test/node_test.go b/test/node_test.go index 890df356..f1a2856a 100644 --- a/test/node_test.go +++ b/test/node_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/carlmjohnson/be" - "github.com/synadia-io/nex/api/nodecontrol/gen" + gen "github.com/synadia-io/nex/api/go" ) func TestStartNode(t *testing.T) { diff --git a/test/workload_test.go b/test/workload_test.go index d0ac3d8b..809cb1f2 100644 --- a/test/workload_test.go +++ b/test/workload_test.go @@ -17,7 +17,7 @@ import ( "github.com/carlmjohnson/be" "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" - "github.com/synadia-io/nex/api/nodecontrol/gen" + gen "github.com/synadia-io/nex/api/go" "github.com/synadia-io/nex/models" )