@@ -102,7 +102,7 @@ def main(cli):
102
102
103
103
104
104
@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 ' )
106
106
def login (cli ):
107
107
"""Login to an API and cache the expiring token."""
108
108
# if logging in to a NF org (default)
@@ -174,15 +174,35 @@ def login(cli):
174
174
else :
175
175
cli .echo (json_dumps (summary_object , indent = 4 ))
176
176
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
+ """
177
194
token_env = f"""
178
- # $ eval "$({ cli .prog_name } --credentials=credentials.json login --eval)"
195
+ # $ eval "$({ cli .prog_name } --credentials={ organization . credentials } login --eval)"
179
196
export NETFOUNDRY_API_TOKEN="{ organization .token } "
180
197
export NETFOUNDRY_API_ACCOUNT="{ organization .credentials if hasattr (organization , 'credentials' ) else '' } "
181
198
export 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 } "
185
203
eval "$(register-python-argcomplete { cli .prog_name } )"
204
+ { nonf }
205
+ { noaws }
186
206
"""
187
207
if cli .config .general .color :
188
208
highlighted = highlight (token_env , bash_lexer , Terminal256Formatter (style = cli .config .general .style ))
@@ -191,7 +211,7 @@ def login(cli):
191
211
cli .echo (token_env )
192
212
193
213
194
- @cli .subcommand ('logout current profile from an organization ' )
214
+ @cli .subcommand ('logout your identity for the current current profile ' )
195
215
def logout (cli ):
196
216
"""Logout by deleting the cached token."""
197
217
spinner = get_spinner ("working" )
@@ -346,7 +366,7 @@ def edit(cli):
346
366
@cli .argument ('-k' , '--keys' , arg_only = True , action = StoreListKeys , help = "list of keys as a,b,c to print only selected keys (columns)" )
347
367
@cli .argument ('-a' , '--as' , dest = 'accept' , arg_only = True , choices = ['create' ], help = "request the as=create alternative form of the resource" )
348
368
@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' )
350
370
def get (cli , echo : bool = True , embed = 'all' , spinner : object = None ):
351
371
"""
352
372
Get a single resource as YAML or JSON.
@@ -358,7 +378,7 @@ def get(cli, echo: bool = True, embed='all', spinner: object = None):
358
378
cli .args .resource_type = singular (RESOURCE_ABBREV [cli .args .resource_type ].name )
359
379
if not cli .config .general .verbose and cli .args .output in ["yaml" , "json" ]: # don't change level if output=text
360
380
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 ) ):
362
382
logging .warning ("ignoring --as=create becuase it is applicable only to mutable resources in the network domain" )
363
383
cli .args ['accept' ] = None
364
384
match = {}
@@ -530,7 +550,7 @@ def get(cli, echo: bool = True, embed='all', spinner: object = None):
530
550
@cli .argument ('-m' , '--my-roles' , arg_only = True , action = 'store_true' , help = "filter roles by caller identity" )
531
551
@cli .argument ('-a' , '--as' , dest = 'accept' , arg_only = True , choices = ['create' ], help = "request the as=create alternative form of the resources" )
532
552
@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 ' )
534
554
def list (cli , spinner : object = None ):
535
555
"""Find resources as lists."""
536
556
if not spinner :
@@ -662,7 +682,7 @@ def list(cli, spinner: object = None):
662
682
663
683
@cli .argument ('query' , arg_only = True , action = StoreDictKeyPair , nargs = '?' , help = "query params as k=v,k=v comma-separated pairs" )
664
684
@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 ' )
666
686
def delete (cli ):
667
687
"""Delete a resource in the network domain."""
668
688
spinner = get_spinner ("working" )
0 commit comments