Integration batch

The integration batch is a plugin type used for customers' integrations. It can be periodic or non-periodic plugin. You can choose to pause a recurring plugin so that all the coming executions are canceled.

You can check plugins key concepts to understand the hierarchy between a plugin, the versions, the instances and the executions.

Imagine you want to create a script that imports data every night for a customer :

  • You declare a new integration batch plugin called import-data-for-customer

  • You declare a first 1.0.0 version for this plugin with the code of the script and the declaration of the script parameters

  • Your script is now available for usage

To execute the script, you can :

  • Create an integration batch instance that will use the code from the 1.0.0 version with specific input parameters

  • Either program the instance to automatically create executions at a specified cron, or manually create a new execution to start now or later.

How-to

Plugin creation

Use the plugin creation endpoints to create a new plugin with the plugin type as INTEGRATION_BATCH. Everything else remains the same.

Example

# Create the plugin definition
curl -X POST \
  https://api.mediarithmics.com/v1/plugins \
  -H 'Authorization: <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
	"organisation_id": "my_organisation_id",
        "plugin_type": "INTEGRATION_BATCH",
        "group_id": "com.my-client.integration_batch",
        "artifact_id": "integration-batch-my-client"
}'

Plugin version creation

Use the plugin version creation endpoints to create a new plugin version with all the properties. The call and format are the same than usual.

Example

# Create the plugin version
curl -X POST \
  https://api.mediarithmics.com/v1/plugins/<PLUGIN_ID>/versions \
  -H 'Authorization: <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
	  "version_id":"1.0.0",
          "plugin_properties":[
        	  	{
        	     "technical_name": "one_more_property",
        	     "value": {
        	       "value": ""
        	     },
        	     "property_type": "STRING",
        	     "origin": "PLUGIN",
        	     "writable": true,
        	     "deletable": true
        	   },
                {
                    "technical_name": "provider",
                    "value": {
                        "value": "mediarithmics"
                    },
                    "property_type": "STRING",
                    "origin": "PLUGIN_STATIC",
                    "writable": false,
                    "deletable": false
                },
                {
                    "technical_name": "name",
                    "value": {
                        "value": "My Plugin Name"
                    },
                    "property_type": "STRING",
                    "origin": "PLUGIN_STATIC",
                    "writable": false,
                    "deletable": false
                }
        ]
}'

Plugin instance creation

For the integration batch plugin, the instance is called integration_batch_instances.

There are five properties that are used for this plugin type: cron , cron_status, ram_size, cpu_size and disk_size.

The cron and the cron_status are not mandatory as you can create non-periodic jobs. If used, you should use them together.

The ram_size , cpu_size and disk_size are mandatory and the default values are set to LOW.

Example

# Create the plugin instance
curl -X POST \
  https://api.mediarithmics.com/v1/integration_batch_instances \
  -H 'Authorization: <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
	"group_id": "com.my-client.integration_batch",
        "artifact_id": "integration-batch-my-client",
        "version_id": "my-version-id",
        "organisation_id": "my-plugin-id",
        "name": "The name of my instance",
        "archived": false, 
        "cron" :"* * * 7 *",
        "cron_status": "ACTIVE | PAUSED",
        "ram_size": "LOW | MEDIUM | LARGE | EXTRA_LARGE",
        "disk_size": "LOW | MEDIUM | LARGE | EXTRA_LARGE",
        "cpu_size": "LOW | MEDIUM | LARGE | EXTRA_LARGE"
}'

You can perform the operations POST / PUT / GET and DELETE on the instances.

Integration batch execution creation

Executions can be created either automatically by the scheduler using the cron defined in the instance or manually using the API or the interface.

When creating an execution you have to set the execution_type and expected_start_date properties.

// Create an execution
curl -X POST \
  https://api.mediarithmics.com/v1/integration_batch_instances/<INSTANCE_ID>/executions \
  -H 'Authorization: <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
           "parameters": {
		execution_type: "MANUAL | CRON", 
		expected_start_date: 1562595783663
            },
           "organisation_id": "1185",
           "user_id": "1007",
           "error": null,
           "status": "PENDING",
           "external_model_id: "42",
           "external_model_name": "PUBLIC_INTEGRATION_BATCH",
           "start_date": 1562595789171,
           "job_type": "BATCH_INTEGRATION",
  }

You can perform the operations POST / PUT / GET and DELETE on the executions.

The execution_type can be either MANUAL when created using the interface or CRON when created by the instance using the cron value set in the instance.

The expected_start_date is set by the timestamp chosen in the interface or by the cron set in the instance.

Last updated