Reports can specify a list of report-specific options that they accept, and can also accept a specified number of additional arguments. Your report can support both, one, or neither of these inputs. When you request help for a report, MySQL Shell provides a listing of options and arguments, and any available descriptions of these that are provided when the report is registered.
Dict report(Session session, List argv, Dict options);
sessionis a MySQL Shell session object that is to be used to execute the report.
argvis an optional list containing string values of additional arguments that are passed to the report.
optionsis an optional dictionary with key names and values that correspond to any report-specific options and their values.
A report function is expected to return data in a specific format, depending on the type you use when registering it:
- List type
Returns output as a list of lists, with the first list consisting of the names of columns, and the remainder being the content of rows. MySQL Shell displays the output in table format by default, or in vertical format if the
--Eoption was specified on the
\watchcommand. The values for the rows are converted to string representations of the items. If a row has fewer elements than the number of column names, the missing elements are considered to be NULL. If a row has more elements than the number of column names, the extra elements are ignored. When you register this report, use the type “list”.
- Report type
Returns free-form output as a list containing a single item. MySQL Shell displays this output using YAML. When you register this report, use the type “report”.
- Print type
Prints the output directly to screen, and return an empty list to MySQL Shell to show that the output has already been displayed. When you register this report, use the type “print”.
To provide the output, the API function for the report must
return a dictionary with the key
a list of JSON objects, one for each of the items in your
returned list. For the List type, use one element for each list,
for the Report type use a single element, and for the Print type
use no elements.