Skip to content

Commit e90f3e2

Browse files
authored
Merge pull request #855 from planetlabs/subscription-request-api
Implement subscription request helper methods in python api
2 parents 3f3f612 + 7aa40b7 commit e90f3e2

File tree

8 files changed

+771
-18
lines changed

8 files changed

+771
-18
lines changed

docs/python/sdk-reference.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ title: Python SDK API Reference
2626
rendering:
2727
show_root_full_path: false
2828

29+
## ::: planet.SubscriptionsClient
30+
rendering:
31+
show_root_full_path: false
32+
33+
## ::: planet.subscription_request
34+
rendering:
35+
show_root_full_path: false
36+
2937
## ::: planet.reporting
3038
rendering:
3139
show_root_full_path: false

planet/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
from .http import Session
16-
from . import order_request, reporting
16+
from . import data_filter, order_request, reporting, subscription_request
1717
from .__version__ import __version__ # NOQA
1818
from .auth import Auth
19-
from .clients import DataClient, OrdersClient # NOQA
19+
from .clients import DataClient, OrdersClient, SubscriptionsClient # NOQA
2020
from .io import collect
2121

2222
__all__ = [
2323
'Auth',
2424
'collect',
25-
'DataClient'
25+
'DataClient',
26+
'data_filter',
2627
'OrdersClient',
2728
'order_request',
2829
'reporting',
2930
'Session',
31+
'SubscriptionsClient',
32+
'subscription_request'
3033
]

planet/clients/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
# limitations under the License.
1515
from .data import DataClient
1616
from .orders import OrdersClient
17+
from .subscriptions import SubscriptionsClient
1718

18-
__all__ = [
19-
'DataClient',
20-
'OrdersClient',
21-
]
19+
__all__ = ['DataClient', 'OrdersClient', 'SubscriptionsClient']

planet/order_request.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def build_request(name: str,
3434
'''Prepare an order request.
3535
3636
```python
37-
>>> from planet.api.order_details import (
37+
>>> from planet.order_request import (
3838
... build_request, product, toar_tool, reproject_tool, tile_tool)
3939
...
4040
>>> products = [
@@ -332,7 +332,7 @@ def clip_tool(aoi: dict) -> dict:
332332
aoi: clip GeoJSON, either Polygon or Multipolygon.
333333
334334
Raises:
335-
geojson.GeoJSONException: If GeoJSON is not a valid polygon or
335+
planet.exceptions.ClientError: If GeoJSON is not a valid polygon or
336336
multipolygon.
337337
'''
338338
valid_types = ['Polygon', 'MultiPolygon']
@@ -421,7 +421,7 @@ def tile_tool(tile_size: int,
421421
return _tool('tile', parameters)
422422

423423

424-
def toar_tool(scale_factor: Optional[int] = None, ) -> dict:
424+
def toar_tool(scale_factor: Optional[int] = None) -> dict:
425425
'''Create the API spec representation of a TOAR tool.
426426
427427
Parameters:
@@ -439,9 +439,19 @@ def toar_tool(scale_factor: Optional[int] = None, ) -> dict:
439439
def harmonize_tool(target_sensor: str) -> dict:
440440
'''Create the API spec representation of a harmonize tool.
441441
442-
Currently, only "PS2" (Dove Classic) and "Sentinel-2" are supported as
443-
target sensors. The Sentinel-2 target only harmonizes PSScene
444-
surface reflectance bundle types (analytic_8b_sr_udm2, analytic_sr_udm2).
445-
The PS2 target only works on analytic bundles from Dove-R (PS2.SD).
442+
Parameters:
443+
target_sensor: A value indicating to what sensor the input asset types
444+
should be calibrated.
445+
446+
Raises:
447+
planet.exceptions.ClientError: If target_sensor is not valid.
446448
'''
449+
450+
try:
451+
target_sensor = specs.get_match(target_sensor,
452+
specs.HARMONIZE_TOOL_TARGET_SENSORS,
453+
'target_sensor')
454+
except specs.SpecificationException as e:
455+
raise ClientError(e)
456+
447457
return _tool('harmonize', {'target_sensor': target_sensor})

planet/specs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
SUPPORTED_ORDER_TYPES = ['full', 'partial']
3434
SUPPORTED_ARCHIVE_TYPES = ['zip']
3535
SUPPORTED_FILE_FORMATS = ['COG', 'PL_NITF']
36+
HARMONIZE_TOOL_TARGET_SENSORS = ('Sentinel-2', 'PS2')
3637

3738
LOGGER = logging.getLogger(__name__)
3839

0 commit comments

Comments
 (0)