Configuring the SDK

The Configuration Object

Configuration in the SDK can be done in two ways:

  1. Global configuration on FX.config, or,
  2. Passing extra configuration to a service object
Setting global configuration with FX.config is often easier to get up and running with, but service level configuration can provide much more control over your requests. Both of these configuration mechanisms are discussed.

Global Configuration

By default, you can set global configuration by updating the FX.config object with new settings. The most common settings are:

More configuration settings can be found in the reference documentation.

The only things you need to set in order to use the SDK are credentials and the region value. Let's discuss how to do that.

Setting Credentials

FX.config.update({apikey: 'apikey', apisecret: 'apisecret'})

Setting the region

FX.config.update({region: 'us-west-2'})

Locking API Versions

For more information on API version locking in the SDK, see the Working With Services section.

You can globally configure a set of API versions to use for each service by specifying the apiVersions parameter in FX.config. For example, you can choose to set specific versions of the Project and Render services, while selecting the "latest" version of the Batch Service:

FX.config.apiVersions = {
  project: '2016-06-02',
  render: '2016-06-02',
  batch: 'latest'
}

Note that by default, the SDK will use the "latest" available API version when constructing a service, i.e. if you don't specify a version.

You can also lock all services at a specific point in time by using a "fuzzy version":

// Try to use latest available APIs before this date
FX.config.apiVersion = '2016-10-12';

Service-Specific Configuration

Occasionally, you might want to apply configuration only to one service. For instance, you want to use multiple Project objects in different regions. You can do this by passing configuration data directly to the service object constructor:

var sydneyProjects = new FX.Project({region: 'ap-southeast-2', maxRetries: 15});

Note that the constructor takes all of the same configuration data as the FX.config object described above, including credential information.

Immutable Configuration Data

Global configuration changes apply to all requests for all newly created services. Any newly created service will merge its local options on top of the global configuration data at the time of creation. This means that any future updates to the global FX.config object will not apply to existing service objects. These services would have to be manually updated with the new configuration data, or recreated using the following command (assuming an existing prj service object):

prj = new FX.Project(prj.config);

Terms of Use | © 2017, Impossible Software, or its affiliates. All rights reserved.