arcgis.gis.tasks module

TaskManager

class arcgis.gis.tasks.TaskManager(url, user, gis)

Bases: object

Provides the functions to create, update and delete scheduled tasks.

This operation is for Enterprise configuration 10.8.1+.

Argument

Description

url

Required string. The URL to the REST endpoint.

user

Required User. The user to perform the Task management on.

gis

Required GIS. The GIS object.

property all

returns all the current user’s tasks

property count

Returns the number of tasks a user has

Returns

Int

create(item, cron, task_type, occurences=10, start_date=None, end_date=None, title=None, parameters=None)

Creates a new scheduled task for a notebook Item.

Argument

Description

item

Required Item. The item to schedule a task on.

cron

Required String. The CRON statement. This should be in the from of:

<minute> <hour> <day of month> <month> <day of week>

Example to run a task weekly, use: 0 0 * * 0

task_type

Required String. The type of task, either executing a notebook or updating an Insights workbook, that will be executed against the specified item. For notebook server tasks use: ExecuteNotebook, for Insights notebook use: UpdateInsightsWorkbook. Use ExecuteSceneCook to cook scene tiles. Use ExecuteWorkflowManager to run workflow manager tasks.

occurences

Optional Integer. The total number of instance that can run at a single time.

start_date

Optional Datetime. The begin date for the task to run.

start_date

Optional Datetime. The end date for the task to run.

title

Optional String. The title of the scheduled task.

parameters

Optional Dict. Optional collection of Key/Values that will be given to the task. The dictionary will be added to the task run request. This parameter is required for ExecuteSceneCook tasks.

Example

``` {

“service_url”: <scene service URL>, “num_of_caching_service_instances”: 2, //2 instances are required “layer”: “{<list of scene layers to cook>}”, //The default is all layers “update_mode”: “PARTIAL_UPDATE_NODES”

Returns

Task

search(item=None, active=None, types=None)

This property allows users to search for tasks based on criteria.

Argument

Description

item

Optional Item. The item to query tasks about.

active

Optional Bool. Queries tasks based on active status.

types

Optional String. The type of notebook execution for the item. This can be ExecuteNotebook, or UpdateInsightsWorkbook.

Returns

List of Tasks

Task

class arcgis.gis.tasks.Task(url, gis)

Bases: BaseTask

Represents a schduled task that can be modified for a user.

Argument

Description

url

Required string. The URL to the REST endpoint.

gis

Required GIS. The GIS object.

delete()

Removes the Task from the System.

Returns

Boolean

enable(enabled)

The enable method allows administrators to enable or disable the scheduled task..

Argument

Description

enabled

Required Boolean. If True, the status of the task is set to active. If False, the task is set active to False.

Returns

Bool

property runs

Returns the Runs for the Task. The maximum number of runs returned is 30

Returns

List

start()

Starts a task if it is actively running.

Returns

Bool

stop()

Stops a task if it is actively running.

Returns

Bool

update(item=None, cron=None, task_type=None, occurences=10, start_date=None, end_date=None, title=None, parameters=None, task_url=None, is_active=None)

Updates the current Task

Argument

Description

item

Optional Item. The item to update the schedule for.

cron

Optional String. The executution time syntax.

task_type

Optional String. The type of task. Two valid options are ExecuteNotebook or UpdateInsightsWorkbook.

occurences

Optional Integer. The maximum number of occurrences this task should execute.

start_date

Optional Datetime. The date/time when the task will begin executing.

end_date

Optional Datetime. The date/time when the task will stop executing.

title

Optional String. The name of the task.

parameters

Optional Dict. Additional key/value pairs for execution of notebooks.

task_url

Optional String. A response URL with a set of results.

is_active

Optional Bool. Determines if the tasks is currently running.

Returns

bool or Dict on error.

Run

class arcgis.gis.tasks.Run(url, gis)

Bases: BaseTask

Represents a single run of a scheduled task.

Argument

Description

url

Required string. The URL to the REST endpoint.

gis

Required GIS. The GIS object.

delete()

Removes the Task from the System.

Returns

Boolean

update(status=None, description=None)

Updates the Run’s Status Message and Result Message.

Argument

Description

status

Optional String. The status of the run. The allowed values are: scheduled, executing, succeeded, failed, or skipped.

description

Optional String. Updates the descriptive message associated with the current Run.

Returns

Bool