mirror of
https://github.com/openziti/zrok.git
synced 2025-06-21 18:21:34 +02:00
ham-fisted, manually wired... but working (#967)
This commit is contained in:
parent
2cecf14143
commit
a7899b3a98
40
controller/agentStatus.go
Normal file
40
controller/agentStatus.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/go-openapi/runtime/middleware"
|
||||||
|
"github.com/openziti/zrok/agent/agentGrpc"
|
||||||
|
"github.com/openziti/zrok/controller/agentController"
|
||||||
|
"github.com/openziti/zrok/controller/config"
|
||||||
|
"github.com/openziti/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti/zrok/rest_server_zrok/operations/agent"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type agentStatusHandler struct {
|
||||||
|
cfg *config.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAgentStatusHandler(cfg *config.Config) *agentStatusHandler {
|
||||||
|
return &agentStatusHandler{cfg: cfg}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *agentStatusHandler) Handle(params agent.AgentStatusParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||||
|
if h.cfg.AgentController != nil {
|
||||||
|
acli, aconn, err := agentController.NewAgentClient(params.Body.EnvZID, h.cfg.AgentController)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("error creating agent client for '%v' (%v): %v", params.Body.EnvZID, principal.Email, err)
|
||||||
|
return agent.NewAgentStatusInternalServerError()
|
||||||
|
}
|
||||||
|
defer aconn.Close()
|
||||||
|
|
||||||
|
resp, err := acli.Version(context.Background(), &agentGrpc.VersionRequest{})
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("error retrieving agent version for '%v' (%v): %v", params.Body.EnvZID, principal.Email, err)
|
||||||
|
return agent.NewAgentStatusInternalServerError()
|
||||||
|
}
|
||||||
|
|
||||||
|
return agent.NewAgentStatusOK().WithPayload(&agent.AgentStatusOKBody{Version: resp.V})
|
||||||
|
}
|
||||||
|
return agent.NewAgentStatusUnauthorized()
|
||||||
|
}
|
@ -65,6 +65,7 @@ func Run(inCfg *config.Config) error {
|
|||||||
api.AdminListOrganizationsHandler = newListOrganizationsHandler()
|
api.AdminListOrganizationsHandler = newListOrganizationsHandler()
|
||||||
api.AdminRemoveOrganizationMemberHandler = newRemoveOrganizationMemberHandler()
|
api.AdminRemoveOrganizationMemberHandler = newRemoveOrganizationMemberHandler()
|
||||||
api.AdminUpdateFrontendHandler = newUpdateFrontendHandler()
|
api.AdminUpdateFrontendHandler = newUpdateFrontendHandler()
|
||||||
|
api.AgentAgentStatusHandler = newAgentStatusHandler(cfg)
|
||||||
api.EnvironmentEnableHandler = newEnableHandler()
|
api.EnvironmentEnableHandler = newEnableHandler()
|
||||||
api.EnvironmentDisableHandler = newDisableHandler()
|
api.EnvironmentDisableHandler = newDisableHandler()
|
||||||
api.MetadataConfigurationHandler = newConfigurationHandler(cfg)
|
api.MetadataConfigurationHandler = newConfigurationHandler(cfg)
|
||||||
|
@ -279,6 +279,9 @@ type AgentStatusOKBody struct {
|
|||||||
|
|
||||||
// shares
|
// shares
|
||||||
Shares []*rest_model_zrok.Share `json:"shares"`
|
Shares []*rest_model_zrok.Share `json:"shares"`
|
||||||
|
|
||||||
|
// version
|
||||||
|
Version string `json:"version,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this agent status o k body
|
// Validate validates this agent status o k body
|
||||||
|
@ -219,6 +219,9 @@ func init() {
|
|||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/share"
|
"$ref": "#/definitions/share"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2577,6 +2580,9 @@ func init() {
|
|||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/share"
|
"$ref": "#/definitions/share"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,9 @@ type AgentStatusOKBody struct {
|
|||||||
|
|
||||||
// shares
|
// shares
|
||||||
Shares []*rest_model_zrok.Share `json:"shares"`
|
Shares []*rest_model_zrok.Share `json:"shares"`
|
||||||
|
|
||||||
|
// version
|
||||||
|
Version string `json:"version,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate validates this agent status o k body
|
// Validate validates this agent status o k body
|
||||||
|
@ -27,6 +27,12 @@ import {
|
|||||||
* @interface AgentStatus200Response
|
* @interface AgentStatus200Response
|
||||||
*/
|
*/
|
||||||
export interface AgentStatus200Response {
|
export interface AgentStatus200Response {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AgentStatus200Response
|
||||||
|
*/
|
||||||
|
version?: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<Share>}
|
* @type {Array<Share>}
|
||||||
@ -52,6 +58,7 @@ export function AgentStatus200ResponseFromJSONTyped(json: any, ignoreDiscriminat
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
'version': json['version'] == null ? undefined : json['version'],
|
||||||
'shares': json['shares'] == null ? undefined : ((json['shares'] as Array<any>).map(ShareFromJSON)),
|
'shares': json['shares'] == null ? undefined : ((json['shares'] as Array<any>).map(ShareFromJSON)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -67,6 +74,7 @@ export function AgentStatus200ResponseToJSONTyped(value?: AgentStatus200Response
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
'version': value['version'],
|
||||||
'shares': value['shares'] == null ? undefined : ((value['shares'] as Array<any>).map(ShareToJSON)),
|
'shares': value['shares'] == null ? undefined : ((value['shares'] as Array<any>).map(ShareToJSON)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**version** | **str** | | [optional]
|
||||||
**shares** | [**List[Share]**](Share.md) | | [optional]
|
**shares** | [**List[Share]**](Share.md) | | [optional]
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
@ -35,6 +35,7 @@ class TestAgentStatus200Response(unittest.TestCase):
|
|||||||
model = AgentStatus200Response()
|
model = AgentStatus200Response()
|
||||||
if include_optional:
|
if include_optional:
|
||||||
return AgentStatus200Response(
|
return AgentStatus200Response(
|
||||||
|
version = '',
|
||||||
shares = [
|
shares = [
|
||||||
zrok_api.models.share.share(
|
zrok_api.models.share.share(
|
||||||
share_token = '',
|
share_token = '',
|
||||||
|
@ -17,7 +17,7 @@ import pprint
|
|||||||
import re # noqa: F401
|
import re # noqa: F401
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||||
from typing import Any, ClassVar, Dict, List, Optional
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
from zrok_api.models.share import Share
|
from zrok_api.models.share import Share
|
||||||
from typing import Optional, Set
|
from typing import Optional, Set
|
||||||
@ -27,8 +27,9 @@ class AgentStatus200Response(BaseModel):
|
|||||||
"""
|
"""
|
||||||
AgentStatus200Response
|
AgentStatus200Response
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
|
version: Optional[StrictStr] = None
|
||||||
shares: Optional[List[Share]] = None
|
shares: Optional[List[Share]] = None
|
||||||
__properties: ClassVar[List[str]] = ["shares"]
|
__properties: ClassVar[List[str]] = ["version", "shares"]
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
populate_by_name=True,
|
populate_by_name=True,
|
||||||
@ -88,6 +89,7 @@ class AgentStatus200Response(BaseModel):
|
|||||||
return cls.model_validate(obj)
|
return cls.model_validate(obj)
|
||||||
|
|
||||||
_obj = cls.model_validate({
|
_obj = cls.model_validate({
|
||||||
|
"version": obj.get("version"),
|
||||||
"shares": [Share.from_dict(_item) for _item in obj["shares"]] if obj.get("shares") is not None else None
|
"shares": [Share.from_dict(_item) for _item in obj["shares"]] if obj.get("shares") is not None else None
|
||||||
})
|
})
|
||||||
return _obj
|
return _obj
|
||||||
|
@ -635,6 +635,8 @@ paths:
|
|||||||
description: ok
|
description: ok
|
||||||
schema:
|
schema:
|
||||||
properties:
|
properties:
|
||||||
|
version:
|
||||||
|
type: string
|
||||||
shares:
|
shares:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
@ -27,6 +27,12 @@ import {
|
|||||||
* @interface AgentStatus200Response
|
* @interface AgentStatus200Response
|
||||||
*/
|
*/
|
||||||
export interface AgentStatus200Response {
|
export interface AgentStatus200Response {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AgentStatus200Response
|
||||||
|
*/
|
||||||
|
version?: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<Share>}
|
* @type {Array<Share>}
|
||||||
@ -52,6 +58,7 @@ export function AgentStatus200ResponseFromJSONTyped(json: any, ignoreDiscriminat
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
'version': json['version'] == null ? undefined : json['version'],
|
||||||
'shares': json['shares'] == null ? undefined : ((json['shares'] as Array<any>).map(ShareFromJSON)),
|
'shares': json['shares'] == null ? undefined : ((json['shares'] as Array<any>).map(ShareFromJSON)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -67,6 +74,7 @@ export function AgentStatus200ResponseToJSONTyped(value?: AgentStatus200Response
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
'version': value['version'],
|
||||||
'shares': value['shares'] == null ? undefined : ((value['shares'] as Array<any>).map(ShareToJSON)),
|
'shares': value['shares'] == null ? undefined : ((value['shares'] as Array<any>).map(ShareToJSON)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user