-
Notifications
You must be signed in to change notification settings - Fork 98
Add destinations api client #1175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aa6dba8
make source type truly optional for planetary_variable_source
charcey 230c8b0
Merge branch 'main' of github.com:planetlabs/planet-client-python
charcey e8e4f9e
python sync and async cli with tests
charcey 1af648e
add cli, new md
charcey ebcbb1f
more cli tutorial, pass in ref in orders cli on list
charcey dc88d31
back out accidently committed unrelated changes
charcey 544a43d
type edit on cli md
charcey 31cbf82
fix url
charcey 29a57d2
linting
charcey bf5a2fa
lint and add ref to sync list
charcey 362a7de
Apply suggestions from code review
charcey d27901a
Apply suggestions from code review
charcey 68aafaa
Merge branch 'main' of github.com:planetlabs/planet-client-python int…
charcey c439611
update cli args to options, update examples
charcey 6722bea
add cli tests
charcey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| --- | ||
| title: CLI for Destinations API Tutorial | ||
| --- | ||
|
|
||
| ## Introduction | ||
| The `planet destinations` command provides an interface for creating, listing, and modifying destinations in the [Planet Destinations API](https://docs.planet.com/develop/apis/destinations/). This tutorial takes you through the main commands available in the CLI. | ||
|
|
||
| ## Core Workflows | ||
|
|
||
| ### Create a Destination | ||
| To discover supported cloud destinations, run the command `planet destinations create --help`. Once you have chosen your target cloud destination type, run the command `planet destinations create <type> --help` to discover the required and supported parameters (eg: `planet destinations create s3 --help`). | ||
|
|
||
| Finally, submit the full request: | ||
| ```sh | ||
| planet destinations create s3 --bucket my-bucket --region us-west-2 --access-key-id AKIA... --secret-access-key SECRET... --name my-s3-destination | ||
| ``` | ||
|
|
||
| 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. | ||
|
|
||
| ### List Destinations | ||
| List all destinations within your organization with command `planet destinations list`. | ||
|
|
||
| You can get nicer formatting with `--pretty` or pipe it into `jq`, just like the other Planet CLIs. | ||
|
|
||
| #### Filtering | ||
| The `list` command supports filtering on a variety of fields. You can discover all filterable fields by running the command `planet destinations list --help`. | ||
|
|
||
| * `--archived`: Set to true to include only archived destinations, | ||
| false to exclude them. | ||
| * `--is-owner`: Set to true to include only destinations owned by the | ||
| requesting user, false to exclude them. | ||
| * `--can-write`: Set to true to include only destinations the user can | ||
| modify, false to exclude them. | ||
|
|
||
| For example, to list destinations that are not archived and you can modify you would issue the following command: | ||
| ```sh | ||
| planet destinations list --archived false --can-write true | ||
| ``` | ||
|
|
||
| ### Modify Destinations | ||
| 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`. | ||
|
|
||
| To discover more information about a specific update action, use the `--help` flag (eg: `planet destinations rename --help`, `planet destinations update --help`). | ||
|
|
||
| Credential updating might be done if credentials expire or need to be rotated. For example, this is how s3 credentials would be updated. | ||
| ```sh | ||
| planet destinations update s3 my-destination-id --access-key-id NEW_ACCESS_KEY --secret-access-key NEW_SECRET_KEY | ||
| ``` | ||
|
|
||
| ## Using destinations in Subscriptions API | ||
| After creating a destination, it can be used as the delivery location for subscriptions. Use the destination reference in the delivery block instead of credentials. | ||
|
|
||
| The subsequent examples will use the destination ref `pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX`. | ||
| ```json | ||
| { | ||
| "name": "Subscription using a destination", | ||
| "source": { | ||
| "parameters": { | ||
| "asset_types": [ | ||
| "ortho_analytic_8b" | ||
| ], | ||
| "end_time": "2023-11-01T00:00:00Z", | ||
| "geometry": { | ||
| "coordinates": [ | ||
| [ | ||
| [ | ||
| 139.5648193359375, | ||
| 35.42374884923695 | ||
| ], | ||
| [ | ||
| 140.1031494140625, | ||
| 35.42374884923695 | ||
| ], | ||
| [ | ||
| 140.1031494140625, | ||
| 35.77102915686019 | ||
| ], | ||
| [ | ||
| 139.5648193359375, | ||
| 35.77102915686019 | ||
| ], | ||
| [ | ||
| 139.5648193359375, | ||
| 35.42374884923695 | ||
| ] | ||
| ] | ||
| ], | ||
| "type": "Polygon" | ||
| }, | ||
| "item_types": [ | ||
| "PSScene" | ||
| ], | ||
| "start_time": "2023-03-17T04:08:00.0Z" | ||
| } | ||
| }, | ||
| "delivery": { | ||
| "type": "destination", | ||
| "parameters": { | ||
| "ref": "pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX", | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Then create the subscription, with the json above saved to a file. | ||
| ```sh | ||
| planet subscriptions create my-subscription.json | ||
| ``` | ||
|
|
||
| The results of the created subscription will be delivered to the destination provided. | ||
|
|
||
| To retrieve all subscriptions created with a specific destination, issue the following command: | ||
| ```sh | ||
| planet subscriptions list --destination-ref pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX | ||
| ``` | ||
|
|
||
| ## Using destinations in Orders API | ||
| After creating a destination, it can be used as the delivery location for orders. Use the destination reference in the delivery block instead of credentials. | ||
|
|
||
| The subsequent examples will use the destination ref `pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX`. | ||
| ```json | ||
| { | ||
| "name": "Order using a destination", | ||
| "products": [ | ||
| { | ||
| "item_ids": [ | ||
| "20220605_124027_64_242b" | ||
| ], | ||
| "item_type": "PSScene", | ||
| "product_bundle": "analytic_sr_udm2" | ||
| } | ||
| ], | ||
| "delivery": { | ||
| "destination": { | ||
| "ref": "pl:destinations/cp-gcs-6HRjBcW74jeH9SC4VElKqX" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Then create the order, with the json above saved to a file. | ||
| ```sh | ||
| planet orders create my-order.json | ||
| ``` | ||
|
|
||
| The results of the created order will be delivered to the destination provided. | ||
|
|
||
| To retrieve all orders created with a specific destination, issue the following command: | ||
| ```sh | ||
| planet orders list --destination-ref pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.