Skip to content
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

Add Hosting Block Convenience Method to SDK #1029

Merged
merged 18 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.5.0 (2024-03-27)

Added:
- Support Subscriptions API hosting block for Sentinel Hub in the CLI (#1029).

2.4.0 (2024-03-19)

Added:
Expand Down
24 changes: 21 additions & 3 deletions planet/cli/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .session import CliSession
from planet.clients.subscriptions import SubscriptionsClient
from .. import subscription_request
from ..subscription_request import sentinel_hub
from ..specs import get_item_types, validate_item_type, SpecificationException

ALL_ITEM_TYPES = get_item_types()
Expand Down Expand Up @@ -87,13 +88,25 @@ async def list_subscriptions_cmd(ctx, status, limit, pretty):
echo_json(sub, pretty)


@subscriptions.command(name='create') # type: ignore
@click.argument('request', type=types.JSON())
@subscriptions.command(name="create") # type: ignore
@click.argument("request", type=types.JSON())
@click.option(
emma-steuer marked this conversation as resolved.
Show resolved Hide resolved
"--hosting",
default=None,
help='Hosting type. Currently, only "sentinel_hub" is supported.',
)
@click.option(
"--collection_id",
default=None,
help=
"Optional collection ID for Sentinel Hub. If omitted, a new collection will be created.",
)
@pretty
@click.pass_context
@translate_exceptions
@coro
async def create_subscription_cmd(ctx, request, pretty):
async def create_subscription_cmd(ctx, request, hosting, collection_id,
emma-steuer marked this conversation as resolved.
Show resolved Hide resolved
emma-steuer marked this conversation as resolved.
Show resolved Hide resolved
pretty):
"""Create a subscription.

Submits a subscription request for creation and prints the created
Expand All @@ -102,6 +115,11 @@ async def create_subscription_cmd(ctx, request, pretty):
REQUEST is the full description of the subscription to be created. It must
be JSON and can be specified a json string, filename, or '-' for stdin.
"""

if hosting == "sentinel_hub":
hosting_info = sentinel_hub(collection_id)
request["hosting"] = hosting_info

async with subscriptions_client(ctx) as client:
sub = await client.create_subscription(request)
echo_json(sub, pretty)
Expand Down
Loading