PeriodicTaskManagement

The periodic task management APS type defines the platform built-in service that allows the applications to manage periodic tasks in the platform.

GraphViz

Schema

The considered APS type (download) extends the Resource APS type(s) and looks as follows:

{
  "name": "PeriodicTaskManagement",
  "id": "http://www.parallels.com/pa/pa-core-services/periodic-task-manager/1.1",
  "apsVersion": "2.0",
  "implements": [
    "http://aps-standard.org/types/core/resource/1.0"
  ],
  "access": {
    "global": true
  },
  "operations": {
    "schedulePeriodicTask": {
      "path": "/tasks",
      "verb": "POST",
      "response": {
        "type": "PeriodicTaskInfo"
      },
      "errorResponse": {
        "type": "object"
      },
      "parameters": {
        "taskInfo": {
          "kind": "body",
          "type": "PeriodicTaskInfo"
        }
      }
    },
    "reschedulePeriodicTask": {
      "path": "/tasks/{taskUuid}",
      "verb": "PUT",
      "response": {
        "type": "Schedule"
      },
      "errorResponse": {
        "type": "object"
      },
      "parameters": {
        "taskUuid": {
          "kind": "path",
          "type": "string"
        }
      }
    },
    "cancelPeriodicTask": {
      "path": "/tasks/{taskUuid}",
      "verb": "DELETE",
      "errorResponse": {
        "type": "object"
      },
      "parameters": {
        "taskUuid": {
          "kind": "path",
          "type": "string"
        }
      }
    },
    "getPeriodicTaskStatus": {
      "path": "/tasks",
      "verb": "GET",
      "response": {
        "type": "PeriodicTaskStatus"
      },
      "errorResponse": {
        "type": "object"
      },
      "access": {
        "referrer": false,
        "public": false
      },
      "parameters": {
        "taskType": {
          "kind": "query",
          "type": "string"
        },
        "appInstanceId": {
          "kind": "query",
          "type": "string"
        }
      }
    },
    "runPeriodicTask": {
      "path": "/tasks",
      "verb": "PUT",
      "errorResponse": {
        "type": "object"
      },
      "access": {
        "referrer": false,
        "public": false
      },
      "parameters": {
        "taskType": {
          "kind": "query",
          "type": "string"
        },
        "appInstanceId": {
          "kind": "query",
          "type": "string"
        }
      }
    }
  },
  "structures": {
    "ServiceCall": {
      "type": "object",
      "properties": {
        "resourceId": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "headers": {
          "type": "object"
        },
        "verb": {
          "type": "string"
        },
        "entity": {
          "type": "string"
        }
      }
    },
    "Schedule": {
      "type": "object",
      "properties": {
        "period": {
          "type": "integer",
          "required": true
        },
        "periodType": {
          "type": "string"
        },
        "startDay": {
          "type": "integer"
        },
        "startHour": {
          "type": "integer"
        },
        "startMinute": {
          "type": "integer"
        }
      }
    },
    "PeriodicTaskInfo": {
      "type": "object",
      "properties": {
        "taskUuid": {
          "type": "string"
        },
        "taskName": {
          "type": "string"
        },
        "taskDescription": {
          "type": "string"
        },
        "callInfo": {
          "type": "ServiceCall"
        },
        "schedule": {
          "type": "Schedule"
        }
      }
    },
    "PeriodicTaskStatus": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "started": {
          "type": "string"
        }
      }
    }
  }
}

The APS type is used to create a singleton APS resource exposing its operations for API calls. The call syntax depends on the operation. For example, a call of an operation that accepts input parameters both in the URL string and in the body looks as follows:

POST  /aps/2/services/periodic-task-manager/<operation-path>?<query-params>

{/*<body params>*/}

In the above call, the verb can be either GET, PUT, POST, or DELETE as specified in the definition of the operation.

Custom Operations

OPERATION

VERB

PATH

RETURNS

Description

