config

Module for managing configuration data from config.json

class sentinelhub.config.SHConfig[source]

Bases: object

This is a singleton implementation of the sentinelhub configuration class.

The class reads during its first initialization the configurable settings from ./config.json file:

  • instance_id: Users’ instance id. User can set it to his/hers instance id in config.json instead of specifying it explicitly every time he/she creates new ogc request.
  • aws_access_key_id: Access key for AWS Requester Pays buckets.
  • aws_secret_access_key: Secret access key for AWS Requester Pays buckets.
  • ogc_base_url: Base url for Sentinel Hub’s services.
  • geopedia_wms_url: Base url for Geopedia WMS services.
  • geopedia_rest_url: Base url for Geopedia REST services.
  • aws_metadata_url: Base url for publicly available metadata files
  • aws_s3_l1c_bucket: Name of Sentinel-2 L1C bucket at AWS s3 service.
  • aws_s3_l2a_bucket: Name of Sentinel-2 L2A bucket at AWS s3 service.
  • opensearch_url: Base url for Sentinelhub Opensearch service.
  • max_wfs_records_per_query: Maximum number of records returned for each WFS query.
  • max_opensearch_records_per_query: Maximum number of records returned for each Opensearch query.
  • default_start_date: In case time parameter for OGC data requests is not specified this will be used for start date of the interval.
  • max_download_attempts: Maximum number of download attempts from a single URL until an error will be raised.
  • download_sleep_time: Number of seconds between the failed download attempt and the next attempt.
  • download_timeout_seconds: Maximum number of seconds before download attempt is canceled.

Usage in the code:

  • SHConfig().ogc_base_url
  • SHConfig().instance_id
save()[source]

Method that saves configuration parameter changes from instance of SHConfig class to global config class and to config.json file.

Example:

my_config = SHConfig()

my_config.instance_id = '<new instance id>'

my_config.save()

reset(params=Ellipsis)[source]

Resets configuration class to initial values. Use SHConfig.save() method in order to save this change.

Parameters:params (Ellipsis or list(str) or str) – Parameters which will be reset. Parameters can be specified with a list of names, e.g. ['instance_id', 'aws_access_key_id', 'aws_secret_access_key'], or as a single name, e.g. 'ogc_base_url'. By default all parameters will be reset and default value is Ellipsis.
get_params()[source]

Returns a list of parameter names

Returns:List of parameter names
Return type:list(str)
get_config_dict()[source]

Get a dictionary representation of SHConfig class

Returns:A dictionary with configuration parameters
Return type:OrderedDict
get_config_location()[source]

Returns location of configuration file on disk

Returns:File path of config.json file
Return type:str
is_eocloud_ogc_url()[source]

Checks if base OGC URL is set to eocloud URL

Returns:True if ‘eocloud’ string is in base OGC URL else False
Return type:bool