3131from .network import Network
3232from .network_group import NetworkGroup
3333from .organization import Organization
34- from .utility import RESOURCES , Utility , plural , singular
34+ from .utility import NETWORK_RESOURCES , RESOURCES , Utility , plural , singular
3535from packaging import version
3636
3737set_metadata (version = "v" + get_versions ()['version' ]) # must precend import milc.cli
@@ -129,13 +129,13 @@ def login(cli, api: str=None, shell: bool=None):
129129 # configure the current shell)
130130 if not cli .args .shell and cli .config .general .output == "text" :
131131 summary_table = [['domain' , 'summary' ]]
132- summary_table .append (['organization' , '"{org_name}" ({org_label}@{env}) logged in as {fullname} ({email}) until {expiry_timestamp} ({expiry_seconds}s)' .format (
132+ summary_table .append (['organization' , '"{org_name}" ({org_label}@{env}) logged in as {fullname} ({email}) until {expiry_timestamp} (T- {expiry_seconds}s)' .format (
133133 fullname = summary_object ['caller' ]['name' ],
134134 email = summary_object ['caller' ]['email' ],
135135 org_label = organization .label ,
136136 org_name = organization .name ,
137137 env = organization .environment ,
138- expiry_timestamp = time .strftime ('%Y-%m-%d % H:%M:%S GMT%z' , time .localtime (organization .expiry )),
138+ expiry_timestamp = time .strftime ('%H:%M GMT%z' , time .localtime (organization .expiry )),
139139 expiry_seconds = int (organization .expiry_seconds )
140140 )])
141141 if network_group :
@@ -281,7 +281,7 @@ def whoami(cli, echo: bool=True, organization: object=None):
281281
282282@cli .argument ('-f' , '--file' , help = 'JSON or YAML file' , type = argparse .FileType ('r' , encoding = 'UTF-8' ))
283283@cli .argument ('-w' ,'--wait' , help = 'seconds to wait for process execution to finish' , default = 0 )
284- @cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = [singular (type ) for type in RESOURCES .keys ()])
284+ @cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = [singular (type ) for type in NETWORK_RESOURCES .keys ()])
285285@cli .subcommand ('create a resource from stdin or file' )
286286def create (cli ):
287287 """Create a resource.
@@ -293,8 +293,8 @@ def create(cli):
293293 # get the input object if available, else get the lines (serialized YAML or JSON) and try to deserialize
294294 create_input_object , create_input_lines , create_object = None , str (), None
295295 if sys .stdin .isatty () and not cli .args .file :
296- if 'create_template' in RESOURCES [plural (cli .args .resource_type )].keys ():
297- create_input_object = RESOURCES [plural (cli .args .resource_type )]['create_template' ]
296+ if 'create_template' in NETWORK_RESOURCES [plural (cli .args .resource_type )].keys ():
297+ create_input_object = NETWORK_RESOURCES [plural (cli .args .resource_type )]['create_template' ]
298298 else :
299299 create_input_object = {"hint" : "No template was found for resource type {type}. Replace the contents of this buffer with the request body as YAML or JSON to create a resource. networkId will be added automatically." .format (type = cli .args .resource_type )}
300300 elif cli .args .file :
@@ -348,7 +348,7 @@ def create(cli):
348348 resource = network .create_resource (type = cli .args .resource_type , properties = create_object , wait = cli .config .create .wait )
349349
350350@cli .argument ('query' , arg_only = True , action = StoreDictKeyPair , nargs = '?' , help = "id=UUIDv4 or query params as k=v,k=v comma-separated pairs" )
351- @cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = [ singular ( type_name ) for type_name , type_props in RESOURCES . items () if type_props [ 'domain' ] == "network" ] )
351+ @cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = NETWORK_RESOURCES . keys () )
352352# this allows us to pass the edit subcommand's cli object to function get without further modifying that functions params
353353@cli .argument ('-a' , '--accept' , arg_only = True , default = 'update' , help = argparse .SUPPRESS )
354354@cli .subcommand ('edit a single resource selected by query with editor defined in NETFOUNDRY_EDITOR or EDITOR' )
@@ -407,7 +407,7 @@ def get(cli, echo: bool=True):
407407 organization = organization ,
408408 network = cli .config .general .network ,
409409 )
410- match = network .describe
410+ match = organization . get_network ( network_id = network .id , embed = "all" , accept = cli . args . accept )
411411 else :
412412 matches = organization .get_networks_by_organization (** cli .args .query )
413413 if len (matches ) == 1 :
@@ -552,7 +552,7 @@ def list(cli):
552552 cli .echo (json_dumps (filtered_matches , indent = 4 ))
553553
554554@cli .argument ('query' , arg_only = True , action = StoreDictKeyPair , nargs = '?' , help = "query params as k=v,k=v comma-separated pairs" )
555- @cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = [singular (type ) for type in RESOURCES .keys ()])
555+ @cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = [singular (type ) for type in NETWORK_RESOURCES .keys ()])
556556@cli .argument ('-w' ,'--wait' , help = 'seconds to wait for confirmation of delete' , default = 0 )
557557@cli .subcommand ('delete a resource in the network domain' )
558558def delete (cli ):
0 commit comments