schedulePeriodicTask

POST

/tasks

If successful, this method returns the PeriodicTaskInfo structure in the response body.

Schedule a periodic task.

reschedulePeriodicTask

PUT

/tasks/{taskUuid}

If successful, this method returns the Schedule structure in the response body.

Reschedule the specified periodic task.

cancelPeriodicTask

DELETE

/tasks/{taskUuid}

If successful, this method returns the 200 OK standard status code.

Delete the specified periodic task.

getPeriodicTaskStatus

GET

/tasks

If successful, this method returns the PeriodicTaskStatus structure in the response body.

Get the current status of the task that polls the resource usage of the specified application.

runPeriodicTask

PUT

/tasks

If successful, this method returns the 200 OK standard status code.

Run a periodic task that must poll the resource usage of the specified application.

schedulePeriodicTask

HTTP Request

POST /aps/2/services/periodic-task-manager/tasks

Description

Schedule a periodic task.

Parameters

PARAMETER

TYPE

DESCRIPTION

taskInfo

PeriodicTaskInfo

PeriodicTaskInfo

Returns

If successful, this method returns the PeriodicTaskInfo structure in the response body.

reschedulePeriodicTask

HTTP Request

PUT /aps/2/services/periodic-task-manager/tasks/{taskUuid}

Description

Reschedule the specified periodic task.

Parameters

PARAMETER

TYPE

DESCRIPTION

taskUuid

String

Task uuid

Returns

If successful, this method returns the Schedule structure in the response body.

cancelPeriodicTask

HTTP Request

DELETE /aps/2/services/periodic-task-manager/tasks/{taskUuid}

Description

Delete the specified periodic task.

Parameters

PARAMETER

TYPE

DESCRIPTION

taskUuid

String

Task uuid

Returns

If successful, this method returns the 200 OK standard status code.

getPeriodicTaskStatus

HTTP Request

GET /aps/2/services/periodic-task-manager/tasks

Description

Get the current status of the task that polls the resource usage of the specified application.

Parameters

PARAMETER

TYPE

DESCRIPTION

taskType

String

Task type

appInstanceId

String

Application instance id

Returns

If successful, this method returns the PeriodicTaskStatus structure in the response body.

runPeriodicTask

HTTP Request

PUT /aps/2/services/periodic-task-manager/tasks

Description

Run a periodic task that must poll the resource usage of the specified application.

Parameters

PARAMETER

TYPE

DESCRIPTION

taskType

String

Task type

appInstanceId

String

Application instance id

Returns

If successful, this method returns the 200 OK standard status code.

Structures

ServiceCall

Service call initialization data.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

resourceId

String

Not Required

ID of the resource.

path

String

Not Required

URI resource

headers

Object

Not Required

Map. HTTP header fields

verb

String

Not Required

Method: ‘GET’, ‘POST’ …

entity

String

Not Required

Entity.

Schedule

Initialization data for scheduling a periodic task

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

period

Integer

Required

Required field. Period the launch

periodType

String

Not Required

Type ‘week’, ‘day’ …

startDay

Integer

Not Required

Start day

startHour

Integer

Not Required

Start hour

startMinute

Integer

Not Required

Start minute

PeriodicTaskInfo

Information about a periodic task.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

taskUuid

String

Not Required

Task Universally Unique Identifier

taskName

String

Not Required

Task name

taskDescription

String

Not Required

Task description

callInfo

ServiceCall

Not Required

Service call ServiceCall

schedule

Schedule

Not Required

Schedule Schedule

PeriodicTaskStatus

Information about the task that collects resource usage.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

title

String

Not Required

Title of the task.

status

String

Not Required

Enum: SUCCESS, RUNNING, FAILED, NOTSTARTED.

message

String

Not Required

Stask trace error

started

String

Not Required

The date and time the task started.

Examples

Since the considered APS type contains custom operations, refer to Custom Operations for the general explanation of their structure and examples of operation calls.