def cli(env, package_keyname, keyword, category):
    """List package items used for ordering.

    The item keyNames listed can be used with `slcli order place` to specify
    the items that are being ordered in the package.

    .. Note::
        Items with a numbered category, like disk0 or gpu0, can be included
        multiple times in an order to match how many of the item you want to order.

    ::

        # List all items in the VSI package
        slcli order item-list CLOUD_SERVER

        # List Ubuntu OSes from the os category of the Bare Metal package
        slcli order item-list BARE_METAL_SERVER --category os --keyword ubuntu

    """
    table = formatting.Table(COLUMNS)
    manager = ordering.OrderingManager(env.client)

    _filter = {'items': {}}
    if keyword:
        _filter['items']['description'] = {'operation': '*= %s' % keyword}
    if category:
        _filter['items']['categories'] = {'categoryCode': {'operation': '_= %s' % category}}

    items = manager.list_items(package_keyname, filter=_filter)
    sorted_items = sort_items(items)

    categories = sorted_items.keys()
    for catname in sorted(categories):
        for item in sorted_items[catname]:
            table.add_row([catname, item['keyName'], item['description'], get_price(item)])
    env.fout(table)
def cli ( env , package_keyname , keyword , category ) : table = formatting . Table ( COLUMNS ) manager = ordering . OrderingManager ( env . client ) _filter = { 'items' : { } } if keyword : _filter [ 'items' ] [ 'description' ] = { 'operation' : '*= %s' % keyword } if category : _filter [ 'items' ] [ 'categories' ] = { 'categoryCode' : { 'operation' : '_= %s' % category } } items = manager . list_items ( package_keyname , filter = _filter ) sorted_items = sort_items ( items ) categories = sorted_items . keys ( ) for catname in sorted ( categories ) : for item in sorted_items [ catname ] : table . add_row ( [ catname , item [ 'keyName' ] , item [ 'description' ] , get_price ( item ) ] ) env . fout ( table )
List package items used for ordering.

    The item keyNames listed can be used with `slcli order place` to specify
    the items that are being ordered in the package.

    .. Note::
        Items with a numbered category, like disk0 or gpu0, can be included
        multiple times in an order to match how many of the item you want to order.

    ::

        # List all items in the VSI package
        slcli order item-list CLOUD_SERVER

        # List Ubuntu OSes from the os category of the Bare Metal package
        slcli order item-list BARE_METAL_SERVER --category os --keyword ubuntu