Workflows

View as Markdown

Workflows

Workflow is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly.

create

The create method creates a new workflow in a specific stack.

NameTypeDescription
data (required)Dict

Data required to create a new workflow

data = {

"workflow":{

           "workflow_stages":[

               {

                   "color":"#2196f3",

                   "SYS_ACL":{

                       "roles":{

                           "uids":[

                           ]

                       },

                       "users":{

                           "uids":[

                               "$all"

                           ]

                       },

                       "others":{

                       }

                   },

                   "next_available_stages":[

                       "$all"

                   ],

                   "allStages":true,

                   "allUsers":true,

                   "specificStages":false,

                   "specificUsers":false,

                   "entry_lock":"$none",

                   "name":"Review"

               },

               {

                   "color":"#74ba76",

                   "SYS_ACL":{

                       "roles":{

                           "uids":[

                           ]

                       },

                       "users":{

                           "uids":[

                               "$all"

                           ]

                       },

                       "others":{

                       }

                   },

                   "allStages":true,

                   "allUsers":true,

                   "specificStages":false,

                   "specificUsers":false,

                   "next_available_stages":[

                       "$all"

                   ],

                   "entry_lock":"$none",

                   "name":"Complete"

               }

           ],

           "admin_users":{

               "users":[

               ]

           },

           "name":"Workflow",

           "enabled":true,

           "branches":[

               "main",

               "development"

           ],

           "content_types":[

               "$all"

           ]

       }

   }

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().create(data).json()

create_publish_rule

The create_publish_rule method creates a new rule for the workflow in a specific stack.

NameTypeDescription
data (required)Dict

Data required to create a new publish rule for the workflow

data = {

 "publishing_rule":{

           "workflow":"workflow_uid",

           "actions":[],

           "branches":[

               "main",

               "development"

           ],

           "content_types":[

               "$all"

           ],

           "locales":[

               "en-us"

           ],

           "environment":"environment_uid",

           "approvers":{

               "users":[

                   "user_uids"

               ],

               "roles":[

                   "role_uids"

               ]

           },

           "workflow_stage":"workflow_stage_uid",

           "disable_approver_publishing":false

       }

   }

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().create_publish_rule(data).json()

delete

The delete method removes an existing workflow from a specific stack.

NameTypeDescription
workflow_uid (required)str

UID of the workflow

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = response = client.stack('api_key').workflows('workflow_uid').delete().json()

delete_publish_rule

The delete_publish_rule method removes an existing publish rule for the workflow in a specific stack.

NameTypeDescription
rule_uid (required)str

UID of the publishing rule

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().delete_publish_rule('rule_uid').json()

disable

The disable method allows you to disable a workflow.

NameTypeDescription
workflow_uid (required)str

UID of the workflow

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

file_path = "tests/resources/mock_content_types/import_content_types.json"

response = client.stack('api_key').workflows('workflow_uid').disable().json()

enable

The enable method allows you to enable a workflow.

NameTypeDescription
workflow_uid (required)str

UID of the workflow

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows('workflow_uid').export().json()

fetch

The fetch method retrieves the details of a single workflow from the stack.

NameTypeDescription
workflow_uid (required)str

UID of the workflow

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows('workflow_uid').fetch().json()

fetch_publish_rule

The fetch_publish_rule method retrieves the details of a specific publish rule from the stack.

NameTypeDescription
rule_uid (required)str

UID of the publishing rule

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().fetch_publish_rule('rule_uid').json()

fetch_publish_rule_content_type

The fetch_publish_rule_content_type method retrieves the details of publish rules applied to a specific content type.

NameTypeDescription
content_type_uid (required)str

UID of the content type

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().fetch_publish_rule_content_type('content_type_uid').json()

fetch_publish_rules

The fetch_publish_rules method retrieves the details of all publish rules from the stack.

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().fetch_publish_rules().json()

fetch_tasks

The fetch_tasks method retrieves the details of all tasks assigned to you.

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().logs().json()

find

The find method retrieves the details of all workflows in the stack.

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack("api_key").workflows().find().json()

publish_request_approval

The publish_request_approval method allows you to either send a publish request or accept/reject a publish request.

NameTypeDescription
content_type_uid (required)str

UID of the content type

entry_uid (required)str

UID of the entry

from contentstack_management import contentstack

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

result = client.stack('api_key').workflows().publish_request_approval('content_type_uid', 'entry_uid').json()

set_workflow_stage

The set_workflow_stage method allows you to either set a workflow stage of an entry or update an already existing one.

NameTypeDescription
content_type_uid (required)str

UID of the content type

entry_uid (required)str

UID of the entry

data (required)Dict

The data required to set the workflow stage for a specific entry

data ={

"workflow": {

           "workflow_stage": {

               "comment": "Workflow Comment",

               "due_date": "Thu Dec 01 2018",

               "notify": false,

               "uid": "workflow_stage_uid",

               "assigned_to": [{

                       "uid": "user_uid", 

                       "name": "Username", 

                       "email": "user_email_id"

                       }],

               "assigned_by_roles": [{

                   "uid": "role_uid",

                   "name": "Role name"

               }]               

           }

       }

   }

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().set_workflow_stage('content_type_uid', 'entry_uid', data).json()

update

The update method allows you to add a workflow stage or update the details of the existing stages of a workflow.

NameTypeDescription
data (required)Dict

The data required to update the workflow stage for a specific entry

workflow_uidstr

UID of the workflow

data = {

       "workflow":{

           "workflow_stages":[

               {

                   "color":"#2196f3",

                   "SYS_ACL":{

                       "roles":{

                           "uids":[

                           ]

                       },

                       "users":{

                           "uids":[

                               "$all"

                           ]

                       },

                       "others":{

                       }

                   },

                   "next_available_stages":[

                       "$all"

                   ],

                   "allStages":true,

                   "allUsers":true,

                   "specificStages":false,

                   "specificUsers":false,

                   "entry_lock":"$none",

                   "name":"Review"

               },

               {

                   "color":"#74ba76",

                   "SYS_ACL":{

                       "roles":{

                           "uids":[

                           ]

                       },

                       "users":{

                           "uids":[

                               "$all"

                           ]

                       },

                       "others":{

                       }

                   },

                   "allStages":true,

                   "allUsers":true,

                   "specificStages":false,

                   "specificUsers":false,

                   "next_available_stages":[

                       "$all"

                   ],

                   "entry_lock":"$none",

                   "name":"Complete"

               }

           ],

           "admin_users":{

               "users":[

               ]

           },

           "name":"Workflow",

           "enabled":true,

           "branches":[

               "main",

               "development"

           ],

           "content_types":[

               "$all"

           ]

       }

   }

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows("workflow_uid").update(data).json()

update_publish_rule

The update_publish_rule method allows you to add a publish rule or update the details of an existing publish rule of a workflow.

NameTypeDescription
data (required)Dict

The data required to update the workflow stage for a specific entry

rule_uidstr

UID of the rule

data = {

       "publishing_rule": {

           "workflow": "workflow_uid",

           "actions": [],

           "branches": [

               "main",

               "development"

           ],

           "content_types": ["$all"],

           "locales": ["en-us"],

           "environment": "environment_uid",

           "approvers": {

               "users": ["user_uid"],

               "roles": ["role_uid"]

           },

           "workflow_stage": "workflow_stage_uid",

           "disable_approver_publishing": false

       }

   }

import contentstack_management 

client = contentstack_management.Client(host='host_name')

client.login(email="email_id", password="password")

response = client.stack('api_key').workflows().update_publish_rule('rule_uid', data).json()