REST API

Overview

These public interfaces are used in REST components. They are provided for implementing advanced functionality in your scripts. In order for you to use these interfaces in your project, you have to reference CozyRoc.SSISPlus.dll and RestSharp.dll libraries. Also include CozyRoc.SqlServer.SSIS, CozyRoc.Rest and RestSharp namespaces.

IConnection

When you call Rest Connection Manager AcquireConnection method, it returns object implementing IConnection interface. This is the interface used for interaction with REST service.

Connect method

Connects to REST service.

Close method

Closes the connection to REST service. Use always after you finish working with the service.

IsConnected method

Returns true if connected to the service.

GetService method

Get REST web service object. The result is RestClient object.

GetResourceList method

Returns list of available REST resources for specific operation. These are the method parameters:

  • operation (uint) - It can be one of the options listed in the following table.
    Value Description
    0 Return records, which can be read.
    1 Return records, which support adding.
    2 Return records, which can be updated.
    3 Return records, which support remove.
    4 Return records, which support upsert.
GetResource method

Get object used to manage REST resource. The method returns IResource object. These are the method parameters:

  • name (string) - resource name.
Configuration property (string)

Specify REST configuration name.

ServerHost property (string)

Specify REST service URL.

UserConfiguration property (string)

Specify REST connection parameters. The format is [name]=[value]. Each parameter is separated with newline (\r\n).

TokenFile property (string)

Specify token file path.

TokenPassword property (string)

Specify token file decryption password.

ServerTimeout property (int)

Specify the number of seconds before timing out session connect. The default value of this property is 100 seconds.

RetainSameConnection property (bool)

Specify if all clients should use the same connection. This property has the options listed in the following table.

Value Description
True All clients use same connection (default).
False Every client uses different connection.
LogFile property (string)

Specify log file name.

RequestsPerSecond property (int)

Specify how many requests per second are permitted.

Retry property (int)

Specify maximum request retry number. Specify 0 to disable retry.

RetryPause property (int)

Specify pause in seconds between retries. The default is 30 seconds.

RetryError property (int)

Specify RegEx pattern to retry if error message matches.

ProxyHost property (string)

Specify the name or IP address of the proxy server.

ProxyPort property (int)

Specify the port number on the proxy server to use for the connection.

ProxyUser property (string)

Specify user name to access the proxy server.

ProxyPassword property (string)

Specify password to access the proxy server.

IField

This interface is used to retrieve REST resource field information.

Id property (string)

Returns field identifier.

Name property (string)

Returns field name.

IsKey property (bool)

Returns true if field is resource key.

FieldType property (DataType)

Returns field type.

Length property (int)

Returns field length.

Precision property (int)

Returns field precision.

Scale property (int)

Returns field scale.

ReadOnly property (bool)

Returns true if field is read-only.

IResource

This interface is used for REST resource management.

GetFields method

Get resource fields. The method returns array of IField objects.

NewResource method

Constructs new in-memory REST resource instance.

SetFieldValue method

Sets field value in a resource. These are the method parameters:

  • instance (object) - resource instance.
  • name (string) - field name.
  • value (object) - field value.
GetFieldValue method

Returns field value from resource object. These are the method parameters:

  • instance (object) - resource instance.
  • name (string) - field name.
GetData method

Retrieves records from REST resource. The method returns array of resource objects. These are the method parameters:

  • filter (string array) - array of filters. The filter format is [name]=[value].
  • fields (string array) - list of fields to retrieve.
  • iterator (ref string) - contains current start iteration position. After data is retrieved, the parameter will contain next iteration position.
  • batchSize (int) - number of records to retrieve in one batch.
Create method

Creates records in resource. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) - array of objects to create.
  • parameters (string array) - array of additional parameters. The parameter format is [name]=[value].
Update method

Updates existing records in resource. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) - array of objects with update data.
  • parameters (string array) - array of additional parameters. The parameter format is [name]=[value].
Delete method

Deletes records in resource. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) - array of objects to delete.
  • parameters (string array) - array of additional parameters. The parameter format is [name]=[value].
Upsert method

Update or insert records in resource. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) - array of objects to upsert.
  • parameters (string array) - array of additional parameters. The parameter format is [name]=[value].

IStatus

This interface is used for reporting back status.

ID property (string)

Returns the REST resource identifier.

Code property (int)

Returns the REST error code. If zero, there is no error.

Message property (string)

Returns the REST status message.

Result property (object)

Returns source JSON object.