sentinelhub.config
Module for managing configuration data from config.json
- class sentinelhub.config.SHConfig(hide_credentials=False, use_defaults=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_session_token: A session token for your AWS account. It is only needed when you are using temporary credentials.
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.
use_defaults (bool) – Does not load the configuration file, returns config object with defaults only.
- CREDENTIALS = {'aws_access_key_id', 'aws_secret_access_key', 'aws_session_token', 'instance_id', 'sh_client_id', 'sh_client_secret'}
- CONFIG_PARAMS = ['instance_id', 'sh_client_id', 'sh_client_secret', 'sh_base_url', 'sh_auth_base_url', 'geopedia_wms_url', 'geopedia_rest_url', 'aws_access_key_id', 'aws_secret_access_key', 'aws_session_token', 'aws_metadata_url', 'aws_s3_l1c_bucket', 'aws_s3_l2a_bucket', 'opensearch_url', 'max_wfs_records_per_query', 'max_opensearch_records_per_query', 'max_download_attempts', 'download_sleep_time', 'download_timeout_seconds', 'number_of_download_processes']
- classmethod load(filename)[source]
Method that loads configuration parameters from a file. Does not affect global settings.
- save(filename=None)[source]
Method that saves configuration parameter changes from instance of SHConfig class to global config class and to config.json file.
- reset(params=Ellipsis)[source]
Resets configuration class to initial values. Use SHConfig.save() method in order to save this change.
- Parameters
params (Union[str, Iterable[str], object]) – 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 isEllipsis
.- Return type
None
- get_config_dict()[source]
Get a dictionary representation of SHConfig class. If hide_credentials is set to True then credentials will be masked.
- classmethod get_config_location()[source]
Returns location of configuration file on disk
- Returns
File path of config.json file
- Return type
- get_sh_oauth_url()[source]
Provides URL for Sentinel Hub authentication endpoint
- Returns
A URL endpoint
- Return type
- get_sh_process_api_url()[source]
Provides URL for Sentinel Hub Process API endpoint
- Returns
A URL endpoint
- Return type
- get_sh_ogc_url()[source]
Provides URL for Sentinel Hub OGC endpoint
- Returns
A URL endpoint
- Return type