Skip to content

Feature request: Support "signing" results #259

Closed
@TomAugspurger

Description

@TomAugspurger

This is a feature request to add an argument to the pystac_client.Client constructor and the from_* classmethods that would enabling "signing" results like those returned by the Planetary Computer and Brazil Data Cube.

Motivation

Some STAC APIs, like the Planetary Computer's, are public but the assets are stored in private blob storage containers. The results returned from the STAC API need to be transformed somehow for the user to read the actual data. For the Planetary Computer, we have users hit another API endpoint that grants them a short-lived token enabling them to read from blob storage. This is implemented in python at https://github.com/microsoft/planetary-computer-sdk-for-python.

In [1]: import requests, pystac_client

In [2]: catalog = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")
   ...: search = catalog.search(collections=["goes-cmi"], query={"goes:image-type": {"eq": "FULL DISK"}, "platform": {"eq": "GOES-16"}}, datetime="2022-06-27/2022-06-29")

In [3]: item = next(search.get_items())

In [4]: requests.head(item.assets["C01_1km"].href).status_code
Out[4]: 404

In [5]: import planetary_computer

In [6]: requests.head(planetary_computer.sign(item.assets["C01_1km"].href)).status_code
Out[6]: 200

This works OK, but does need to be manually called on each result. This request is for convenience: you specifying the signing function once when creating the Client and it calls the callable on each result.

Proposal

Add a new parameter, something like sign_function (name TDB), that's a callable called with the result immediately before returning it to the user. planetary_computer.sign works with URLs, assets, items, or ItemCollections so I'm personally OK with lumping all of those under a single parameter. Alternatively we could have an object with dedicated implementations for each kind of thing being signed (or maybe just Items and ItemCollections, since those are the only thing returned by pystac-client.


Note that odc-stac as implemented something similar with the patch_url function: https://odc-stac.readthedocs.io/en/latest/_api/odc.stac.load.html?highlight=patch_url#odc.stac.load. I think that pystac-client is more appropriate place for this functionality since not all STAC metadata represent data that can be put in a datacube.

Docs for rstac's sign_bdc and sign_planetary_computer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions