Working with Services

Constructing a Service

Each service can be constructed with runtime configuration data that is specific to that service object. The service-specific configuration data will be merged on top of global configuration, so there is no need to re-specify any global settings. For example, an Project object can be created for a specific region:

var prj = new FX.Project({region: 'us-west-2'});

This object will continue to use the globally provided credentials.

Locking API Versions

Services released by Impossible Software use API versions to keep track of API compatibility. API versions in FX services can be identified by a YYYY-mm-dd formatted date string, i.e., 2016-06-02 for the Project Service. It is recommended to lock into an API version for a service if you are relying on it for production code. This way, you can isolate yourself from service changes in updates of the SDK.

In order to lock into an API version of a given service, simply pass the apiVersion parameter when constructing the object, for example:

var render = new FX.Render({apiVersion: '2016-06-02'});

Note that versions can also be locked globally by specifying the apiVersion or apiVersions global configuration parameters. This is documented with more detail in the Configuring section.

Fuzzy Versions and Date Locking

Since FX has many services with many different API versions, the SDK allows for the specification of "fuzzy versions" instead of exact API version matches. This allows you to specify any date after the API version date, and the SDK will look for the last available matching API version when loading the service object.

You can also use this strategy to globally lock your application to a point in time. For instance, if you begin developing your application on 2016-07-05, you can add the following global apiVersion lock value:

FX.config.apiVersion = '2016-07-05';

This will allow all created service objects to use the latest available API versions at the specified lock time. You can override any API versions if you need a newer version, or if the service had not yet been released, by adding the apiVersion parameter to the constructor call as normal:

// FX Story Service was not yet released as of 2016-06-02
var story = new FX.Story({apiVersion: '2016-07-10'});

Passing Parameters to a Service Operation

When calling a method to a service, you should pass parameters in as option values, similar to the way configuration is passed. For example, to get an asset for a given project and name, you can pass the following parameters to the getAsset method:

prj.getAsset({ProjectId: '123456-789-abcdef-0123-abcd', Name: 'assetName'});

Note that the full parameter documentation for each method is found in each service page in the complete API reference documentation.

Bound Parameters

Parameters can be automatically passed to service operations by binding them directly when constructing the service object. To do this, pass the params parameter to your constructed service with the map of default parameter values like so:

var myProject = new FX.Project({ params: {ProjectId: '123456-789-abcdef-0123-abcd'} });

The myProject object will now represent a FX Project service object bound to a project identified by the project ID '123456-789-abcdef-0123-abcd'. Any operation that takes the projectId parameter will now have it auto-filled with this value. This value can be overridden by passing a new value in the service operation. Additionally, operations that do not require a projectId parameter will automatically ignore this bound parameter, so the myProject object can still be used to call listProjects, for instance.

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