Skip to content

Fix AgentWatcher.get_status API to use proper query parameter #4513

Closed
@seedspirit

Description

@seedspirit

Summary  

  • The API to get the status of an AgentWatcher requires the agent id value as a path param, but the SDK is currently implemented to put it in the body
  • We need to fix to put param in path, not body
@server_status_required(READ_ALLOWED)
@superadmin_required
@check_api_params(
    t.Dict({
        tx.AliasedKey(["agent_id", "agent"]): t.String,
    })
)
async def get_watcher_status(request: web.Request, params: Any) -> web.Response:
    log.info("GET_WATCHER_STATUS (ag:{})", params["agent_id"])
    root_ctx: RootContext = request.app["_root.context"]

    result = await root_ctx.processors.agent.get_watcher_status.wait_for_complete(
        GetWatcherStatusAction(agent_id=params["agent_id"])
    )

    if result.resp.status == HTTPStatus.OK:
        data = await result.resp.json()
        return web.json_response(data, status=result.resp.status)
    else:
        data = await result.resp.text()
        return web.Response(text=data, status=result.resp.status)
class AgentWatcher(BaseFunction):
    @api_function
    @classmethod
    async def get_status(cls, agent_id: str) -> dict:
        """
        Get agent and watcher status.
        """
        rqst = Request("GET", "/resource/watcher")
        rqst.set_json({"agent_id": agent_id})
        async with rqst.fetch() as resp:
            data = await resp.json()
            if "message" in data:
                return data["message"]
            else:
                return data

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions