config

Module for managing configuration data from config.json

class sentinelhub.config.SHConfig(hide_credentials=False)[source]

Bases: object

A sentinelhub-py package configuration class.

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

  • instance_id: An instance ID for Sentinel Hub service used for OGC requests.
  • sh_client_id: User’s OAuth client ID for Sentinel Hub service
  • sh_client_secret: User’s OAuth client secret for Sentinel Hub service
  • sh_base_url: There exist multiple deployed instances of Sentinel Hub service, this parameter defines the location of a specific service instance.
  • sh_auth_base_url: Base url for Sentinel Hub Authentication service. Authentication is typically sent to the main service deployment even if sh_base_url points to another deployment.
  • geopedia_wms_url: Base url for Geopedia WMS services.
  • geopedia_rest_url: Base url for Geopedia REST services.
  • aws_access_key_id: Access key for AWS Requester Pays buckets.
  • aws_secret_access_key: Secret access key for AWS Requester Pays buckets.
  • 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.
  • max_download_attempts: Maximum number of download attempts from a single URL until an error will be raised.
  • download_sleep_time: Number of seconds to sleep between the first failed attempt and the next. Every next attempt this number exponentially increases with factor 3.
  • download_timeout_seconds: Maximum number of seconds before download attempt is canceled.
  • number_of_download_processes: Number of download processes, used to calculate rate-limit sleep time.

Usage in the code:

  • SHConfig().sh_base_url
  • SHConfig().instance_id
Parameters:hide_credentials (bool) – If True then methods that provide the entire content of the config object will mask out all credentials. But credentials could still be accessed directly from config object attributes. The default is False.
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. 'sh_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. If hide_credentials is set to True then credentials will be masked.

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

Returns location of configuration file on disk

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

Checks if base Sentinel Hub URL is set to eocloud URL

Returns:True if ‘eocloud’ string is in base OGC URL else False
Return type:bool
get_sh_oauth_url()[source]

Provides URL for Sentinel Hub authentication endpoint

Returns:An URL endpoint
Return type:str
get_sh_process_api_url()[source]

Provides URL for Sentinel Hub Process API endpoint

Returns:An URL endpoint
Return type:str
get_sh_ogc_url()[source]

Provides URL for Sentinel Hub OGC endpoint

Returns:An URL endpoint
Return type:str
get_sh_rate_limit_url()[source]

Provides URL for Sentinel Hub rate limiting endpoint

Returns:An URL endpoint
Return type:str
raise_for_missing_instance_id()[source]

In case Sentinel Hub instance ID is missing it raises an informative error

Raises:ValueError