|
| 1 | +--- |
| 2 | +title: CLI for Destinations API Tutorial |
| 3 | +--- |
| 4 | + |
| 5 | +## Introduction |
| 6 | +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. |
| 7 | + |
| 8 | +## Core Workflows |
| 9 | + |
| 10 | +### Create a Destination |
| 11 | +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`). |
| 12 | + |
| 13 | +Finally, submit the full request: |
| 14 | +```sh |
| 15 | +planet destinations create s3 --bucket my-bucket --region us-west-2 --access-key-id AKIA... --secret-access-key SECRET... --name my-s3-destination |
| 16 | +``` |
| 17 | + |
| 18 | +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. |
| 19 | + |
| 20 | +### List Destinations |
| 21 | +List all destinations within your organization with command `planet destinations list`. |
| 22 | + |
| 23 | +You can get nicer formatting with `--pretty` or pipe it into `jq`, just like the other Planet CLIs. |
| 24 | + |
| 25 | +#### Filtering |
| 26 | +The `list` command supports filtering on a variety of fields. You can discover all filterable fields by running the command `planet destinations list --help`. |
| 27 | + |
| 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. |
| 34 | + |
| 35 | +For example, issue the following command to list destinations that are not archived and you as the user have permission to modify: |
| 36 | +```sh |
| 37 | +planet destinations list --archived false --can-write true |
| 38 | +``` |
| 39 | + |
| 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`. |
| 42 | + |
| 43 | +To discover more information about a specific update action, use the `--help` flag (eg: `planet destinations rename --help`, `planet destinations update --help`). |
| 44 | + |
| 45 | +Credential updating might be done if credentials expire or need to be rotated. For example, this is how s3 credentials would be updated. |
| 46 | +```sh |
| 47 | +planet destinations update s3 my-destination-id --access-key-id NEW_ACCESS_KEY --secret-access-key NEW_SECRET_KEY |
| 48 | +``` |
| 49 | + |
| 50 | +## Using destinations in Subscriptions API |
| 51 | +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. |
| 52 | + |
| 53 | +The subsequent examples will use the destination ref `pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX`. |
| 54 | +```json |
| 55 | +{ |
| 56 | + "name": "Subscription using a destination", |
| 57 | + "source": { |
| 58 | + "parameters": { |
| 59 | + "asset_types": [ |
| 60 | + "ortho_analytic_8b" |
| 61 | + ], |
| 62 | + "end_time": "2023-11-01T00:00:00Z", |
| 63 | + "geometry": { |
| 64 | + "coordinates": [ |
| 65 | + [ |
| 66 | + [ |
| 67 | + 139.5648193359375, |
| 68 | + 35.42374884923695 |
| 69 | + ], |
| 70 | + [ |
| 71 | + 140.1031494140625, |
| 72 | + 35.42374884923695 |
| 73 | + ], |
| 74 | + [ |
| 75 | + 140.1031494140625, |
| 76 | + 35.77102915686019 |
| 77 | + ], |
| 78 | + [ |
| 79 | + 139.5648193359375, |
| 80 | + 35.77102915686019 |
| 81 | + ], |
| 82 | + [ |
| 83 | + 139.5648193359375, |
| 84 | + 35.42374884923695 |
| 85 | + ] |
| 86 | + ] |
| 87 | + ], |
| 88 | + "type": "Polygon" |
| 89 | + }, |
| 90 | + "item_types": [ |
| 91 | + "PSScene" |
| 92 | + ], |
| 93 | + "start_time": "2023-03-17T04:08:00.0Z" |
| 94 | + } |
| 95 | + }, |
| 96 | + "delivery": { |
| 97 | + "type": "destination", |
| 98 | + "parameters": { |
| 99 | + "ref": "pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX", |
| 100 | + } |
| 101 | + } |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +Then create the subscription, with the json above saved to a file. |
| 106 | +```sh |
| 107 | +planet subscriptions create my-subscription.json |
| 108 | +``` |
| 109 | + |
| 110 | +The results of the created subscription will be delivered to the destination provided. |
| 111 | + |
| 112 | +To retrieve all subscriptions created with a specific destination, issue the following command: |
| 113 | +```sh |
| 114 | +planet subscriptions list --destination-ref pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX |
| 115 | +``` |
| 116 | + |
| 117 | +## Using destinations in Orders API |
| 118 | +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. |
| 119 | + |
| 120 | +The subsequent examples will use the destination ref `pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX`. |
| 121 | +```json |
| 122 | +{ |
| 123 | + "name": "Order using a destination", |
| 124 | + "products": [ |
| 125 | + { |
| 126 | + "item_ids": [ |
| 127 | + "20220605_124027_64_242b" |
| 128 | + ], |
| 129 | + "item_type": "PSScene", |
| 130 | + "product_bundle": "analytic_sr_udm2" |
| 131 | + } |
| 132 | + ], |
| 133 | + "delivery": { |
| 134 | + "destination": { |
| 135 | + "ref": "pl:destinations/cp-gcs-6HRjBcW74jeH9SC4VElKqX" |
| 136 | + } |
| 137 | + } |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +Then create the order, with the json above saved to a file. |
| 142 | +```sh |
| 143 | +planet orders create my-order.json |
| 144 | +``` |
| 145 | + |
| 146 | +The results of the created order will be delivered to the destination provided. |
| 147 | + |
| 148 | +To retrieve all orders created with a specific destination, issue the following command: |
| 149 | +```sh |
| 150 | +planet orders list --destination-ref pl:destinations/my-s3-destination-6HRjBcW74jeH9SC4VElKqX |
| 151 | +``` |
0 commit comments