Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIRTS-3151 Agents HEAD/GET/POST documentation #2398

13 changes: 9 additions & 4 deletions app/api/v2/handlers/agent_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ def add_routes(self, app: web.Application):
router.add_get('/deploy_commands', self.get_deploy_commands)
router.add_get('/deploy_commands/{ability_id}', self.get_deploy_commands_for_ability)

@aiohttp_apispec.docs(tags=['agents'])
@aiohttp_apispec.docs(tags=['agents'],
summary="Retrieves all agents",
description="Retrieves all stored agents.")
@aiohttp_apispec.querystring_schema(BaseGetAllQuerySchema)
@aiohttp_apispec.response_schema(AgentSchema(many=True, partial=True))
@aiohttp_apispec.response_schema(AgentSchema(many=True, partial=True),
description="Returns a list of all agents.")
async def get_agents(self, request: web.Request):
agents = await self.get_all_objects(request)
return web.json_response(agents)
Expand All @@ -40,9 +43,11 @@ async def get_agent_by_id(self, request: web.Request):
agent = await self.get_object(request)
return web.json_response(agent)

@aiohttp_apispec.docs(tags=['agents'])
@aiohttp_apispec.docs(tags=['agents'],
summary="Create a new agent",
description="Creates a new agent using the format from 'AgentSchema'.")
@aiohttp_apispec.request_schema(AgentSchema)
@aiohttp_apispec.response_schema(AgentSchema)
@aiohttp_apispec.response_schema(AgentSchema, description="Returns a single agent in 'AgentSchema' format")
async def create_agent(self, request: web.Request):
agent = await self.create_object(request)
return web.json_response(agent.display)
Expand Down