Creating Jobs

Unsupported

Jobs can only have a single source. Jobs with more than one source will not sync content and run forever. Transactions started with this job configuration should be canceled. We intend to add support for multiple jobs in the future.

Getting Endpoint IDs

To save a job, you will need all the endpoint IDs you want to use in the job. If you do not have all the endpoint IDs already saved you can use the endpoint-depot API to view all endpoints and find the endpoint you want to use.

curl --location -g --request GET '{{impulse-protocol}}://{{impulse-domain}}:{{impulse-port}}/private/endpoint-depot/endpoints'

From this response, you can identify the endpoints by their name, which is unique. In addition you can view the contentRepo to determine what connector the endpoint is associated with.

The connectorId returned in the response can be used to find the job options for the connector.

Saving a Job

To save a job you will need to use the job-depot API.

To save a job the payload will require a few attributes:

  • name

    • The name of the job.

    • Must be unique

  • endpoints

    • The list of endpoints to be used by the job. This is an array of endpoint objects

Jobs can also have the following attributes:

  • type

    • Type of job.

    • We currently only support "manual" value

  • active

    • Determines if the job is active or not.

  • description

    • A description of the job

Each endpoint object requires the following attributes:

  • endpoint.id

    • The ID of the endpoint to be used

  • type

    • The type of the endpoint.

    • Either "source" or "destination"

  • detail

    • The job options for the endpoint

    • Comma separated string of job options following key:value notation.

For this example we will save a job with a source dotCMS endpoint and a destination dotCMS endpoint.

curl --request POST '{{impulse-protocol}}://{{impulse-domain}}:{{impulse-port}}/private/job-depot/jobs' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "dotCMS-to-dotCMS-contentType",
  "type": "manual",
  "description": "dotCMS to dotCMS job using Content Type",
  "active": true,
  "endpoints": [
    {
      "endpoint": {
        "id": "{{source-endpoint-id}}"
      },
      "type": "source",
      "detail": "contentType:webPageContent,contentDependencies:true,dependenciesDepth:4"
    },
    {
      "endpoint": {
        "id": "{{destination-endpoint-id}}"
      },
      "type": "destination",
      "detail": "contentType:webPageContent,contentDependencies:true,dependenciesDepth:4"
    }
  ]
}'

The response returned after the job is saved will contain the job ID. You will need to make note of this ID and use it in later API to start a transaction.

Getting Job Options

To get the possible job options for a connector to set in the job payload endpoints.detail, you can view the connector doc for the chosen connector to view details about the job options. As well as use the connector-depot API to know the key value to use.

Using the connectorId from the endpoint response you can make a call like the following.

curl --request GET '{{impulse-protocol}}://{{impulse-domain}}:{{impulse-port}}/public/connector-depot/connectors/{{connector-id}}

From this response you can view the jobOptions array. Based on if the endpoint is a source or destination, the available job options are listed with the connectorType "Read" or "Write" respectively.

{
    "id": "12dcb152-51b5-422a-b2f3-615dd3387fbd",
    "name": "dotcms-connector",
    "description": "Connector for dotCMS",
    "active": true,
    "level": 3,
    "versionRanges": [
        {
            "startVersion": "5.2.7",
            "endVersion": "5.3.3"
        }
    ],
    "jobOptions": [
        {
            "connectorType": "Read",
            "jobOptions": {
                "options": [
                    {
                        "name": "path",
                        "dataType": "Array",
                        "required": false
                    },
                    {
                        "name": "contentType",
                        "dataType": "Array",
                        "required": false
                    },
                    {
                        "name": "dependenciesDepth",
                        "dataType": "Integer",
                        "defaultValue": "1",
                        "required": false
                    },
                    {
                        "name": "systemObjects",
                        "dataType": "Boolean",
                        "defaultValue": "false",
                        "required": false
                    },
                    {
                        "name": "contentDependencies",
                        "dataType": "Boolean",
                        "defaultValue": "false",
                        "required": false
                    }
                ]
            }
        },
        {
            "connectorType": "Write",
            "jobOptions": {
                "options": [
                    {
                        "name": "path",
                        "dataType": "Array",
                        "required": false
                    },
                    {
                        "name": "contentType",
                        "dataType": "Array",
                        "required": false
                    },
                    {
                        "name": "dependenciesDepth",
                        "dataType": "Integer",
                        "defaultValue": "1",
                        "required": false
                    },
                    {
                        "name": "systemObjects",
                        "dataType": "Boolean",
                        "defaultValue": "false",
                        "required": false
                    },
                    {
                        "name": "contentDependencies",
                        "dataType": "Boolean",
                        "defaultValue": "false",
                        "required": false
                    },
                    {
                        "name": "location.path",
                        "dataType": "Text",
                        "required": false
                    },
                    {
                        "name": "location.site",
                        "dataType": "Text",
                        "required": false
                    }
                ]
            }
        }
    ]
}

In this response you can see the various keys available for job options as well as the data type. For example, the source connector has the job option contentType which is a data type "Array". While the destination connector has the job option location.path which is a data type "Text".

This response can be used to find the keys of the job options to set and in the details for the endpoint in the job.

Data Types

A job option can have the following data types.

  • Text

    • String value.

    • key:myvalue

  • Integer

    • Whole number value

    • key:4

  • Decimal

    • Decimal number value

    • key:4.2

  • Boolean

    • Boolean value

    • key:true

  • Array

    • Multiple string key:values

    • key:myvalue,key:myothervalue

Last updated