Skip to content

Latest commit

 

History

History
executable file
·
92 lines (71 loc) · 2.02 KB

configuration.md

File metadata and controls

executable file
·
92 lines (71 loc) · 2.02 KB

Configuration Guide

Summary

This SDK uses a plist file to configure context information, except for AccessKeyID and SecretAccessKey, you can also configure the API servers for private cloud usage scenario. All available configureable items are list in default configuration file.

Default Configuration File:

<dict>
	<key>access_key_id</key>
	<string>ACCESS_KEY_ID</string>
	<key>secret_access_key</key>
	<string>SECRET_ACCESS_KEY</string>
	<key>protocol</key>
	<string>https</string>
	<key>host</key>
	<string>qingstor.com</string>
	<key>port</key>
	<string>443</string>
</dict>

Usage

Configure general context for the entire SDK

You can use Registry to register AccessKeyID and SecretAccessKey to the general context information for the entire SDK

// Swift
Registry.register(accessKeyID: "ACCESS_KEY_ID", secretAccessKey: "SECRET_ACCESS_KEY")
// Objective-C
[QSRegistry registerWithAccessKeyID:@"ACCESS_KEY_ID" secretAccessKey:@"SECRET_ACCESS_KEY"];

Can also use the plist file to register:

// Swift
Registry.registerFrom(plist: configURL)
// Objective-C
[QSRegistry registerFromPlist:url error:nil];

Create API context

// Swift
let context = APIContext(baseURL: "https://api.private.com:4433")
// Objective-C
QSAPIContext *context = [[QSAPIContext alloc] initWithBaseURL:@"https://api.private.com:4433"];

Can also use the plist file to create:

// Swift
let context = try! APIContext(plist: configURL)
// Objective-C
QSAPIContext *context = [[QSAPIContext alloc] initWithPlist:configURL error:nil];

Change API server:

// Swift
var context = try! APIContext(plist: configURL)
context.`protocol` = "https"
context.host = "api.private.com"
context.port = 4433
// Objective-C
QSAPIContext *context = [[QSAPIContext alloc] initWithPlist:configURL error:nil];
context.protocol = @"https";
context.host = @"api.private.com";
context.portNumber = @4433;