@@ -112,14 +112,20 @@ def _validate_parameters(ctx, param, value): # pylint: disable=unused-argument
112112@click .option ('--mask' , help = "String-based object mask" )
113113@click .option ('--limit' , type = click .INT , help = "Result limit" )
114114@click .option ('--offset' , type = click .INT , help = "Result offset" )
115+ @click .option ('--orderBy' , type = click .STRING ,
116+ help = "To set the sort direction, ASC or DESC can be provided."
117+ "This should be of the form: '--orderBy nested.property' default DESC or "
118+ "'--orderBy nested.property=ASC', e.g. "
119+ " --orderBy subnets.id default DESC"
120+ " --orderBy subnets.id=ASC" )
115121@click .option ('--output-python / --no-output-python' ,
116122 help = "Show python example code instead of executing the call" )
117123@click .option ('--json-filter' , callback = _validate_filter ,
118124 help = "A JSON string to be passed in as the object filter to the API call. "
119125 "Remember to use double quotes (\" ) for variable names. Can NOT be used with --filter. "
120126 "Dont use whitespace outside of strings, or the slcli might have trouble parsing it." )
121127@environment .pass_env
122- def cli (env , service , method , parameters , _id , _filters , mask , limit , offset ,
128+ def cli (env , service , method , parameters , _id , _filters , mask , limit , offset , orderby = None ,
123129 output_python = False , json_filter = None ):
124130 """Call arbitrary API endpoints with the given SERVICE and METHOD.
125131
@@ -141,14 +147,19 @@ def cli(env, service, method, parameters, _id, _filters, mask, limit, offset,
141147 --json-filter '{"virtualGuests":{"hostname":{"operation":"^= test"}}}' --limit=10
142148 slcli -v call-api SoftLayer_User_Customer addBulkPortalPermission --id=1234567 \\
143149 '[{"keyName": "NETWORK_MESSAGE_DELIVERY_MANAGE"}]'
150+ slcli call-api Account getVirtualGuests \\
151+ --orderBy virttualguests.id=ASC
144152 """
145153
146154 if _filters and json_filter :
147155 raise exceptions .CLIAbort ("--filter and --json-filter cannot be used together." )
148156
149157 object_filter = _build_filters (_filters )
158+ if orderby :
159+ orderby = utils .build_filter_orderby (orderby )
160+ object_filter = utils .dict_merge (object_filter , orderby )
150161 if json_filter :
151- object_filter . update (json_filter )
162+ object_filter = utils . dict_merge (json_filter , object_filter )
152163
153164 args = [service , method ] + list (parameters )
154165 kwargs = {
0 commit comments