arcgis.gis.workflowmanager module

The arcgis.workflowmanager module contains classes and functions for working with a Workflow Manager installation. Workflow diagrams, job templates and jobs can be created, modified, or deleted. Information such as location, assignment, history and attachments for individual jobs can be accessed. Additionally, information about the various roles, users, groups, and searches can be view, modified or created.

WorkflowManager

class arcgis.gis.workflowmanager.WorkflowManager(item)

Bases: object

Represents a connection to a Workflow Manager instance or item.

Users create, update, delete workflow diagrams, job templates and jobs or the various other properties with a workflow item.

Argument

Description

item

The Workflow Manager Item

# USAGE EXAMPLE: Creating a WorkflowManager object from a workflow item

from arcgis.workflow import WorkflowManager
from arcgis.gis import GIS

# connect to your GIS and get the web map item
gis = GIS(url, username, password)
wf_item = gis.content.get('1234abcd_workflow item id')

# create a WorkflowManager object from the workflow item
wm = WorkflowManager(wf_item)
type(wm)
>> arcgis.workflowmanager.WorkflowManager

# explore the users in this workflow using the 'users' property
wm.users
>> [{}...{}]  # returns a list of dictionaries representing each user
property assignable_groups

Get portal groups associated with Workflow Manager roles, to which the current user can assign work based on their Workflow Manager assignment privileges.

Returns

A list of the assignable group objects

property assignable_users

Get all assignable users for a user in the workflow system

Returns

A list of the assignable user objects

create_diagram(name, steps, display_grid, description='', active=False, annotations=[], data_sources=[])

Adds a diagram to the Workflow Manager instance given a user-defined name and array of steps

Argument

Description

name

Diagram Name (required)

steps

List of Step objects associated with the Diagram (required)

display_grid

Boolean indicating whether the grid will be displayed in the Diagram (required)

description

Diagram description

active

Boolean indicating whether the Diagram is active

annotations

List of Annotation objects associated with the Diagram

data_sources

List of Data Source objects associated with the Diagram

Returns

Workflow Manager Diagram ID

create_job_template(name, priority, id='', category='', job_duration=0, assigned_to='', default_due_date=None, default_start_date=None, start_date_type='CreationDate', diagram_id='', diagram_name='', assigned_type='Unassigned', description='', default_description='', state='Draft', last_updated_by='', last_updated_date=None, extended_property_table_definitions=[])

Adds a job template to the Workflow Manager instance given a user-defined name and default priority level

Argument

Description

name

Job Template Name (required)

priority

Default Job Template Priority Level (required)

id

Job Template ID

category

Job Template Category

job_duration

Default Job Template Duration

assigned_to

Job Owner

default_due_date

Due Date for Job Template

default_start_date

Start Date for Job Template

start_date_type

Type of Start Date (e.g. creationDate)

diagram_id

Job Template Diagram ID

diagram_name

Job Template Diagram Name

assigned_type

Type of Job Template Assignment

description

Job Template Description

default_description

Default Job Template Description

state

Default Job Template State

last_updated_by

User Who Last Updated Job Template

last_updated_date

Date of Last Job Template Update

extended_property_table_definitions

List of Extended Properties for Job Template

Returns

Workflow Manager Job Template ID

create_wm_role(name, description='', privileges=[])

Adds a role to the Workflow Manager instance given a user-defined name

Argument

Description

name

Role Name (required)

description

Role Description

privileges

List of privileges associated with the role

Returns

Workflow Manager Role Object

delete_diagram(id)

Deletes a diagram object by ID

Argument

Description

id

Diagram id (required)

Returns

Workflow Manager Diagram ID

delete_job_template(id)

Deletes a job template with the given ID

Argument

Description

id

Job Template ID

Returns

status code

diagram(id)

Returns the diagram with the given ID

Argument

Description

id

Diagram ID

Returns

Workflow Manager Job Diagram Object

property diagrams

Gets the workflow diagrams within the workflow item.

Returns

List of all current diagrams in the Workflow Manager

evaluate_arcade(expression, context=None, context_type='BaseContext', mode='Standard')

Evaluates an arcade expression

Argument

Description

expression

Required String.

context

Optional String.

context_type

Optional String.

mode

Optional String.

Returns

String

group(group_id)

Returns group information with the given group ID

Argument

Description

group_id

Workflow Manager Group ID

Returns

Workflow Manager Group Object

property groups

Returns an array of all user groups stored in Workflow Manager

Returns

array

job_template(id)

Returns a job template with the given ID

Argument

Description

id

Job Template ID

Returns

Workflow Manager Job Template Object

property job_templates

Gets all the job templates in a workflow item.

Returns

List of all current job templates in the Workflow Manager (required information for create_job call)

property jobs

The job manager for a workflow item. See JobManager.

property searches

Returns an array of all saved searches.

Returns

List

property settings

Returns an array of all settings for the Workflow Manager instance

Returns

array

update_diagram(body, delete_draft=True)

Updates a diagram object by ID

Argument

Description

body

Diagram body - existing Diagram object that inherits required/optional fields.

delete_draft

Boolean - option to delete the Diagram draft (optional)

Returns

success object

update_job_template(template)

Updates a job template object by ID

Argument

Description

body

Job Template body - existing Job Template object that inherits required/optional fields.

