2222
2323
2424class CommandResult (base .APIBase ):
25+ """Object representing the result of a given command."""
26+
2527 id = types .text
2628 command_name = types .text
2729 command_params = types .DictType (types .text , base .json_type )
@@ -31,6 +33,13 @@ class CommandResult(base.APIBase):
3133
3234 @classmethod
3335 def from_result (cls , result ):
36+ """Convert a BaseCommandResult object to a CommandResult object.
37+
38+ :param result: a :class:`ironic_python_agent.extensions.base.
39+ BaseCommandResult` object.
40+ :returns: a :class:`ironic_python_agent.api.controllers.v1.command.
41+ CommandResult` object.
42+ """
3443 instance = cls ()
3544 for field in ('id' , 'command_name' , 'command_params' , 'command_status' ,
3645 'command_error' , 'command_result' ):
@@ -39,18 +48,26 @@ def from_result(cls, result):
3948
4049
4150class CommandResultList (base .APIBase ):
51+ """An object representing a list of CommandResult objects."""
4252 commands = [CommandResult ]
4353
4454 @classmethod
4555 def from_results (cls , results ):
56+ """Convert a list of BaseCommandResult objects to a CommandResultList.
57+
58+ :param results: a list of :class:`ironic_python_agent.extensions.base.
59+ BaseCommandResult` objects.
60+ :returns: a :class:`ironic_python_agent.api.controllers.v1.command.
61+ CommandResultList` object.
62+ """
4663 instance = cls ()
4764 instance .commands = [CommandResult .from_result (result )
4865 for result in results ]
4966 return instance
5067
5168
5269class Command (base .APIBase ):
53- """A command representation."""
70+ """A representation of a command ."""
5471 name = types .wsattr (types .text , mandatory = True )
5572 params = types .wsattr (base .MultiType (dict ), mandatory = True )
5673
@@ -60,12 +77,20 @@ class CommandController(rest.RestController):
6077
6178 @wsme_pecan .wsexpose (CommandResultList )
6279 def get_all (self ):
80+ """Get all command results."""
6381 agent = pecan .request .agent
6482 results = agent .list_command_results ()
6583 return CommandResultList .from_results (results )
6684
6785 @wsme_pecan .wsexpose (CommandResult , types .text , types .text )
6886 def get_one (self , result_id , wait = None ):
87+ """Get a command result by ID.
88+
89+ :param result_id: the ID of the result to get.
90+ :param wait: if 'true', block until the command completes.
91+ :returns: a :class:`ironic_python_agent.api.controller.v1.command.
92+ CommandResult` object.
93+ """
6994 agent = pecan .request .agent
7095 result = agent .get_command_result (result_id )
7196
@@ -76,6 +101,14 @@ def get_one(self, result_id, wait=None):
76101
77102 @wsme_pecan .wsexpose (CommandResult , types .text , body = Command )
78103 def post (self , wait = None , command = None ):
104+ """Post a command for the agent to run.
105+
106+ :param wait: if 'true', block until the command completes.
107+ :param command: the command to execute. If None, an InvalidCommandError
108+ will be returned.
109+ :returns: a :class:`ironic_python_agent.api.controller.v1.command.
110+ CommandResult` object.
111+ """
79112 # the POST body is always the last arg,
80113 # so command must be a kwarg here
81114 if command is None :
0 commit comments