Skip to content

Commit eadf183

Browse files
author
Pavel Petroshenko
authored
Merge pull request #20 from electricimp/develop
v1.2.0
2 parents bb74589 + 12b3fbb commit eadf183

File tree

8 files changed

+287
-206
lines changed

8 files changed

+287
-206
lines changed

Diff for: CommandsManual.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Applicable to the following impCentral API entities — Account, Product, De
123123
- If at least one entity is found for the particular attribute, the search is stopped.
124124
- If no entity is found for all attributes, or more than one entity is found, then, depending on a particular command, that may be considered as a success (for all `list` commands) or as a fail (for all other commands).
125125

126-
### Account identifier ###
126+
### Account Identifier ###
127127

128128
Option: `--owner <ACCOUNT_IDENTIFIER>`
129129

@@ -134,7 +134,7 @@ Attributes accepted as <ACCOUNT_IDENTIFIER> (in order of search):
134134
- Email (always unique)
135135
- Username (always unique)
136136

137-
### Product identifier ###
137+
### Product Identifier ###
138138

139139
Option: `--product <PRODUCT_IDENTIFIER>`
140140

@@ -143,7 +143,7 @@ Attributes accepted as `<PRODUCT_IDENTIFIER>` (in order of search):
143143
- Product ID (always unique)
144144
- Product name (unique among all Products owned by a particular user)
145145

146-
### Device Group identifier ###
146+
### Device Group Identifier ###
147147

148148
Option: `--dg <DEVICE_GROUP_IDENTIFIER>`
149149

@@ -152,7 +152,7 @@ Attributes accepted as `<DEVICE_GROUP_IDENTIFIER>` (in order of search):
152152
- Device Group ID (always unique)
153153
- Device Group name (unique among all the Device Groups within a Product)
154154

155-
### Device identifier ###
155+
### Device Identifier ###
156156

157157
Option: `--device <DEVICE_IDENTIFIER>`
158158

@@ -163,7 +163,7 @@ Attributes accepted as `<DEVICE_IDENTIFIER>` (in order of search):
163163
- Agent ID
164164
- Device name
165165

166-
### Build identifier ###
166+
### Build Identifier ###
167167

168168
Option: `--build <BUILD_IDENTIFIER>`
169169

@@ -237,25 +237,29 @@ Displays the status and the details of the authentication applicable to the curr
237237

238238
```
239239
impt auth login [--local] [--endpoint <endpoint_url>]
240-
(--user <user_id> --pwd <password> | --lk <login_key_id>) [--temp] [--confirmed]
240+
[--user <user_id> [--pwd <password>] | --lk <login_key_id>] [--temp] [--confirmed]
241241
[--debug] [--help]
242242
```
243243

