19
19
from rest .exceptions import ApiException
20
20
from util import globals
21
21
from util .editor import NotModifiedException
22
- import os
23
22
import argparse
24
23
import traceback
25
24
import sys
26
- import textwrap
27
25
import control .router
28
26
from config import Config , ConfigException
29
27
from api import Client
30
28
from api .exceptions import PythonApiException
31
29
from comodit_client .api .importer import ImportException
32
30
from comodit_client .api .exporter import ExportException
33
31
from comodit_client .control .store import AppStoreController , DistStoreController
32
+ from comodit_client .control .application_keys import ApplicationKeysController
34
33
35
34
def run (argv ):
36
35
# entities
@@ -43,6 +42,7 @@ def run(argv):
43
42
control .router .register (["hosts" ], HostsController ())
44
43
control .router .register (["app-store" ], AppStoreController ())
45
44
control .router .register (["dist-store" ], DistStoreController ())
45
+ control .router .register (["application_keys" ], ApplicationKeysController ())
46
46
47
47
_parse (argv )
48
48
@@ -60,6 +60,7 @@ def _get_value_options(parser):
60
60
"--api" ,
61
61
"--user" ,
62
62
"--pass" ,
63
+ "--token" ,
63
64
"--templates" ,
64
65
"--profile" ,
65
66
"--completions" ,
@@ -86,6 +87,7 @@ def __get_parser(config):
86
87
environments Environment defined within an organization
87
88
hosts Host defined within an environment
88
89
flavors Available flavors when creating a distribution
90
+ application_keys Temporary access tokens related to an organization
89
91
""" )
90
92
91
93
parser .add_argument ("entity" , help = "An entity" )
@@ -115,6 +117,7 @@ def __get_parser(config):
115
117
parser .add_argument ("--api" , dest = "api" , help = "endpoint for the API" , default = None )
116
118
parser .add_argument ("--user" , dest = "username" , help = "username on comodit server" , default = None )
117
119
parser .add_argument ("--pass" , dest = "password" , help = "password on comodit server" , default = None )
120
+ parser .add_argument ("--token" , dest = "token" , help = "application key token" , default = None )
118
121
parser .add_argument ("--templates" , dest = "templates_path" , help = "directory containing JSON templates" , default = config .templates_path )
119
122
parser .add_argument ("--profile" , dest = "profile_name" , help = "Name of profile to use" , default = None )
120
123
@@ -200,7 +203,13 @@ def _parse(argv):
200
203
password = config .get_password (globals .options .profile_name )
201
204
globals .options .password = password
202
205
203
- client = Client (api , username , password , globals .options .insecure )
206
+ if globals .options .token :
207
+ token = globals .options .token
208
+ else :
209
+ token = config .get_token (globals .options .profile_name )
210
+ globals .options .token = token
211
+
212
+ client = Client (api , username , password , token , globals .options .insecure )
204
213
205
214
entity_args = [] + globals .options .subentities
206
215
0 commit comments