@@ -52,7 +52,7 @@ def resolve_project_id(client_secrets, credentials):
52
52
raise click .ClickException ('Error loading client secret: %s.\n '
53
53
'Run the device tool '
54
54
'with --client-secrets '
55
- 'or --project option.\n '
55
+ 'or --project-id option.\n '
56
56
'Or copy the %s file '
57
57
'in the current directory.'
58
58
% (e , client_secrets ))
@@ -65,7 +65,7 @@ def build_api_url(api_endpoint, api_version, project_id):
65
65
66
66
67
67
def build_client_from_context (ctx ):
68
- project_id = (ctx .obj ['PROJECT ' ]
68
+ project_id = (ctx .obj ['PROJECT_ID ' ]
69
69
or resolve_project_id (ctx .obj ['CLIENT_SECRETS' ],
70
70
ctx .obj ['CREDENTIALS' ]))
71
71
api_url = build_api_url (ctx .obj ['API_ENDPOINT' ],
@@ -103,7 +103,7 @@ def pretty_print_device(device):
103
103
104
104
105
105
@click .group ()
106
- @click .option ('--project' ,
106
+ @click .option ('--project-id ' ,
107
107
help = 'Enter the Google Developer Project ID that you want to '
108
108
'use with the registration tool. If you don\' t use this flag, '
109
109
'the tool will use the project listed in the '
@@ -113,8 +113,9 @@ def pretty_print_device(device):
113
113
help = 'Enter the path and filename for the '
114
114
'<client_secret_client-id.json> file you downloaded from your '
115
115
'developer project. This file is used to infer the Google '
116
- 'Developer Project ID if it was not provided with the --project '
117
- 'flag. If the --project flag and this flag are not used, the '
116
+ 'Developer Project ID if it was not provided with the '
117
+ '--project-id flag. '
118
+ 'If the --project-id flag and this flag are not used, the '
118
119
'tool will look for this file in the current directory (by '
119
120
'searching for a file named after the client_id stored in the '
120
121
'credentials file).' )
@@ -134,7 +135,7 @@ def pretty_print_device(device):
134
135
'API. You can use this flag if the credentials were generated '
135
136
'in a location that is different than the default.' )
136
137
@click .pass_context
137
- def cli (ctx , project , client_secrets , verbose , api_endpoint , credentials ):
138
+ def cli (ctx , project_id , client_secrets , verbose , api_endpoint , credentials ):
138
139
try :
139
140
with open (credentials , 'r' ) as f :
140
141
c = google .oauth2 .credentials .Credentials (token = None ,
@@ -148,7 +149,7 @@ def cli(ctx, project, client_secrets, verbose, api_endpoint, credentials):
148
149
ctx .obj ['API_ENDPOINT' ] = api_endpoint
149
150
ctx .obj ['API_VERSION' ] = ASSISTANT_API_VERSION
150
151
ctx .obj ['SESSION' ] = None
151
- ctx .obj ['PROJECT ' ] = project
152
+ ctx .obj ['PROJECT_ID ' ] = project_id
152
153
ctx .obj ['CREDENTIALS' ] = c
153
154
ctx .obj ['CLIENT_SECRETS' ] = client_secrets
154
155
logging .basicConfig (format = '' ,
@@ -207,13 +208,14 @@ def register(ctx, model, type, trait, manufacturer, product_name, description,
207
208
hyphen (-), underscore (_), and plus (+). The device nickname can only
208
209
contain numbers, letters, and the space ( ) symbol.
209
210
"""
210
- # cache SESSION and PROJECT so that we don't re-create them between request
211
+ # cache SESSION and PROJECT_ID
212
+ # so that we don't re-create them between commands
211
213
ctx .obj ['SESSION' ] = google .auth .transport .requests .AuthorizedSession (
212
214
ctx .obj ['CREDENTIALS' ]
213
215
)
214
- ctx .obj ['PROJECT ' ] = (ctx .obj ['PROJECT ' ]
215
- or resolve_project_id (ctx .obj ['CLIENT_SECRETS' ],
216
- ctx .obj ['CREDENTIALS' ]))
216
+ ctx .obj ['PROJECT_ID ' ] = (ctx .obj ['PROJECT_ID ' ]
217
+ or resolve_project_id (ctx .obj ['CLIENT_SECRETS' ],
218
+ ctx .obj ['CREDENTIALS' ]))
217
219
ctx .invoke (register_model ,
218
220
model = model , type = type , trait = trait ,
219
221
manufacturer = manufacturer ,
@@ -398,7 +400,7 @@ def delete(ctx, resource, id):
398
400
def list (ctx , resource ):
399
401
"""Lists all of the device models and/or instances associated with the
400
402
current Google Developer project. To change the current project, use the
401
- devicetool's --project flag.
403
+ devicetool's --project-id flag.
402
404
"""
403
405
session , api_url , project_id = build_client_from_context (ctx )
404
406
url = '/' .join ([api_url , resource ])
0 commit comments