Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 1.91 KB

configuration.md

File metadata and controls

81 lines (57 loc) · 1.91 KB

Configuration Guide

Summary

This SDK uses a structure called "Config" to store and manage configuration, read comments of public functions in "config.js" for details.

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

# Additional User-Agent
additional_user_agent: ""
# Valid levels are "debug", "info", "warn", "error", and "fatal".
log_level: 'warn'

Usage

Just create a config structure instance with your API Access Key.

Code Snippet

Create default configuration

import { Config } from 'qingstor-sdk';
let defaultConfig = new Config().loadDefaultConfig();

Create configuration from Access Key

import { Config } from 'qingstor-sdk';
let userConfig = new Config().loadDefaultConfig();
userConfig.access_key_id = "ACCESS_KEY_ID";
userConfig.secret_access_key = "SECRET_ACCESS_KEY";

Load user configuration

import { Config } from 'qingstor-sdk';
let userConfig = new Config().loadUserConfig();

Load configuration from config file

import { Config } from 'qingstor-sdk';
let userConfig = new Config().loadConfigFromFilepath('PATH/TO/FILE');

Change API endpoint

import { Config } from 'qingstor-sdk';
let moreConfiguration = new Config().loadDefaultConfig();

moreConfiguration.protocol = "https";
moreConfiguration.host = "api.private.com";
moreConfiguration.port = 4433;

Customize User Agent

import { Config } from 'qingstor-sdk';
let userConfig = new Config().loadDefaultConfig();
userConfig.additional_user_agent = "UserExample";