1313import six
1414
1515
16- # Get the OSC show command display and attribute columns for an SDK resource.
17- def get_osc_show_columns_for_sdk_resource (sdk_resource , osc_column_map ):
16+ def get_osc_show_columns_for_sdk_resource (
17+ sdk_resource ,
18+ osc_column_map ,
19+ invisible_columns = []
20+ ):
21+ """Get and filter the display and attribute columns for an SDK resource.
22+
23+ Common utility function for preparing the output of an OSC show command.
24+ Some of the columns may need to get renamed, others made invisible.
25+
26+ :param sdk_resource: An SDK resource
27+ :param osc_column_map: A hash of mappings for display column names
28+ :param invisible_columns: A list of invisible column names
29+
30+ :returns: Two tuples containing the names of the display and attribute
31+ columns
32+ """
33+
1834 if getattr (sdk_resource , 'allow_get' , None ) is not None :
1935 resource_dict = sdk_resource .to_dict (
2036 body = True , headers = False , ignore_none = False )
@@ -24,6 +40,9 @@ def get_osc_show_columns_for_sdk_resource(sdk_resource, osc_column_map):
2440 # Build the OSC column names to display for the SDK resource.
2541 attr_map = {}
2642 display_columns = list (resource_dict .keys ())
43+ for col_name in invisible_columns :
44+ if col_name in display_columns :
45+ display_columns .remove (col_name )
2746 for sdk_attr , osc_attr in six .iteritems (osc_column_map ):
2847 if sdk_attr in display_columns :
2948 attr_map [osc_attr ] = sdk_attr
0 commit comments