Returns

success object

update_settings(props)

Returns an active job with the given ID

Argument

Description

props

a list of Props objects to update (Prop object example: {‘propName’: ‘string’, ‘value’: ‘string’})

Returns

success object

user(username)

Returns a user profile with the given username

Argument

Description

username

Workflow Manager Username

Returns

Workflow Manager User Object

property users

Returns an array of all user profiles stored in Workflow Manager

Returns

array

wm_role(name)

Returns an active role with the given name

Argument

Description

name

Role Name

Returns

Workflow Manager Role Object

property wm_roles

Returns an array of user roles available in the local Workflow Manager instance

Returns

array

WorkflowManagerAdmin

class arcgis.gis.workflowmanager.WorkflowManagerAdmin(gis)

Bases: object

Represents a a series of CRUD functions for Workflow Manager Items

Argument

Description

gis

Optional GIS. The connection to the Enterprise.

create_item(name)tuple

Creates a Workflow Manager schema that stores all the configuration information and location data in the data store on Portal. This can be run by any user assigned to the administrator role in Portal.

For users that do not belong to the administrator role, the following privileges are required to run Create Workflow Item:

Argument

Description

name

Required String. The name of the new schema.

Returns

string (item_id)

JobManager

class arcgis.gis.workflowmanager.JobManager(item)

Bases: object

Represents a helper class for workflow manager jobs

Argument

Description

item

The Workflow Manager Item

close(job_ids)

Closes a single or multiple jobs with specific JobIDs

Argument

Description

job_ids

A list of job ID strings

Returns

success object

create(template, count=1, name=None, start=None, end=None, priority=None, description=None, owner=None, group=None, assigned=None, complete=None, notes=None, parent=None)

Adds a job to the Workflow Manager instance given a user-defined template

Argument

Description

template

Workflow Manager Job Template ID (required)

count

Number of jobs to create

name

Job Name

start

Job Start Date

end

Job End Date

priority

Job Priority Level

description

Job Description

owner

Job Owner

group

Job Group

assigned

Initial Job Assignee

complete

Integer Percentage Complete

notes

Job Notes

parent

Parent Job

Returns

Workflow Manager Job Object

delete_attachment(job_id, attachment_id)

Deletes a job attachment given a job ID and attachment ID

Argument

Description

job_id

Job ID

attachment_id

Attachment ID

Returns

status code

diagram(id)

Returns the job diagram for the user-defined job

Argument

Description

id

Job ID

Returns

Workflow Manager Job Diagram Object

get(id)

Returns an active job with the given ID

Argument

Description

id

Job ID

Returns

Workflow Manager Job Object

search(query=None, search_string=None, fields=None, display_names=[], sort_by=[], num=10, start_num=0)

Runs a search against the jobs stored inside the Workflow Manager instance

Argument

Description

query

SQL query to search against (e.g. “priority=’High’”)

search_str

Search string to search against (e.g. “High”)

fields

Field list to return

display_names

Display names for the return fields

sort_by

Field to sort by (e.g. {‘field’: ‘priority’, ‘sortOrder’: ‘Asc’})

num

Number of return results

start_num

Index of first return value

Returns

List of search results

update(job_id, update_object)

Updates a job object by ID

Argument

Description

job_id

ID for the job to update

update_object

an object containing the fields and new values to add to the job

Returns

success object

upgrade(job_ids)

Upgrades a single or multiple jobs with specific JobIDs

Argument

Description

job_ids

A list of job ID strings

Returns

success object

Job

class arcgis.gis.workflowmanager.Job(init_data, gis=None, url=None)

Helper class for managing Workflow Manager jobs in a workflow item. This class is not created by users directly. An instance of this class, can be created by calling jobs.get(id) with the appropriate ID for the job. jobs is available as property on arcgis.WorkflowManager.

add_attachment(attachment)

Adds an attachment to the job

Argument

Description

attachment

Filepath to attachment

Returns

Job Attachment

get_attachment(attachment_id)

Returns a job attachment given an attachment ID

Argument

Description

attachment_id

Attachment ID

Returns

Job Attachment

property history

Gets the history of a job given job ID

Returns

success object

property location

Returns the job location for the user-defined job

Returns

Workflow Manager Job Location Object

set_current_step(step_id)

Sets a single step to be the active step on the job. The ability to set a step as current is controlled by the workflowSetStepCurrent privilege.

Argument

Description

step_id

Active Step ID

Returns

success object

update_attachment(attachment_id, alias)

Updates an attachment alias given a Job ID and attachment ID

Argument

Description

attachment_id

Attachment ID

alias

Alias

Returns

success

update_step(step_id, assigned_type, assigned_to)

Update the assignment of the current step in a job based on the current user’s Workflow Manager assignment privileges

Argument

Description

step_id

Active Step ID

assigned_type

Type of assignment designated (NOTE: Must be User, Group or Unassigned)

assigned_to

User to which the active step is assigned

Returns

success object

JobDiagram

class arcgis.gis.workflowmanager.JobDiagram(init_data, gis=None, url=None)

Helper class for managing Workflow Manager jobs diagrams in a workflow item. This class is not created by users directly. An instance of this class, can be created by calling diagram.get(id) with the appropriate ID for the diagram. diagrams is available as property on arcgis.WorkflowManager.