#NEWLINE# @ cli . group ( invoke_without_command = True ) #NEWLINE# @ click . option ( '-a' , '--attributes' , metavar = 'ATTRS' , help = 'A key/value pair attached to this Interface (format: key=value).' , multiple = True ) #NEWLINE# @ click . option ( '-d' , '--delimited' , is_flag = True , help = 'Display set query results separated by commas vs. newlines.' , default = False , show_default = True ) #NEWLINE# @ click . option ( '-D' , '--device' , metavar = 'DEVICE' , help = 'Unique ID or hostname of the Device being retrieved.' ) #NEWLINE# @ click . option ( '-e' , '--description' , metavar = 'DESCRIPTION' , type = str , help = 'Filter by Interfaces matching this description.' ) #NEWLINE# @ click . option ( '-g' , '--grep' , is_flag = True , help = 'Display list results in a grep-friendly format.' , default = False , show_default = True ) #NEWLINE# @ click . option ( '-i' , '--id' , metavar = 'ID' , type = int , help = 'Unique ID of the Interface being retrieved.' ) #NEWLINE# @ click . option ( '-l' , '--limit' , metavar = 'LIMIT' , help = 'Limit result to N resources.' ) #NEWLINE# @ click . option ( '-m' , '--mac-address' , metavar = 'MAC' , type = str , help = 'Filter by the MAC address of the Interface.' ) #NEWLINE# @ click . option ( '-n' , '--name' , metavar = 'NAME' , help = 'Filter to Interfaces matching this name.' ) #NEWLINE# @ click . option ( '-N' , '--natural-key' , is_flag = True , help = 'Display list results by their natural key' , default = False , show_default = True ) #NEWLINE# @ click . option ( '-o' , '--offset' , metavar = 'OFFSET' , help = 'Skip the first N resources.' ) #NEWLINE# @ click . option ( '-p' , '--parent-id' , metavar = 'PARENT_ID' , type = int , help = 'Filter by integer of the ID of the parent Interface.' ) #NEWLINE# @ click . option ( '-q' , '--query' , metavar = 'QUERY' , help = 'Perform a set query using Attributes and output matching Interfaces.' ) #NEWLINE# @ click . option ( '-S' , '--speed' , metavar = 'SPEED' , type = int , help = 'Filter by integer of Mbps of interface (e.g. 20000 for 20 Gbps)' ) #NEWLINE# @ click . option ( '-s' , '--site-id' , metavar = 'SITE_ID' , help = 'Unique ID of the Site this Interface is under.  [required]' , callback = callbacks . process_site_id ) #NEWLINE# @ click . option ( '-t' , '--type' , metavar = 'TYPE' , type = int , help = 'Filter by integer of the interface type (e.g. 6 for ethernet)' ) #NEWLINE# @ click . pass_context #NEWLINE# def list( ctx , attributes , delimited , device , description , grep , id , limit , mac_address , name , natural_key , offset , parent_id , query , site_id , speed , type ) : #NEWLINE# #INDENT# '\n    List existing Interfaces for a Site.\n\n    You must provide a Site ID using the -s/--site-id option.\n\n    When listing Interfaces, all objects are displayed by default. You\n    optionally may lookup a single Interfaces by ID using the -i/--id option.\n\n    You may limit the number of results using the -l/--limit option.\n\n    You may look up the interfaces for a single Device using -D/--device which\n    can be either a hostname or ID for a Device.\n    ' #NEWLINE# data = ctx . params #NEWLINE# data . pop ( 'delimited' ) #NEWLINE# if ( ( id is not None ) or all ( [ device , name ] ) ) : #NEWLINE# #INDENT# display_fields = VERBOSE_FIELDS #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# display_fields = DISPLAY_FIELDS #NEWLINE# #UNINDENT# if ( device and ( not device . isdigit ( ) ) ) : #NEWLINE# #INDENT# log . debug ( 'Device is hostname! Converting device => device__hostname' ) #NEWLINE# data [ 'device__hostname' ] = data . pop ( 'device' ) #NEWLINE# #UNINDENT# if ( ctx . invoked_subcommand is None ) : #NEWLINE# #INDENT# if ( query is not None ) : #NEWLINE# #INDENT# results = ctx . obj . set_query ( data ) #NEWLINE# interfaces = get_result ( results ) #NEWLINE# interfaces = sorted ( ( ( i [ 'device' ] , i [ 'name' ] ) for i in interfaces ) ) #NEWLINE# interfaces = [ ( '%s:%s' % obj ) for obj in interfaces ] #NEWLINE# joiner = ( ',' if delimited else '\n' ) #NEWLINE# click . echo ( joiner . join ( interfaces ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ctx . obj . list ( data , display_fields = display_fields , verbose_fields = VERBOSE_FIELDS )