Skip to content

Commit c439611

Browse files
committed
update cli args to options, update examples
1 parent 68aafaa commit c439611

File tree

2 files changed

+101
-74
lines changed

2 files changed

+101
-74
lines changed

docs/cli/cli-destinations.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To discover supported cloud destinations, run the command `planet destinations c
1212

1313
Finally, submit the full request:
1414
```sh
15-
planet destinations create s3 my-bucket us-west-2 AKIA... SECRET... --name my-s3-destination
15+
planet destinations create s3 --bucket my-bucket --region us-west-2 --access-key-id AKIA... --secret-access-key SECRET... --name my-s3-destination
1616
```
1717

1818
The newly created destination will be printed to stdout, with the destination reference under the key `pl:ref`, which can subsequently be used in Orders API and Subscriptions API requests as the delivery destination.
@@ -25,23 +25,26 @@ You can get nicer formatting with `--pretty` or pipe it into `jq`, just like the
2525
#### Filtering
2626
The `list` command supports filtering on a variety of fields. You can discover all filterable fields by running the command `planet destinations list --help`.
2727

28-
* `--archived / --is-not-archived`: Filter by archive status. Use --archived to include only archived destinations, or --is-not-archived to list only active (not archived) destinations.
29-
* `--is-owner / --is-not-owner`: Filter by ownership. Use --is-owner to include only destinations owned by the requesting user, or --is-not-owner to include destinations not owned by the user.
30-
* `--can-write / --can-not-write`: Filter by write access. Use --can-write to include only destinations the user can modify, or --can-not-write to list destinations with read-only access for the user.
28+
* `--archived`: Set to true to include only archived destinations,
29+
false to exclude them.
30+
* `--is-owner`: Set to true to include only destinations owned by the
31+
requesting user, false to exclude them.
32+
* `--can-write`: Set to true to include only destinations the user can
33+
modify, false to exclude them.
3134

3235
For example, to list destinations that are not archived and you can modify you would issue the following command:
3336
```sh
34-
planet destinations list --not-archived --can-write
37+
planet destinations list --archived false --can-write true
3538
```
3639

37-
### Update Destinations
38-
The CLI conveniently moves all update actions to first class commands on the destination. The supported actions are archive, unarchive, rename, and update credentials. To discover all update actions run `planet destinations --help`.
40+
### Modify Destinations
41+
The CLI conveniently moves all modify actions to first class commands on the destination. The supported actions are archive, unarchive, rename, and update credentials. To discover all update actions run `planet destinations --help`.
3942

4043
To discover more information about a specific update action, use the `--help` flag (eg: `planet destinations rename --help`, `planet destinations update --help`).
4144

4245
Credential updating might be done if credentials expire or need to be rotated. For example, this is how s3 credentials would be updated.
4346
```sh
44-
planet destinations update parameters s3 my-destination-id NEW_ACCESS_KEY NEW_SECRET_KEY
47+
planet destinations update s3 my-destination-id --access-key-id NEW_ACCESS_KEY --secret-access-key NEW_SECRET_KEY
4548
```
4649

4750
## Using destinations in Subscriptions API

planet/cli/destinations.py

Lines changed: 90 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,22 @@ async def _create_destination(ctx, data, pretty):
6666

6767

6868
@command(destinations, name="list")
69+
@click.option('--archived',
70+
type=bool,
71+
default=None,
72+
help="""Set to true to include only archived destinations,
73+
false to exclude them.""")
74+
@click.option('--is-owner',
75+
type=bool,
76+
default=None,
77+
help="""Set to true to include only destinations owned by the
78+
requesting user, false to exclude them.""")
6979
@click.option(
70-
'--archived/--is-not-archived',
71-
default=None,
72-
help="""Filter by archive status. Use --archived to include only archived
73-
destinations, or --is-not-archived to list only active (not archived)
74-
destinations.""")
75-
@click.option(
76-
'--is-owner/--is-not-owner',
80+
'--can-write',
81+
type=bool,
7782
default=None,
78-
help="""Filter by ownership. Use --is-owner to include only destinations
79-
owned by the requesting user, or --is-not-owner to include destinations
80-
not owned by the user.""")
81-
@click.option('--can-write/--can-not-write',
82-
default=None,
83-
help="""Filter by write access. Use --can-write to include only
84-
destinations the user can modify, or --can-not-write to list destinations
85-
with read-only access for the user.""")
83+
help="""Set to true to include only destinations the user can modify,
84+
false to exclude them.""")
8685
async def list_destinations(ctx, archived, is_owner, can_write, pretty):
8786
"""
8887
List destinations with optional filters
@@ -92,7 +91,7 @@ async def list_destinations(ctx, archived, is_owner, can_write, pretty):
9291
9392
Example:
9493
95-
planet destinations list --not-archived --is-owner --can-write
94+
planet destinations list --archived false --is-owner true --can-write true
9695
"""
9796
await _list_destinations(ctx, archived, is_owner, can_write, pretty)
9897

@@ -120,10 +119,12 @@ def create():
120119

121120

122121
@command(create, name="s3")
123-
@click.argument("bucket")
124-
@click.argument("region")
125-
@click.argument("access_key_id")
126-
@click.argument("secret_access_key")
122+
@click.option("--bucket", required=True, help="S3 bucket name.")
123+
@click.option("--region", required=True, help="AWS region.")
124+
@click.option("--access-key-id", required=True, help="AWS access key ID.")
125+
@click.option("--secret-access-key",
126+
required=True,
127+
help="AWS secret access key.")
127128
@click.option("--explicit-sse",
128129
is_flag=True,
129130
help="Explicitly set headers for server-side encryption (SSE).")
@@ -147,7 +148,7 @@ async def create_s3(ctx,
147148
148149
Example:
149150
150-
planet destinations create s3 my-bucket us-west-2 AKIA... SECRET... --name my-s3-destination
151+
planet destinations create s3 --bucket my-bucket --region us-west-2 --access-key-id AKIA... --secret-access-key SECRET... --name my-s3-destination
151152
"""
152153
data = {
153154
"type": "amazon_s3",
@@ -168,11 +169,11 @@ async def create_s3(ctx,
168169

169170

170171
@command(create, name="s3-compatible")
171-
@click.argument("bucket")
172-
@click.argument("endpoint")
173-
@click.argument("region")
174-
@click.argument("access_key_id")
175-
@click.argument("secret_access_key")
172+
@click.option("--bucket", required=True, help="Bucket name.")
173+
@click.option("--endpoint", required=True, help="Endpoint URL.")
174+
@click.option("--region", required=True, help="Region.")
175+
@click.option("--access-key-id", required=True, help="Access key ID.")
176+
@click.option("--secret-access-key", required=True, help="Secret access key.")
176177
@click.option("--use-path-style",
177178
is_flag=True,
178179
default=False,
@@ -199,7 +200,7 @@ async def create_s3_compatible(ctx,
199200
200201
Example:
201202
202-
planet destinations create s3-compatible my-bucket https://objects.example.com us-east-1 AKIA... SECRET... --name my-s3-destination
203+
planet destinations create s3-compatible --bucket my-bucket --endpoint https://objects.example.com --region us-east-1 --access-key-id AKIA... --secret-access-key SECRET... --name my-s3-comp-destination
203204
"""
204205
data = {
205206
"type": "s3_compatible",
@@ -221,11 +222,19 @@ async def create_s3_compatible(ctx,
221222

222223

223224
@command(create, name="ocs")
224-
@click.argument("bucket")
225-
@click.argument("access_key_id")
226-
@click.argument("secret_access_key")
227-
@click.argument("namespace")
228-
@click.argument("region")
225+
@click.option("--bucket", required=True, help="Oracle bucket name.")
226+
@click.option("--access-key-id",
227+
required=True,
228+
help="Oracle account access key.")
229+
@click.option("--secret-access-key",
230+
required=True,
231+
help="Oracle account secret key.")
232+
@click.option("--namespace",
233+
required=True,
234+
help="Oracle Object Storage namespace.")
235+
@click.option("--region",
236+
required=True,
237+
help="Oracle region bucket resides in.")
229238
@click.option('--name',
230239
help="""Optional name to assign to the destination.
231240
Otherwise, the bucket name is used.""")
@@ -246,7 +255,7 @@ async def create_ocs(ctx,
246255
247256
Example:
248257
249-
planet destinations create ocs my-bucket OCID... SECRET... my-namespace us-ashburn-1 --name my-ocs-destination
258+
planet destinations create ocs --bucket my-bucket --access-key-id OCID... --secret-access-key SECRET... --namespace my-namespace --region us-ashburn-1 --name my-ocs-destination
250259
"""
251260
data = {
252261
"type": "oracle_cloud_storage",
@@ -266,13 +275,16 @@ async def create_ocs(ctx,
266275

267276

268277
@command(create, name="azure")
269-
@click.argument("container")
270-
@click.argument("account")
271-
@click.argument("sas_token")
278+
@click.option("--container",
279+
required=True,
280+
help="Blob storage container name.")
281+
@click.option("--account", required=True, help="Azure account.")
282+
@click.option("--sas-token",
283+
required=True,
284+
help="Shared-Access Signature token.")
272285
@click.option('--storage-endpoint-suffix',
273286
required=False,
274-
help="""Custom Azure Storage endpoint suffix
275-
(e.g., 'core.windows.net' or for sovereign clouds).""")
287+
help="Custom Azure Storage endpoint suffix.")
276288
@click.option('--name',
277289
help="""Optional name to assign to the destination.
278290
Otherwise, the bucket name is used.""")
@@ -286,13 +298,13 @@ async def create_azure(ctx,
286298
"""
287299
Create a new Azure Blob Storage destination.
288300
289-
This command configures a destination in Azure Blob Storage using the specified container name,
301+
This command sets up a destination in Azure Blob Storage using the specified container name,
290302
storage account name, and SAS token. You can optionally specify a custom endpoint suffix
291303
and assign a name to the destination.
292304
293305
Example:
294306
295-
planet destinations create azure my-container mystorage ?sv=... --name my-azure-destination
307+
planet destinations create azure --container my-container --account mystorage --sas-token ?sv=... --name my-azure-destination
296308
"""
297309

298310
data = {
@@ -313,29 +325,32 @@ async def create_azure(ctx,
313325

314326

315327
@command(create, name="gcs")
316-
@click.argument("bucket")
317-
@click.argument("credentials")
328+
@click.option("--bucket", required=True, help="GCS bucket name.")
329+
@click.option("--credentials",
330+
required=True,
331+
help="Base64-encoded service account credentials (JSON).")
318332
@click.option('--name',
319333
help="""Optional name to assign to the destination.
320334
Otherwise, the bucket name is used.""")
321335
async def create_gcs(ctx, bucket, credentials, name, pretty):
322336
"""
323337
Create a new Google Cloud Storage (GCS) destination.
324338
325-
This command sets up a GCS destination using the specified bucket name and
326-
base64-encoded service account credentials (in JSON format). You can optionally
327-
assign a name to the destination for easier reference.
339+
This command sets up a GCS destination using the specified bucket name
340+
and base64-encoded service account credentials (in JSON format). You can
341+
optionally assign a name to the destination for easier reference.
328342
329343
Note:
330-
The `credentials` argument must be the base64-encoded JSON of your Google Cloud
331-
service account key. To encode a JSON file to base64, you can use the following
332-
command:
344+
345+
The `credentials` argument must be the base64-encoded JSON of your
346+
Google Cloud service account key. To encode a JSON file to base64,
347+
you can use the following command:
333348
334349
cat my_creds.json | base64 | tr -d '\n'
335350
336351
Example:
337352
338-
planet destinations create gcs my-bucket eyJ0eXAiOiJKV1Qi... --name my-gcs-destination
353+
planet destinations create gcs --bucket my-bucket --credentials eyJ0eXAiOiJKV1Qi... --name my-gcs-destination
339354
"""
340355
data = {
341356
"type": "google_cloud_storage",
@@ -416,8 +431,10 @@ async def rename(ctx, destination_id, name, pretty):
416431

417432
@command(update, name="s3")
418433
@click.argument('destination_id')
419-
@click.argument('access_key_id')
420-
@click.argument('secret_access_key')
434+
@click.option('--access-key-id', required=True, help="AWS access key ID.")
435+
@click.option('--secret-access-key',
436+
required=True,
437+
help="AWS secret access key.")
421438
@click.option('--explicit-sse',
422439
is_flag=True,
423440
help='Explicitly set headers for server-side encryption (SSE).')
@@ -431,13 +448,13 @@ async def update_s3(ctx,
431448
Update S3 destination parameters.
432449
433450
This command updates the parameters of an existing S3 destination, including the
434-
`access_key_id`, `secret_access_key`, and optionally sets headers for server-side
451+
`access-key-id`, `secret-access-key`, and optionally sets headers for server-side
435452
encryption (SSE) using the `explicit-sse` flag. The updated parameters will be applied
436453
to the destination configuration without altering the destination’s other properties.
437454
438455
Example:
439456
440-
planet destinations update parameters s3 my-destination-id NEW_ACCESS_KEY NEW_SECRET_KEY
457+
planet destinations update s3 my-destination-id --access-key-id NEW_ACCESS_KEY --secret-access-key NEW_SECRET_KEY
441458
"""
442459
data = {
443460
"parameters": {
@@ -454,18 +471,18 @@ async def update_s3(ctx,
454471

455472
@command(update, name="azure")
456473
@click.argument('destination_id')
457-
@click.argument('sas_token')
474+
@click.option('--sas-token', required=True, help="New SAS token.")
458475
async def update_azure(ctx, destination_id, sas_token, pretty):
459476
"""
460477
Update Azure destination parameters.
461478
462479
This command updates the parameters of an existing Azure destination, specifically
463-
the `sas_token`. The updated SAS token will be applied to the destination configuration
480+
the `sas-token`. The updated SAS token will be applied to the destination configuration
464481
without affecting other destination properties.
465482
466483
Example:
467484
468-
planet destinations update parameters azure my-destination-id NEW_SAS_TOKEN
485+
planet destinations update azure my-destination-id --sas-token NEW_SAS_TOKEN
469486
"""
470487
data = {"parameters": {"sas_token": sas_token}}
471488

@@ -474,7 +491,9 @@ async def update_azure(ctx, destination_id, sas_token, pretty):
474491

475492
@command(update, name="gcs")
476493
@click.argument('destination_id')
477-
@click.argument('credentials')
494+
@click.option('--credentials',
495+
required=True,
496+
help="Base64-encoded service account credentials (JSON).")
478497
async def update_gcs(ctx, destination_id, credentials, pretty):
479498
"""
480499
Update Google Cloud Storage (GCS) destination parameters.
@@ -484,6 +503,7 @@ async def update_gcs(ctx, destination_id, credentials, pretty):
484503
credentials will be applied to the destination configuration without altering other properties.
485504
486505
Note:
506+
487507
The `credentials` argument must be the base64-encoded JSON of your Google Cloud
488508
service account key. To encode a JSON file to base64, you can use the following
489509
command:
@@ -492,7 +512,7 @@ async def update_gcs(ctx, destination_id, credentials, pretty):
492512
493513
Example:
494514
495-
planet destinations update parameters gcs my-destination-id eyJ0eXAiOiJKV1Qi...
515+
planet destinations update gcs my-destination-id --credentials eyJ0eXAiOiJKV1Qi...
496516
"""
497517
data = {"parameters": {"credentials": credentials}}
498518

@@ -501,8 +521,12 @@ async def update_gcs(ctx, destination_id, credentials, pretty):
501521

502522
@command(update, name="ocs")
503523
@click.argument('destination_id')
504-
@click.argument('access_key_id')
505-
@click.argument('secret_access_key')
524+
@click.option('--access-key-id',
525+
required=True,
526+
help="Oracle account access key.")
527+
@click.option('--secret-access-key',
528+
required=True,
529+
help="Oracle account secret key.")
506530
async def update_ocs(ctx,
507531
destination_id,
508532
access_key_id,
@@ -512,12 +536,12 @@ async def update_ocs(ctx,
512536
Update Oracle Cloud Storage (OCS) destination parameters.
513537
514538
This command updates the parameters of an existing Oracle Cloud Storage destination,
515-
including the `access_key_id` and `secret_access_key`. The updated credentials will
539+
including the `access-key-id` and `secret-access-key`. The updated credentials will
516540
be applied to the destination configuration without affecting other properties.
517541
518542
Example:
519543
520-
planet destinations update parameters ocs my-destination-id NEW_ACCESS_KEY NEW_SECRET_KEY
544+
planet destinations update ocs my-destination-id --access-key-id NEW_ACCESS_KEY --secret-access-key NEW_SECRET_KEY
521545
"""
522546

523547
data = {
@@ -532,8 +556,8 @@ async def update_ocs(ctx,
532556

533557
@command(update, name="s3-compatible")
534558
@click.argument("destination_id")
535-
@click.argument("access_key_id")
536-
@click.argument("secret_access_key")
559+
@click.option("--access-key-id", required=True, help="Access key ID.")
560+
@click.option("--secret-access-key", required=True, help="Secret access key.")
537561
@click.option("--use-path-style",
538562
is_flag=True,
539563
help="Use path-style addressing with bucket name in the URL.")
@@ -547,13 +571,13 @@ async def update_s3_compatible(ctx,
547571
Update S3-compatible destination parameters.
548572
549573
This command updates the parameters of an existing S3-compatible destination,
550-
including the `access_key_id` and `secret_access_key`. You can also optionally
574+
including the `access-key-id` and `secret-access-key`. You can also optionally
551575
enable path-style addressing using the `--use-path-style` flag. The updated parameters
552576
will be applied to the destination configuration without affecting other properties.
553577
554578
Example:
555579
556-
planet destinations update parameters s3-compatible my-destination-id NEW_ACCESS_KEY NEW_SECRET_KEY
580+
planet destinations update s3-compatible my-destination-id --access-key-id NEW_ACCESS_KEY --secret-access-key NEW_SECRET_KEY
557581
"""
558582
data = {
559583
"parameters": {

0 commit comments

Comments
 (0)