def save_object(self, include_self_link=True, dest_href=None): """Saves this STAC Object to it's 'self' HREF. Args: include_self_link (bool): If this is true, include the 'self' link with this object. Otherwise, leave out the self link. dest_href (str): Optional HREF to save the file to. If None, the object will be saved to the object's self href. Raises: :class:`~pystac.STACError`: If no self href is set, this error will be raised. Note: When to include a self link is described in the `Use of Links section of the STAC best practices document <https://github.com/radiantearth/stac-spec/blob/v0.8.1/best-practices.md#use-of-links>`_ """ if dest_href is None: self_href = self.get_self_href() if self_href is None: raise STACError( 'Self HREF must be set before saving without an explicit dest_href.') dest_href = self_href STAC_IO.save_json(dest_href, self.to_dict(include_self_link=include_self_link))
def save(self, href=None, include_self_link=True): """Saves this ItemCollection. Args: href (str): The HREF to save the ItemCollection to. If None, will save to the currently set ``self`` link. If supplied, will set this href to the ItemCollection's self link. include_self_link (bool): If True, will include the self link in the set of links of the saved JSON. """ if href is None: href = self.get_self_href() if href is None: raise STACError('Must either supply an href or set a self href on ' 'this ItemCollection.') else: self.set_self_href(href) STAC_IO.save_json(href, self.to_dict(include_self_link=include_self_link))