Skip to content

v2: add cli for orders api #284

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 38 commits into from
Jul 15, 2021
Merged

v2: add cli for orders api #284

merged 38 commits into from
Jul 15, 2021

Conversation

jreiberkyle
Copy link
Contributor

@jreiberkyle jreiberkyle commented Jun 9, 2021

This PR adds a CLI as a thin wrapper around the python api orders client. Functionality was added to the orders client and other modules to support back-compatible CLI functionality while keeping the CLI thin.

One addition to the API is implemented:
Simple management of geojson, via the new planet/geojson.py module

Two changes to the python API are implemented:

  1. OrdersClient.create_order() now returns the entire order description (as returned by the API) instead of just the id.
    This aligns with the rule of "make the client as similar to the REST API as possible" and allows the cli to easily report the details as a json blob that can be processed or viewed via the command line.
  2. Delivery.from_dict() tries to create a subclass if possible.
    For example, if the dict describes an AmazonS3Delivery, it makes an instance of that class. This is necessary because a Delivery only holds the minimum delivery information while a subclass holds more information about the specific cloud. This change allows the cli to just call Delivery.from_dict() while parsing a file and have the proper information passed into OrdersClient.create_order().

Other than that, the API changes are improved error handling.

Wish list: The cli.py module got huge quick. I would like to break it up into different modules based on api (e.g. auth and orders). Ticket #288

Closes #244
Closes #252

@jreiberkyle jreiberkyle self-assigned this Jun 9, 2021
@jreiberkyle jreiberkyle requested a review from sarasafavi June 9, 2021 20:31
Copy link
Contributor

@sarasafavi sarasafavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor fix request re: planet.geojson -- otherwise this LGTM! And it works on my box, too :-D

Really great work @jreiberkyle I am SO EXCITED to see this happening!

raise GeoJSONException('Invalid GeoJSON: {data}')

if len(features) > 1:
LOGGER.warning(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to raise DataLossWarning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for bringing this up and for our offline discussion. I'll raise an exception when multiple features are given.


class DataLossWarning(UserWarning):
"""Warn that data will be lost."""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency add the pass no-op here too

geom_geojson['coordinates'] = []
_ = geojson.validate_geom(geom_geojson)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's test_validate_geom_multiple_features (or whatever) here too :)

@jreiberkyle
Copy link
Contributor Author

thank you so much @sarasafavi for the in-depth review. changes made, merging now. YASSS!!

@jreiberkyle jreiberkyle merged commit 06aab6c into v2 Jul 15, 2021
@jreiberkyle jreiberkyle deleted the v2-cli-244 branch July 15, 2021 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement cli auth key retrieval implement cli for orders client
2 participants