244244
Perform global or local login. Creates a [global](#global-auth-file) or [local](#local-auth-file) auth file.
245245

246-
The options for one and only one of the following authentication methods must be specified in the command:
246+
The options for one, and only one, of the following authentication methods may be specified in the command:
247247
- Using an account identifier and password (`--user` and `--pwd` options).
248248
- Using a [login key](#login-key-manipulation-commands) (`--lk` option).
249249

250+
If neither the `--user` nor the `--lk` option is specified, the user is asked to choose an authentication method and input the corresponding credentials.
251+
252+
If the `--user` option is specified but the `--pwd` option is not, the user is asked to input the account password.
253+
250254
The user is asked to confirm the operation if the corresponding auth file already exists, unless confirmed automatically with the `--confirmed` option. If confirmed, the existing auth file is overwritten.
251255

252256
| Option | Alias | Mandatory? | Value Required? | Description |
253257
| --- | --- | --- | --- | --- |
254258
| --local | -l | No | No | If specified, creates or replaces a [local auth file](#local-auth-file) in the current directory. If not specified, creates or replaces the [global auth file](#global-auth-file) |
255259
| --endpoint | -e | No | Yes | An impCentral API endpoint. Default: `https://api.electricimp.com/v5` |
256-
| --user | -u | Yes/no | Yes | The account identifier: username or email address. If specified, the `--pwd` option must be specified too |
257-
| --pwd | -w | Yes/no | Yes | The account password. If specified, the `--user` option must be specified too |
258-
| --lk | -k | Yes/no | Yes | The login key ID |
260+
| --user | -u | No | Yes | The account identifier: a username or an email address |
261+
| --pwd | -w | No | Yes | The account password. If specified, the `--user` option must be specified too |
262+
| --lk | -k | No | Yes | A login key for the account |
259263
| --temp | -t | No | No | If this option is not specified, *impt* saves the information required to refresh access token and refreshes it automatically when the token expires. If the option is specified, the tool does not save information required to refresh access token. In this case, you need to call `impt auth login` again after the access token has expired |
260264
| --confirmed | -q | No | No | Executes the operation without asking additional confirmation from user |
261265
| --debug | -z | No | No | Displays debug info for the command execution |

Diff for: README.md

+61-59
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ HTTPS_PROXY=https://proxy.example.net
5656

5757
All commands follow a unified format and [syntax](./CommandsManual.md#command-syntax):
5858

59-
```
59+
```bash
6060
impt <command_group> <command_name> [<options>]
6161
```
6262

@@ -87,21 +87,21 @@ The most of commands have optional arguments: `--<options>`. Options may be writ
8787

8888
Every option has a one letter [alias](./CommandsManual.md#list-of-aliases). The aliases are unique for a particular command but may be reused for different options in different commands. The same option in different commands always has the same alias. The options and aliases are detailed in the [Command Description](./CommandsManual.md#command-description).
8989

90-
**Examples**
90+
##### Examples #####
9191

92-
```
92+
```bash
9393
impt product create --name TestProduct --descr "My test product"
9494
```
9595

96-
```
96+
```bash
9797
impt product update --product TestProduct -s ""
9898
```
9999

100-
```
100+
```bash
101101
impt dg create --name "TestDG" -y development -p TestProduct
102102
```
103103

104-
```
104+
```bash
105105
impt device assign -g TestDG -d myDevice1
106106
```
107107

@@ -111,11 +111,9 @@ Every command has a `--help` option (alias: `-h`). If it is specified, any other
111111

112112
The [help option](./CommandsManual.md#the-help-option) is applicable to a partially specified command, but also may be used to list all available command groups or to list all commands available in one group.
113113

114-
**Examples**
114+
##### Example 1: List all command groups #####
115115

116-
**List all command groups**
117-
118-
```
116+
```bash
119117
> impt --help
120118

121119
Usage: impt <command> [options]
@@ -137,9 +135,9 @@ Options:
137135
[boolean]
138136
```
139137

140-
**List all commands in one group**
138+
##### Example 2: List all the commands in one group #####
141139

142-
```
140+
```bash
143141
> impt product --help
144142

145143
Usage: impt product <command> [options]
@@ -158,9 +156,9 @@ Options:
158156
[boolean]
159157
```
160158

161-
**Display a command description**
159+
##### Example 3: Display a command description #####
162160

163-
```
161+
```bash
164162
> impt product create --help
165163

166164
Usage: impt product create --name <product_name> [--descr <product_description>]
@@ -181,9 +179,9 @@ Options:
181179
182180
Every command has a `--debug` option (alias: `-z`). If it is specified, the tool displays debug information from the command being executed, including impCentral API requests and responses.
183181
184-
**Example**
182+
#### Example ####
185183
186-
```
184+
```bash
187185
> impt product create --name TestProduct --descr "My test product" --debug
188186
Doing the request with options:
189187
{
@@ -263,19 +261,17 @@ A command’s execution output contains one of the two predefined phrases: `IMPT
263261
264262
If a command finishes with `IMPT COMMAND FAILS`, it returns non-zero exit code. Otherwise, it returns zero exit code. This can be used by scripts as well.
265263
266-
**Example**
267-
268-
**A successful command execution**
264+
##### Example 1: A successful command execution #####
269265
270-
```
266+
```bash
271267
> impt product delete --product TestProduct --confirmed
272268
Product "TestProduct" is deleted successfully.
273269
IMPT COMMAND SUCCEEDS
274270
```
275271
276-
**A failed command execution**
272+
##### Example 2: A failed command execution #####
277273
278-
```
274+
```bash
279275
> impt product delete --product TestProduct --confirmed
280276
ERROR: Product "TestProduct" is not found.
281277
IMPT COMMAND FAILS
@@ -289,6 +285,8 @@ Calls to the impCentral API need to be authenticated. *impt* provides the [login
289285
- NOTE: If your username or password contains certain special characters, such as the "!", you may need to wrap the `user_id` and `password` in single quotes to avoid [potential bash interpretation issues](https://ss64.com/bash/bang.html) (e.g. `impt auth login --user 'AUserId' --pwd 'A!Password'`)
290286
- Using a [login key](#login-keys): `impt auth login --lk <login_key>`
291287
288+
You may specify credentials (identifier and password, or login key) directly in the [login command](./CommandsManual.md#auth-login) options. If credentials are not specified, *impt* asks you to choose an authentication method and to input the corresponding credentials.
289+
292290
The tool takes care of obtaining an access token and refreshing it using an obtained refresh token or a provided login key. Typically, you need only log in once and can continue using the tool while the refresh token or login key remains valid (ie. not deleted by you). For this purpose, the tool stores the access token and the refresh token/login key in an [auth file](./CommandsManual.md#auth-files).
293291
294292
*impt* never stores an account identifier and password. If you do not want the tool to store a refresh token/login key, use the [login command’s](./CommandsManual.md#auth-login) `--temp` option. In this case you will not be able to work with the impCentral API after the access token has expired (usually one hour after issue), and you will have to log in again to continue.
@@ -320,27 +318,39 @@ If you run the [logout command](./CommandsManual.md#auth-logout) with the `--loc
320318
321319
At any time you can get known the login status related to any directory. Call the [`impt auth info`](./CommandsManual.md#auth-info) from the required directory. The returned information includes a type of the login applicable to the current directory, access token status, your account ID and other details.
322320
323-
**Examples**
324-
325-
**Global login**
321+
##### Example 1: Global login #####
326322
327-
```
323+
```bash
328324
> impt auth login --user username --pwd password
329325
Global login is successful.
330326
IMPT COMMAND SUCCEEDS
331327
```
332328
333-
**Local login using a login key, specifying a endpoint, without storing the login key**
329+
##### Example 2: Global login without specifying credentials in the options #####
334330
331+
```bash
332+
> impt auth login
333+
Choose authentication method:
334+
(1) User/Password
335+
(2) Login Key
336+
Enter 1 or 2: 1
337+
Enter username or email address: username
338+
Enter password: ********
339+
Global login is successful.
340+
IMPT COMMAND SUCCEEDS
335341
```
342+
343+
##### Example 3: Local login using a login key, specifying an endpoint, but without storing the login key #####
344+
345+
```bash
336346
> impt auth login --local --lk 7d8e6670aa285e9d --temp --endpoint https://api.electricimp.com/v5
337347
Local login is successful.
338348
IMPT COMMAND SUCCEEDS
339349
```
340350
341-
**Display login status**
351+
##### Example 4: Display login status #####
342352
343-
```
353+
```bash
344354
> impt auth info
345355
Auth info:
346356
impCentral API endpoint: https://api.electricimp.com/v5
@@ -353,9 +363,9 @@ Account id: c1d61eef-d544-4d09-c8dc-d43e6742cae3
353363
IMPT COMMAND SUCCEEDS
354364
```
355365
356-
**Local logout**
366+
##### Exmaple 5: Local logout #####
357367
358-
```
368+
```bash
359369
> impt auth logout --local
360370
Local logout is successful.
361371
IMPT COMMAND SUCCEEDS
@@ -365,9 +375,9 @@ IMPT COMMAND SUCCEEDS
365375
366376
*impt* provides a set of [Login Key manipulation commands](./CommandsManual.md#login-key-manipulation-commands) which allows you to fully control your account’s login keys: list the existent login keys, create a new one, delete one, etc. You must be logged in in order to use the commands, which may additionally requires your password.
367377
368-
**Example**
378+
##### Example #####
369379
370-
```
380+
```bash
371381
> impt loginkey list
372382
Login Key list (1 items):
373383
Login Key:
@@ -382,13 +392,11 @@ A Project is an *impt* entity introduced to help developers manage their work. A
382392
383393
Projects are intended for developers and are described in detail in the [*impt* Development Guide](./DevelopmentGuide.md). The tool provides a set of [Project manipulation commands](./CommandsManual.md#project-manipulation-commands). However, many other commands are affected when called from a directory where a [Project file](./CommandsManual.md#project-files) is located. Product, Device Group, Devices, Deployment referenced by the Project file may be assumed by a command when they are not specified in the command’s options explicitly. If you want to avoid that, always specify the mandatory options of the commands. All such options are detailed in the [Command Description](./CommandsManual.md#command-description).
384394
385-
**Example**
386-
387-
**Unassign all Devices from Device Group**
395+
##### Example: Unassign all Devices from a Device Group #####
388396
389397
A Device Group is not specified in the command below, but the current directory contains a Project File. All Devices are unassigned from the Device Group referenced by that Project File.
390398
391-
```
399+
```bash
392400
> impt dg unassign
393401
The following Devices are unassigned successfully from Device Group "dfcde3bd-3d89-6c75-bf2a-a543c47e586b":
394402
Device:
@@ -414,11 +422,9 @@ If you want to use this feature, please read the [Commands Manual](./CommandsMan
414422
415423
When it is hard to uniquely specify an entity without knowing the entity ID, use [entity listing](#entity-listing-and-ownership) commands to view the entities basing on some attributes, choose the required entity and use its entity ID in the required command.
416424
417-
**Examples**
425+
##### Example 1: An entity is found successfully**
418426
419-
**An entity is found successfully**
420-
421-
```
427+
```bash
422428
> impt device info --device 0c:2a:69:05:0d:62
423429
Device:
424430
id: 234776801163a9ee
@@ -440,9 +446,9 @@ Device:
440446
IMPT COMMAND SUCCEEDS
441447
```
442448
443-
**An entity is not unique, so the command fails**
449+
##### Example 2: An entity is not unique, so the command fails #####
444450
445-
```
451+
```bash
446452
> impt build info --build MyRC1
447453
ERROR: Multiple Deployments "MyRC1" are found:
448454
Deployment:
@@ -483,11 +489,9 @@ As a general rule, if an entity is owned by the current logged-in account, infor
483489
484490
To display the Account ID and email of the current account, use [`impt auth info`](./CommandsManual.md#auth-info).
485491
486-
**Example**
487-
488-
**List all Products owned by me and my collaborators**
492+
##### Example 1: List all Products owned by me and my collaborators #####
489493
490-
```
494+
```bash
491495
> impt product list
492496
impt product list
493497
Product list (4 items):
@@ -512,9 +516,9 @@ Product:
512516
IMPT COMMAND SUCCEEDS
513517
```
514518
515-
**List all Factory Device Groups owned by the specified account**
519+
##### Example 2: List all Factory Device Groups owned by a specified account #####
516520
517-
```
521+
```bash
518522
> impt dg list --owner user@email.com --dg-type pre-factory --dg-type factory
519523
Device Group list (2 items):
520524
Device Group:
@@ -540,9 +544,9 @@ Device Group:
540544
IMPT COMMAND SUCCEEDS
541545
```
542546
543-
**List all Device Groups owned by me and belonged to the specified Products**
547+
##### Example 3: List all Device Groups owned by me and belonging to the specified Products #####
544548
545-
```
549+
```bash
546550
> impt dg list --owner me --product MyProduct --product TestProduct
547551
Device Group list (4 items):
548552
Device Group:
@@ -580,9 +584,9 @@ IMPT COMMAND SUCCEEDS
580584
581585
Most command groups contain the `info` command, which displays information about the specified entity. Some of that commands have a `--full` option (alias: `-u`). When it is specified, the command displays additional details about the related entities. For example, `impt product info --full` displays the full structure of the Product: details about every Device Group that belongs to the Product, and about devices assigned to the Device Groups.
582586
583-
**Example**
587+
##### Example #####
584588
585-
```
589+
```bash
586590
> impt product info --product MyProduct --full
587591
Product:
588592
id: c4e006ed-85b9-3513-fa99-0700333c3ad7
@@ -619,19 +623,17 @@ By default, commands which delete impCentral entities (eg. Product, Device Group
619623
620624
By default, every delete command asks a confirmation of the operation from user. Before that the command lists all the entities which are to be deleted or updated. If you specify the `--confirmed` option (alias: `-q`), the operation is executed without requesting confirmation from the user.
621625
622-
**Example**
626+
##### Example 1: A failed delete command execution #####
623627
624-
**A failed delete command execution**
625-
626-
```
628+
```bash
627629
> impt dg delete --dg MyDevDG --confirmed
628630
ERROR: Flagged Deployments Exist: Cannot delete a devicegroup with flagged deployments; delete those first.
629631
IMPT COMMAND FAILS
630632
```
631633
632-
**A successful delete command execution**
634+
##### Example 2: A successful delete command execution #####
633635
634-
```
636+
```bash
635637
> impt dg delete --dg MyDevDG --force
636638
The following entities will be deleted:
637639
Device Group:

0 commit comments

Comments
 (0)