@@ -102,7 +102,7 @@ def main(cli):
102102
103103
104104@cli .argument ('-e' , '--eval' , help = "source or eval output to configure shell environment with a login token" , arg_only = True , action = "store_true" , default = False )
105- @cli .subcommand ('login to a management API' )
105+ @cli .subcommand ('login to NetFoundry with a user token or API account credentials ' )
106106def login (cli ):
107107 """Login to an API and cache the expiring token."""
108108 # if logging in to a NF org (default)
@@ -174,15 +174,35 @@ def login(cli):
174174 else :
175175 cli .echo (json_dumps (summary_object , indent = 4 ))
176176 else : # if eval
177+ nonf = """
178+ # helper function logs out from NetFoundry
179+ function nonf(){
180+ unset NETFOUNDRY_API_ACCOUNT NETFOUNDRY_API_TOKEN \
181+ NETFOUNDRY_CLIENT_ID NETFOUNDRY_PASSWORD NETFOUNDRY_OAUTH_URL \
182+ NETFOUNDRY_ORGANIZATION NETFOUNDRY_NETWORK NETFOUNDRY_NETWORK_GROUP \
183+ MOPENV MOPURL
184+ }
185+ """
186+ noaws = """
187+ # helper function logs out from AWS
188+ function noaws(){
189+ unset AWS_SECURITY_TOKEN AWS_SESSION_TOKEN \
190+ AWS_ACCESS_KEY AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY \
191+ AWS_REGION AWS_DEFAULT_REGION AWS_SHARED_CREDENTIALS_FILE
192+ }
193+ """
177194 token_env = f"""
178- # $ eval "$({ cli .prog_name } --credentials=credentials.json login --eval)"
195+ # $ eval "$({ cli .prog_name } --credentials={ organization . credentials } login --eval)"
179196export NETFOUNDRY_API_TOKEN="{ organization .token } "
180197export NETFOUNDRY_API_ACCOUNT="{ organization .credentials if hasattr (organization , 'credentials' ) else '' } "
181198export NETFOUNDRY_ORGANIZATION="{ organization .id } "
182- { 'export NETFOUNDRY_NETWORK="' + network .id + '"' if network else '' }
183- { 'export NETFOUNDRY_NETWORK_GROUP="' + network_group .id + '"' if network_group else '' }
184- { 'export MOPENV="' + organization .environment + '"' if organization .environment else '' }
199+ { 'export NETFOUNDRY_NETWORK="' + network .id + '"' if network else '# NETFOUNDRY_NETWORK' }
200+ { 'export NETFOUNDRY_NETWORK_GROUP="' + network_group .id + '"' if network_group else '# NETFOUNDRY_NETWORK_GROUP' }
201+ export MOPENV="{ organization .environment } "
202+ export MOPURL="{ organization .audience } "
185203eval "$(register-python-argcomplete { cli .prog_name } )"
204+ { nonf }
205+ { noaws }
186206"""
187207 if cli .config .general .color :
188208 highlighted = highlight (token_env , bash_lexer , Terminal256Formatter (style = cli .config .general .style ))
@@ -191,7 +211,7 @@ def login(cli):
191211 cli .echo (token_env )
192212
193213
194- @cli .subcommand ('logout current profile from an organization ' )
214+ @cli .subcommand ('logout your identity for the current current profile ' )
195215def logout (cli ):
196216 """Logout by deleting the cached token."""
197217 spinner = get_spinner ("working" )
@@ -346,7 +366,7 @@ def edit(cli):
346366@cli .argument ('-k' , '--keys' , arg_only = True , action = StoreListKeys , help = "list of keys as a,b,c to print only selected keys (columns)" )
347367@cli .argument ('-a' , '--as' , dest = 'accept' , arg_only = True , choices = ['create' ], help = "request the as=create alternative form of the resource" )
348368@cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , metavar = "RESOURCE_TYPE" , choices = [choice for group in [[singular (type ), RESOURCES [type ].abbreviation ] for type in RESOURCES .keys ()] for choice in group ])
349- @cli .subcommand ('get a single resource by query' )
369+ @cli .subcommand ('get a single resource by type and query' )
350370def get (cli , echo : bool = True , embed = 'all' , spinner : object = None ):
351371 """
352372 Get a single resource as YAML or JSON.
@@ -358,7 +378,7 @@ def get(cli, echo: bool = True, embed='all', spinner: object = None):
358378 cli .args .resource_type = singular (RESOURCE_ABBREV [cli .args .resource_type ].name )
359379 if not cli .config .general .verbose and cli .args .output in ["yaml" , "json" ]: # don't change level if output=text
360380 cli .log .setLevel (logging .WARN ) # don't emit INFO messages to stdout because they will break deserialization
361- if cli .args .accept and not MUTABLE_NET_RESOURCES .get (cli .args .resource_type ):
381+ if cli .args .accept and not MUTABLE_NET_RESOURCES .get (plural ( cli .args .resource_type ) ):
362382 logging .warning ("ignoring --as=create becuase it is applicable only to mutable resources in the network domain" )
363383 cli .args ['accept' ] = None
364384 match = {}
@@ -530,7 +550,7 @@ def get(cli, echo: bool = True, embed='all', spinner: object = None):
530550@cli .argument ('-m' , '--my-roles' , arg_only = True , action = 'store_true' , help = "filter roles by caller identity" )
531551@cli .argument ('-a' , '--as' , dest = 'accept' , arg_only = True , choices = ['create' ], help = "request the as=create alternative form of the resources" )
532552@cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , metavar = "RESOURCE_TYPE" , choices = [choice for group in [[type , RESOURCES [type ].abbreviation ] for type in RESOURCES .keys ()] for choice in group ])
533- @cli .subcommand (description = 'find resources as lists ' )
553+ @cli .subcommand (description = 'find a collection of resources by type and query ' )
534554def list (cli , spinner : object = None ):
535555 """Find resources as lists."""
536556 if not spinner :
@@ -662,7 +682,7 @@ def list(cli, spinner: object = None):
662682
663683@cli .argument ('query' , arg_only = True , action = StoreDictKeyPair , nargs = '?' , help = "query params as k=v,k=v comma-separated pairs" )
664684@cli .argument ('resource_type' , arg_only = True , help = 'type of resource' , choices = [choice for group in [[singular (type ), RESOURCES [type ].abbreviation ] for type in RESOURCES .keys ()] for choice in group ])
665- @cli .subcommand ('delete a resource in the network domain ' )
685+ @cli .subcommand ('delete a single resource by type and query ' )
666686def delete (cli ):
667687 """Delete a resource in the network domain."""
668688 spinner = get_spinner ("working" )
0 commit comments