SDK 封装一个 Config
object 用于存储和管理配置信息,您可以通过阅读 "config.py" 来获取细节.
Except for Access Key, you can also configure the API endpoint for private cloud usage scenario. All available configurable items are listed in the default configuration file.
Default Configuration File:
# QingStor services configuration
access_key_id: ''
secret_access_key: ''
host: 'qingstor.com'
port: 443
protocol: 'https'
connection_retries: 3
# Valid log levels are "debug", "info", "warn", "error", and "fatal".
log_level: 'warn'
Just create a config structure instance with your API Access Key, and initialize services.
Create default configuration
default_config = Config()
Create configuration from Access Key
configuration = Config('ACCESS_KEY_ID', 'SECRET_ACCESS_KEY')
another_configuration = Config()
another_configuration.access_key_id = "ACCESS_KEY_ID"
another_configuration.secret_access_key = "SECRET_ACCESS_KEY"
Load user configuration
user_config = Config().load_user_config()
Load configuration from config file
config_from_file = Config().load_config_from_filepath('PATH/TO/FILE')
Change API endpoint
more_configuration = Config()
more_configuration.protocol = 'https'
more_configuration.host = 'api.private.com'
more_configuration.port = 4433