1313# the License.
1414"""Functionality for preparing subscription requests."""
1515from datetime import datetime
16- from typing import Any , Dict , Optional , List , Literal , Mapping
16+ from typing import Any , Dict , Optional , List , Literal , Mapping , Sequence
1717
1818from . import geojson , specs
1919from .exceptions import ClientError
@@ -151,6 +151,9 @@ def catalog_source(
151151 filter : Optional [Mapping ] = None ,
152152 end_time : Optional [datetime ] = None ,
153153 rrule : Optional [str ] = None ,
154+ publishing_stages : Optional [Sequence [Literal ["preview" ,
155+ "standard" ,
156+ "finalized" ]]] = None ,
154157) -> dict :
155158 """Construct a Catalog subscription source.
156159
@@ -173,13 +176,38 @@ def catalog_source(
173176 the past or future, and must be after the start_time.
174177 rrule: The recurrence rule, given in iCalendar RFC 5545 format.
175178 Only monthly recurrences are supported at this time.
179+ publishing_stages: A sequence of one or more of the values
180+ "preview", "standard", or "finalized".
176181
177182 Returns:
178183 dict: a representation of a subscription source.
179184
180185 Raises:
181186 ClientError: if a source can not be
182187 configured.
188+
189+ Examples:
190+ ```pycon
191+ >>> source = catalog_source(
192+ ... ["PSScene"],
193+ ... ["ortho_analytic_4b"],
194+ ... geometry={
195+ ... "type": "Polygon",
196+ ... "coordinates": [[[37.791595458984375, 14.84923123791421],
197+ ... [37.90214538574219, 14.84923123791421],
198+ ... [37.90214538574219, 14.945448293647944],
199+ ... [37.791595458984375, 14.945448293647944],
200+ ... [37.791595458984375, 14.84923123791421]]]
201+ ... },
202+ ... start_time=datetime(2021, 3, 1),
203+ ... publishing_stages=["standard"],
204+ ... )
205+ >>> request = build_request(
206+ ... "Standard PSScene Ortho Analytic",
207+ ... source=source,
208+ ... delivery={})
209+ ```
210+
183211 """
184212 if len (item_types ) > 1 :
185213 raise ClientError (
@@ -216,6 +244,9 @@ def catalog_source(
216244 if rrule :
217245 parameters ['rrule' ] = rrule
218246
247+ if publishing_stages :
248+ parameters ['publishing_stages' ] = list (set (publishing_stages ))
249+
219250 return {"type" : "catalog" , "parameters" : parameters }
220251
221252
@@ -275,7 +306,10 @@ def planetary_variable_source(
275306 ... },
276307 ... start_time=datetime(2021, 3, 1)
277308 ... )
278- >>> request = build_request(source=source, ...)
309+ >>> request = build_request(
310+ ... "Soil Water Content",
311+ ... source=source,
312+ ... delivery={})
279313 ```
280314 """
281315 # TODO: validation of variable types and ids.
0 commit comments