Wordpress

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. It is the foundation of the WordPress Block Editor, and can likewise enable your theme, plugin or custom application to present new, powerful interfaces for managing and publishing your site content.

IT Services · Wordpress

Details

IDWordpress
ProviderOpen Source
CategoryIT Services
From Version6.2.0
Docker Imagedemisto/python3:3.12.8.3296088
Supported ModulesAgentix XSIAM

README

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. It is the foundation of the WordPress Block Editor, and can likewise enable your theme, plugin or custom application to present new, powerful interfaces for managing and publishing your site content.
This integration was integrated and tested with version 5.6 of Wordpress

Configure Wordpress in Cortex

Parameter Description Required
Your server URL   True
User Username True
Application Password The Application Password to use for connection True
Trust any certificate (not secure)   False
Use system proxy settings   False

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

wordpress-url-request


Get information from a custom URL

Base Command

wordpress-url-request

Input

Argument Name Description Required
method Method. Possible values are: get, post, put, delete, patch. Default is get. Required
url URL suffix to append to the base URL. Required
body Body data (JSON). Optional
params Parameters (JSON). Optional

Context Output

Path Type Description
Wordpress.URL Unknown URL output data

wordpress-list-posts


Lists all posts

Base Command

wordpress-list-posts

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
page Current page of the collection (defaults is 1). Optional
per_page Maximum number of items to be returned in result set (default is 10). Optional
search Limit results to those matching a string. Optional
after Limit response to posts published after a given ISO8601 compliant date. Optional
author Limit result set to posts assigned to specific authors. Optional
author_exclude Ensure result set excludes posts assigned to specific authors. Optional
before Limit response to posts published before a given ISO8601 compliant date. Optional
exclude Ensure result set excludes specific IDs. Optional
include Limit result set to specific IDs. Optional
offset Offset the result set by a specific number of items. Optional
order Order sort attribute ascending or descending (default is desc). Possible values are: desc, asc. Default is desc. Optional
orderby Sort collection by object attribute (default is date). Possible values are: author, date, id, include, modified, parent, relevance, slug, include_slugs, title. Default is date. Optional
slug Limit result set to posts with one or more specific slugs. Optional
status Limit result set to posts assigned one or more statuses (default is publish). Default is publish. Optional
tax_relation Limit result set based on relationship between multiple taxonomies. Possible values are: AND, OR. Optional
categories Limit result set to all items that have the specified term assigned in the categories taxonomy. Optional
categories_exclude Limit result set to all items except those that have the specified term assigned in the categories taxonomy. Optional
tags Limit result set to all items that have the specified term assigned in the tags taxonomy. Optional
tags_exclude Limit result set to all items except those that have the specified term assigned in the tags taxonomy. Optional
sticky Limit result set to items that are sticky. Optional

Context Output

Path Type Description
Wordpress.Posts.excerpt.protected Boolean Exerpt protected
Wordpress.Posts.excerpt.rendered String Exerpt rendered
Wordpress.Posts.meta Unknown Metadata
Wordpress.Posts.sticky Boolean Sticky
Wordpress.Posts.guid.rendered String GUID rendered
Wordpress.Posts.modified String Modified
Wordpress.Posts.author String Author
Wordpress.Posts.slug String Slug
Wordpress.Posts.date String Date
Wordpress.Posts.comment_status String Comment status
Wordpress.Posts.status String Status
Wordpress.Posts.featured_media Number Featured media
Wordpress.Posts.format String Format
Wordpress.Posts.modified_gmt String Modified GMT
Wordpress.Posts.title.rendered String Title rendered
Wordpress.Posts.tags List Tags
Wordpress.Posts.content.protected Boolean Content protected
Wordpress.Posts.content.rendered String Content rendered
Wordpress.Posts.template String Template
Wordpress.Posts._links Unknown Links
Wordpress.Posts.type String Type
Wordpress.Posts.link String Link
Wordpress.Posts.id String ID
Wordpress.Posts.categories List Categories
Wordpress.Posts.date_gmt String Date GMT
Wordpress.Posts.ping_status String Ping status

wordpress-get-post


Retrieve a specific post record.

Base Command

wordpress-get-post

Input

Argument Name Description Required
id Unique identifier for the object. Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
password The password for the post if it is password protected. Optional

Context Output

Path Type Description
Wordpress.Posts.excerpt.protected Boolean Exerpt protected
Wordpress.Posts.excerpt.rendered String Exerpt rendered
Wordpress.Posts.meta Unknown Metadata
Wordpress.Posts.sticky Boolean Sticky
Wordpress.Posts.guid.rendered String GUID rendered
Wordpress.Posts.modified String Modified
Wordpress.Posts.author String Author
Wordpress.Posts.slug String Slug
Wordpress.Posts.date String Date
Wordpress.Posts.comment_status String Comment status
Wordpress.Posts.status String Status
Wordpress.Posts.featured_media Number Featured media
Wordpress.Posts.format String Format
Wordpress.Posts.modified_gmt String Modified GMT
Wordpress.Posts.title.rendered String Title rendered
Wordpress.Posts.tags List Tags
Wordpress.Posts.content.protected Boolean Content protected
Wordpress.Posts.content.rendered String Content rendered
Wordpress.Posts.template String Template
Wordpress.Posts._links Unknown Links
Wordpress.Posts.type String Type
Wordpress.Posts.link String Link
Wordpress.Posts.id String ID
Wordpress.Posts.categories List Categories
Wordpress.Posts.date_gmt String Date GMT
Wordpress.Posts.ping_status String Ping status

wordpress-create-post


Create a post

Base Command

wordpress-create-post

Input

Argument Name Description Required
status A named status for the object (default is draft). Possible values are: publish, future, draft, pending, private. Default is draft. Required
slug An alphanumeric identifier for the object unique to its type. Optional
password A password to protect access to the content and excerpt. Optional
title The title for the object. Required
content The content for the object. Required
author The ID for the author of the object. Required
exerpt The excerpt for the object. Optional
featured_media The ID of the featured media for the object. Optional
comment_status Whether or not comments are open on the object. Possible values are: open, closed. Optional
ping_status Whether or not the object can be pinged. Possible values are: open, closed. Optional
format The format for the object (default is standard). Possible values are: standard, aside, chat, gallery, link, image, quote, status, video, audio. Default is standard. Required
meta Meta fields (JSON dict). Optional
sticky Whether or not the object should be treated as sticky (default is false). Possible values are: true, false. Default is false. Optional
template The theme file to use to display the object. Optional
categories The terms assigned to the object in the category taxonomy (CSV of IDs). Optional
tags The terms assigned to the object in the post_tag taxonomy (CSV). Optional

Context Output

Path Type Description
Wordpress.Posts.excerpt.protected Boolean Exerpt protected
Wordpress.Posts.excerpt.rendered String Exerpt rendered
Wordpress.Posts.meta Unknown Metadata
Wordpress.Posts.sticky Boolean Sticky
Wordpress.Posts.guid.rendered String GUID rendered
Wordpress.Posts.modified String Modified
Wordpress.Posts.author String Author
Wordpress.Posts.slug String Slug
Wordpress.Posts.date String Date
Wordpress.Posts.comment_status String Comment status
Wordpress.Posts.status String Status
Wordpress.Posts.featured_media Number Featured media
Wordpress.Posts.format String Format
Wordpress.Posts.modified_gmt String Modified GMT
Wordpress.Posts.title.rendered String Title rendered
Wordpress.Posts.tags List Tags
Wordpress.Posts.content.protected Boolean Content protected
Wordpress.Posts.content.rendered String Content rendered
Wordpress.Posts.template String Template
Wordpress.Posts._links Unknown Links
Wordpress.Posts.type String Type
Wordpress.Posts.link String Link
Wordpress.Posts.id String ID
Wordpress.Posts.categories List Categories
Wordpress.Posts.date_gmt String Date GMT
Wordpress.Posts.ping_status String Ping status

wordpress-update-post


Update a post

Base Command

wordpress-update-post

Input

Argument Name Description Required
id Post ID. Required
date The date the object was published, in the sites timezone. Optional
date_gmt The date the object was published, as GMT. Optional
status A named status for the object (default is draft). Possible values are: publish, future, draft, pending, private. Default is draft. Optional
slug An alphanumeric identifier for the object unique to its type. Optional
password A password to protect access to the content and excerpt. Optional
title The title for the object. Optional
content The content for the object. Optional
author The ID for the author of the object. Optional
exerpt The excerpt for the object. Optional
featured_media The ID of the featured media for the object. Optional
comment_status Whether or not comments are open on the object. Possible values are: open, closed. Optional
ping_status Whether or not the object can be pinged. Possible values are: open, closed. Optional
format The format for the object (default is standard). Possible values are: standard, aside, chat, gallery, link, image, quote, status, video, audio. Default is standard. Optional
meta Meta fields (JSON dict). Optional
sticky Whether or not the object should be treated as sticky (default is false). Possible values are: true, false. Default is false. Optional
template The theme file to use to display the object. Optional
categories The terms assigned to the object in the category taxonomy (CSV of IDs). Optional
tags The terms assigned to the object in the post_tag taxonomy (CSV of IDs). Optional

Context Output

Path Type Description
Wordpress.Posts.excerpt.protected Boolean Exerpt protected
Wordpress.Posts.excerpt.rendered String Exerpt rendered
Wordpress.Posts.meta Unknown Metadata
Wordpress.Posts.sticky Boolean Sticky
Wordpress.Posts.guid.rendered String GUID rendered
Wordpress.Posts.modified String Modified
Wordpress.Posts.author String Author
Wordpress.Posts.slug String Slug
Wordpress.Posts.date String Date
Wordpress.Posts.comment_status String Comment status
Wordpress.Posts.status String Status
Wordpress.Posts.featured_media Number Featured media
Wordpress.Posts.format String Format
Wordpress.Posts.modified_gmt String Modified GMT
Wordpress.Posts.title.rendered String Title rendered
Wordpress.Posts.tags List Tags
Wordpress.Posts.content.protected Boolean Content protected
Wordpress.Posts.content.rendered String Content rendered
Wordpress.Posts.template String Template
Wordpress.Posts._links Unknown Links
Wordpress.Posts.type String Type
Wordpress.Posts.link String Link
Wordpress.Posts.id String ID
Wordpress.Posts.categories List Categories
Wordpress.Posts.date_gmt String Date GMT
Wordpress.Posts.ping_status String Ping status

wordpress-delete-post


Delete a post

Base Command

wordpress-delete-post

Input

Argument Name Description Required
id Post ID. Required
force Whether to bypass Trash and force deletion (default is false). Possible values are: true, false. Default is false. Optional

Context Output

Path Type Description
Wordpress.Posts.excerpt.protected Boolean Exerpt protected
Wordpress.Posts.excerpt.rendered String Exerpt rendered
Wordpress.Posts.meta Unknown Metadata
Wordpress.Posts.sticky Boolean Sticky
Wordpress.Posts.guid.rendered String GUID rendered
Wordpress.Posts.modified String Modified
Wordpress.Posts.author String Author
Wordpress.Posts.slug String Slug
Wordpress.Posts.date String Date
Wordpress.Posts.comment_status String Comment status
Wordpress.Posts.status String Status
Wordpress.Posts.featured_media Number Featured media
Wordpress.Posts.format String Format
Wordpress.Posts.modified_gmt String Modified GMT
Wordpress.Posts.title.rendered String Title rendered
Wordpress.Posts.tags List Tags
Wordpress.Posts.content.protected Boolean Content protected
Wordpress.Posts.content.rendered String Content rendered
Wordpress.Posts.template String Template
Wordpress.Posts._links Unknown Links
Wordpress.Posts.type String Type
Wordpress.Posts.link String Link
Wordpress.Posts.id String ID
Wordpress.Posts.categories List Categories
Wordpress.Posts.date_gmt String Date GMT
Wordpress.Posts.ping_status String Ping status

wordpress-list-categories


List categories

Base Command

wordpress-list-categories

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
page Current page of the collection (defaults is 1). Optional
per_page Maximum number of items to be returned in result set (default is 10). Optional
search Limit results to those matching a string. Optional
exclude Ensure result set excludes specific IDs. Optional
include Limit result set to specific IDs. Optional
order Order sort attribute ascending or descending (default is desc). Possible values are: desc, asc. Default is desc. Optional
orderby Sort collection by object attribute (default is date). Possible values are: author, date, id, include, modified, parent, relevance, slug, include_slugs, title. Default is date. Optional
slug Limit result set to posts with one or more specific slugs. Optional
hide_empty Whether to hide terms not assigned to any posts. Optional
post Limit result set to terms assigned to a specific post. Optional
parent Limit result set to terms assigned to a specific parent. Optional

Context Output

Path Type Description
Wordpress.Categories.meta Unknown Metadata
Wordpress.Categories.parent Number Parent
Wordpress.Categories.name String Name
Wordpress.Categories.slug String Slug
Wordpress.Categories.count Number Count
Wordpress.Categories.taxonomy String Taxonomy
Wordpress.Categories._links List Links
Wordpress.Categories.link String Link
Wordpress.Categories.id Number ID
Wordpress.Categories.description String Description

wordpress-create-category


Create a category

Base Command

wordpress-create-category

Input

Argument Name Description Required
description HTML description of the term. Optional
name HTML title for the term. Required
slug An alphanumeric identifier for the term unique to its type. Optional
parent The parent term ID. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Categories.meta Unknown Metadata
Wordpress.Categories.parent Number Parent
Wordpress.Categories.name String Name
Wordpress.Categories.slug String Slug
Wordpress.Categories.count Number Count
Wordpress.Categories.taxonomy String Taxonomy
Wordpress.Categories._links List Links
Wordpress.Categories.link String Link
Wordpress.Categories.id Number ID
Wordpress.Categories.description String Description

wordpress-get-category


Retrieve a category

Base Command

wordpress-get-category

Input

Argument Name Description Required
id Unique identifier for the category. Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional

Context Output

Path Type Description
Wordpress.Categories.meta Unknown Metadata
Wordpress.Categories.parent Number Parent
Wordpress.Categories.name String Name
Wordpress.Categories.slug String Slug
Wordpress.Categories.count Number Count
Wordpress.Categories.taxonomy String Taxonomy
Wordpress.Categories._links List Links
Wordpress.Categories.link String Link
Wordpress.Categories.id Number ID
Wordpress.Categories.description String Description

wordpress-update-category


Update a category

Base Command

wordpress-update-category

Input

Argument Name Description Required
id Category ID. Required
description HTML description of the term. Optional
name HTML title for the term. Optional
slug An alphanumeric identifier for the term unique to its type. Optional
parent The parent term ID. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Categories.meta Unknown Metadata
Wordpress.Categories.parent Number Parent
Wordpress.Categories.name String Name
Wordpress.Categories.slug String Slug
Wordpress.Categories.count Number Count
Wordpress.Categories.taxonomy String Taxonomy
Wordpress.Categories._links List Links
Wordpress.Categories.link String Link
Wordpress.Categories.id Number ID
Wordpress.Categories.description String Description

wordpress-delete-category


Delete a category

Base Command

wordpress-delete-category

Input

Argument Name Description Required
id Category ID. Required

Context Output

There is no context output for this command.

wordpress-list-tags


Lists all tags

Base Command

wordpress-list-tags

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
page Current page of the collection (defaults is 1). Optional
per_page Maximum number of items to be returned in result set (default is 10). Optional
search Limit results to those matching a string. Optional
exclude Ensure result set excludes specific IDs. Optional
include Limit result set to specific IDs. Optional
offset Offset the result set by a specific number of items. Optional
order Order sort attribute ascending or descending (default is desc). Possible values are: desc, asc. Default is desc. Optional
orderby Sort collection by object attribute (default is date). Possible values are: author, date, id, include, modified, parent, relevance, slug, include_slugs, title. Default is date. Optional
slug Limit result set to posts with one or more specific slugs. Optional
hide_empty Whether to hide terms not assigned to any posts. Optional
post Limit result set to terms assigned to a specific post. Optional

Context Output

Path Type Description
Wordpress.Tags.meta Unknown Metadata
Wordpress.Tags.name String Name
Wordpress.Tags.slug String Slug
Wordpress.Tags.count Number Count
Wordpress.Tags.taxonomy String Taxonomy
Wordpress.Tags._links List Links
Wordpress.Tags.link String Link
Wordpress.Tags.id Number ID
Wordpress.Tags.description String Description

wordpress-create-tag


Create a tag

Base Command

wordpress-create-tag

Input

Argument Name Description Required
description HTML description of the term. Optional
name HTML title for the term. Optional
slug An alphanumeric identifier for the term unique to its type. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Tags.meta Unknown Metadata
Wordpress.Tags.name String Name
Wordpress.Tags.slug String Slug
Wordpress.Tags.count Number Count
Wordpress.Tags.taxonomy String Taxonomy
Wordpress.Tags._links List Links
Wordpress.Tags.link String Link
Wordpress.Tags.id Number ID
Wordpress.Tags.description String Description

wordpress-get-tag


Retrieves a tag

Base Command

wordpress-get-tag

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
id Tag ID. Required

Context Output

Path Type Description
Wordpress.Tags.meta Unknown Metadata
Wordpress.Tags.name String Name
Wordpress.Tags.slug String Slug
Wordpress.Tags.count Number Count
Wordpress.Tags.taxonomy String Taxonomy
Wordpress.Tags._links List Links
Wordpress.Tags.link String Link
Wordpress.Tags.id Number ID
Wordpress.Tags.description String Description

wordpress-update-tag


Update a tag

Base Command

wordpress-update-tag

Input

Argument Name Description Required
id Tag ID. Required
description HTML description of the term. Optional
name HTML title for the term. Optional
slug An alphanumeric identifier for the term unique to its type. Optional
parent The parent term ID. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Tags.meta Unknown Metadata
Wordpress.Tags.name String Name
Wordpress.Tags.slug String Slug
Wordpress.Tags.count Number Count
Wordpress.Tags.taxonomy String Taxonomy
Wordpress.Tags._links List Links
Wordpress.Tags.link String Link
Wordpress.Tags.id Number ID
Wordpress.Tags.description String Description

wordpress-delete-tag


Delete a tag

Base Command

wordpress-delete-tag

Input

Argument Name Description Required
id Tag ID. Required

Context Output

There is no context output for this command.

wordpress-list-comments


Lists all comments

Base Command

wordpress-list-comments

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
page Current page of the collection (defaults is 1). Optional
per_page Maximum number of items to be returned in result set (default is 10). Optional
search Limit results to those matching a string. Optional
after Limit response to comments published after a given ISO8601 compliant date. Optional
author Limit result set to comments assigned to specific user IDs. Optional
author_exclude Ensure result set excludes comments assigned to specific user IDs. Optional
author_email Limit result set to that from a specific author email. Optional
before Limit response to comments published before a given ISO8601 compliant date. Optional
exclude Ensure result set excludes specific IDs. Optional
include Limit result set to specific IDs. Optional
offset Offset the result set by a specific number of items. Optional
order Order sort attribute ascending or descending (default is desc). Possible values are: desc, asc. Default is desc. Optional
orderby Sort collection by object attribute (default is date_gmt). Possible values are: date, date_gmt, id, include, post, parent, type. Default is date_gmt. Optional
parent Limit result set to terms assigned to a specific parent. Optional
parent_exclude Ensure result set excludes specific parent IDs. Optional
post Limit result set to terms assigned to a specific post. Optional
status Limit result set to comments assigned a specific status (default is approve). Default is approve. Optional
type Limit result set to comments assigned a specific type (default is comment). Default is comment. Optional
password The password for the post if it is password protected. Optional

Context Output

Path Type Description
Wordpress.Comments.post String Post ID
Wordpress.Comments.meta String Metadata
Wordpress.Comments.parent Number Parent ID
Wordpress.Comments.author Number Author ID
Wordpress.Comments.date String Date
Wordpress.Comments.status String Status
Wordpress.Comments.author_avatar_urls List Author svatars
Wordpress.Comments.content.rendered String Rendered content
Wordpress.Comments._links List Links
Wordpress.Comments.type String Type
Wordpress.Comments.link String Link
Wordpress.Comments.author_url String Author URL
Wordpress.Comments.id Number id
Wordpress.Comments.date_gmt String Date GMT
Wordpress.Comments.author_name String Author name

wordpress-create-comment


Create a comment

Base Command

wordpress-create-comment

Input

Argument Name Description Required
author The ID of the user object, if author was a user. Optional
author_email Email address for the object author. Optional
author_ip IP address for the object author. Optional
author_name Display name for the object author. Optional
author_url URL for the object author. Optional
author_user_agent User agent for the object author. Optional
content The content for the object. Optional
parent The ID for the parent of the object. Optional
post The ID of the associated post object. Optional
status State of the object. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Comments.post String Post ID
Wordpress.Comments.meta String Metadata
Wordpress.Comments.parent Number Parent ID
Wordpress.Comments.author Number Author ID
Wordpress.Comments.date String Date
Wordpress.Comments.status String Status
Wordpress.Comments.author_avatar_urls List Author svatars
Wordpress.Comments.content.rendered String Rendered content
Wordpress.Comments._links List Links
Wordpress.Comments.type String Type
Wordpress.Comments.link String Link
Wordpress.Comments.author_url String Author URL
Wordpress.Comments.id Number id
Wordpress.Comments.date_gmt String Date GMT
Wordpress.Comments.author_name String Author name

wordpress-get-comment


Retrieves a comment

Base Command

wordpress-get-comment

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
id Comment ID. Required
password The password for the parent post of the comment (if the post is password protected). Optional

Context Output

Path Type Description
Wordpress.Comments.post String Post ID
Wordpress.Comments.meta String Metadata
Wordpress.Comments.parent Number Parent ID
Wordpress.Comments.author Number Author ID
Wordpress.Comments.date String Date
Wordpress.Comments.status String Status
Wordpress.Comments.author_avatar_urls List Author svatars
Wordpress.Comments.content.rendered String Rendered content
Wordpress.Comments._links List Links
Wordpress.Comments.type String Type
Wordpress.Comments.link String Link
Wordpress.Comments.author_url String Author URL
Wordpress.Comments.id Number id
Wordpress.Comments.date_gmt String Date GMT
Wordpress.Comments.author_name String Author name

wordpress-update-comment


Update a comment

Base Command

wordpress-update-comment

Input

Argument Name Description Required
id Comment ID. Required
author The ID of the user object, if author was a user. Optional
author_email Email address for the object author. Optional
author_ip IP address for the object author. Optional
author_name Display name for the object author. Optional
author_url URL for the object author. Optional
author_user_agent User agent for the object author. Optional
content The content for the object. Optional
date The date the object was published, in the sites timezone. Optional
date_gmt The date the object was published, as GMT. Optional
parent The ID for the parent of the object. Optional
post The ID of the associated post object. Optional
status State of the object. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Comments.post String Post ID
Wordpress.Comments.meta String Metadata
Wordpress.Comments.parent Number Parent ID
Wordpress.Comments.author Number Author ID
Wordpress.Comments.date String Date
Wordpress.Comments.status String Status
Wordpress.Comments.author_avatar_urls List Author svatars
Wordpress.Comments.content.rendered String Rendered content
Wordpress.Comments._links List Links
Wordpress.Comments.type String Type
Wordpress.Comments.link String Link
Wordpress.Comments.author_url String Author URL
Wordpress.Comments.id Number id
Wordpress.Comments.date_gmt String Date GMT
Wordpress.Comments.author_name String Author name

wordpress-delete-comment


Delete a comment

Base Command

wordpress-delete-comment

Input

Argument Name Description Required
id Tag ID. Required
force Whether to bypass Trash and force deletion (default is false). Possible values are: true, false. Default is false. Optional
password The password for the parent post of the comment (if the post is password protected). Optional

Context Output

Path Type Description
Wordpress.Comments.post String Post ID
Wordpress.Comments.meta String Metadata
Wordpress.Comments.parent Number Parent ID
Wordpress.Comments.author Number Author ID
Wordpress.Comments.date String Date
Wordpress.Comments.status String Status
Wordpress.Comments.author_avatar_urls List Author svatars
Wordpress.Comments.content.rendered String Rendered content
Wordpress.Comments._links List Links
Wordpress.Comments.type String Type
Wordpress.Comments.link String Link
Wordpress.Comments.author_url String Author URL
Wordpress.Comments.id Number id
Wordpress.Comments.date_gmt String Date GMT
Wordpress.Comments.author_name String Author name

wordpress-list-users


List users

Base Command

wordpress-list-users

Input

Argument Name Description Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional
page Current page of the collection (defaults is 1). Default is 1. Optional
per_page Maximum number of items to be returned in result set (default is 10). Optional
search Limit results to those matching a string. Optional
exclude Ensure result set excludes specific IDs. Optional
include Limit result set to specific IDs. Optional
offset Offset the result set by a specific number of items. Optional
order Order sort attribute ascending or descending (default is desc). Possible values are: desc, asc. Default is desc. Optional
orderby Sort collection by object attribute (default is name). Possible values are: id, include, name, registered_date, slug, include_slugs, email, url. Default is name. Optional
slug Limit result set to users with one or more specific slugs. Optional
roles Limit result set to users matching at least one specific role provided (CSV). Optional
who Limit result set to users who are considered authors. Possible values are: authors. Optional

Context Output

Path Type Description
Wordpress.Users.meta List Metadata
Wordpress.Users.avatar_urls List Avatar URLs
Wordpress.Users.name String Name
Wordpress.Users.slug String Slug
Wordpress.Users.url String URL
Wordpress.Users._links List Links
Wordpress.Users.link String Link
Wordpress.Users.id Number User ID
Wordpress.Users.description String Description

wordpress-get-user


Retrieve a user.

Base Command

wordpress-get-user

Input

Argument Name Description Required
id User ID. Required
context Scope under which the request is made; determines fields present in response (default is view). Possible values are: view, edit, embed. Default is view. Optional

Context Output

Path Type Description
Wordpress.Users.meta List Metadata
Wordpress.Users.avatar_urls List Avatar URLs
Wordpress.Users.name String Name
Wordpress.Users.slug String Slug
Wordpress.Users.url String URL
Wordpress.Users._links List Links
Wordpress.Users.link String Link
Wordpress.Users.id Number User ID
Wordpress.Users.description String Description

wordpress-create-user


Create a user

Base Command

wordpress-create-user

Input

Argument Name Description Required
locale Locale for the user (default is en_US). Default is en_US. Optional
username Login name for the user. Required
name Display name for the user. Optional
first_name First name for the user. Optional
last_name Last name for the user. Optional
email The email address for the user. Required
url URL of the user. Optional
description Description of the user. Optional
nickname The nickname for the user. Optional
slug An alphanumeric identifier for the user. Optional
roles Roles assigned to the user (CSV). Optional
password Password for the user. Required
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Users.meta List Metadata
Wordpress.Users.avatar_urls List Avatar URLs
Wordpress.Users.name String Name
Wordpress.Users.slug String Slug
Wordpress.Users.url String URL
Wordpress.Users._links List Links
Wordpress.Users.link String Link
Wordpress.Users.id Number User ID
Wordpress.Users.description String Description

wordpress-update-user


Update a user

Base Command

wordpress-update-user

Input

Argument Name Description Required
id User ID. Required
locale Locale for the user (default is en_US). Default is en_US. Optional
username Login name for the user. Optional
name Display name for the user. Optional
first_name First name for the user. Optional
last_name Last name for the user. Optional
email The email address for the user. Optional
url URL of the user. Optional
description Description of the user. Optional
nickname The nickname for the user. Optional
slug An alphanumeric identifier for the user. Optional
roles Roles assigned to the user (CSV). Optional
password Password for the user. Optional
meta Meta fields (JSON dict). Optional

Context Output

Path Type Description
Wordpress.Users.meta List Metadata
Wordpress.Users.avatar_urls List Avatar URLs
Wordpress.Users.name String Name
Wordpress.Users.slug String Slug
Wordpress.Users.url String URL
Wordpress.Users._links List Links
Wordpress.Users.link String Link
Wordpress.Users.id Number User ID
Wordpress.Users.description String Description

wordpress-delete-user


Delete a user

Base Command

wordpress-delete-user

Input

Argument Name Description Required
id User ID. Required
reassign Reassign the deleted users posts and links to this user ID. Required

Context Output

There is no context output for this command.

Configuration parameters

  • url — Your server URL (required)
  • credentials — Username (required)
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings

Commands (26)

  • wordpress-create-category

    Create a category

  • wordpress-create-comment

    Create a comment

  • wordpress-create-post

    Create a post

  • wordpress-create-tag

    Create a tag

  • wordpress-create-user

    Create a user

  • wordpress-delete-category

    Delete a category

  • wordpress-delete-comment

    Delete a comment

  • wordpress-delete-post

    Delete a post

  • wordpress-delete-tag

    Delete a tag

  • wordpress-delete-user

    Delete a user

  • wordpress-get-category

    Retrieve a category

  • wordpress-get-comment

    Retrieves a comment

  • wordpress-get-post

    Retrieve a specific post record.

  • wordpress-get-tag

    Retrieves a tag

  • wordpress-get-user

    Retrieve a user.

  • wordpress-list-categories

    List categories

  • wordpress-list-comments

    Lists all comments

  • wordpress-list-posts

    Lists all posts

  • wordpress-list-tags

    Lists all tags

  • wordpress-list-users

    List users

  • wordpress-update-category

    Update a category

  • wordpress-update-comment

    Update a comment

  • wordpress-update-post

    Update a post

  • wordpress-update-tag

    Update a tag

  • wordpress-update-user

    Update a user

  • wordpress-url-request

    Get information from a custom URL

import demistomock as demisto
from CommonServerPython import *  # noqa # pylint: disable=unused-wildcard-import
from CommonServerUserPython import *  # noqa

import urllib3
import traceback
from collections.abc import Callable

# Disable insecure warnings
urllib3.disable_warnings()  # pylint: disable=no-member


""" CONSTANTS """


""" CLIENT CLASS """


class Client(BaseClient):
    def url_request(self, method, url, body: dict = None, params: dict = None):
        response = self._http_request(method, url, json_data=body, params=params)
        return response

    def list_posts(self, args: dict = {}):
        url_suffix = "/wp-json/wp/v2/posts"
        response = self._http_request("GET", url_suffix, params=args)
        return response

    def get_post(self, post_id, params: dict = {}):
        url_suffix = f"wp-json/wp/v2/posts/{post_id}"
        response = self._http_request("GET", url_suffix, params=params)
        return response

    def create_post(self, args: dict):
        url_suffix = "/wp-json/wp/v2/posts"
        response = self._http_request("POST", url_suffix=url_suffix, json_data=args)
        return response

    def update_post(self, post_id, args: dict):
        url_suffix = f"/wp-json/wp/v2/posts/{post_id}"
        response = self._http_request("POST", url_suffix=url_suffix, json_data=args)
        return response

    def delete_post(self, post_id, force):
        url_suffix = f"/wp-json/wp/v2/posts/{post_id}"
        params = {"force": force}
        response = self._http_request("DELETE", url_suffix=url_suffix, params=params)
        return response

    def list_categories(self):
        url_suffix = "wp-json/wp/v2/categories"
        response = self._http_request("GET", url_suffix)
        return response

    def create_category(self, params: dict):
        url_suffix = "wp-json/wp/v2/categories"
        response = self._http_request("POST", url_suffix, params=params)
        return response

    def get_category(self, category_id, params: dict):
        url_suffix = f"wp-json/wp/v2/categories/{category_id}"
        response = self._http_request("GET", url_suffix, params=params)
        return response

    def update_category(self, category_id, args: dict):
        url_suffix = f"wp-json/wp/v2/categories/{category_id}"
        response = self._http_request("POST", url_suffix, json_data=args)
        return response

    def delete_category(self, category_id):
        url_suffix = f"/wp-json/wp/v2/categories/{category_id}"
        params = {"force": True}
        response = self._http_request("DELETE", url_suffix=url_suffix, params=params)
        return response

    def list_tags(self):
        url_suffix = "wp-json/wp/v2/tags"
        response = self._http_request("GET", url_suffix)
        return response

    def create_tag(self, params: dict):
        url_suffix = "wp-json/wp/v2/tags"
        response = self._http_request("POST", url_suffix, params=params)
        return response

    def get_tag(self, tag_id, params: dict):
        url_suffix = f"wp-json/wp/v2/tags/{tag_id}"
        response = self._http_request("GET", url_suffix, params=params)
        return response

    def update_tag(self, tag_id, args: dict):
        url_suffix = f"wp-json/wp/v2/tags/{tag_id}"
        response = self._http_request("POST", url_suffix, json_data=args)
        return response

    def delete_tag(self, tag_id):
        url_suffix = f"/wp-json/wp/v2/tags/{tag_id}"
        params = {"force": True}
        response = self._http_request("DELETE", url_suffix=url_suffix, params=params)
        return response

    def list_comments(self, args: dict = {}):
        url_suffix = "/wp-json/wp/v2/comments"
        response = self._http_request("GET", url_suffix, params=args)
        return response

    def get_comment(self, comment_id, params: dict = {}):
        url_suffix = f"wp-json/wp/v2/comments/{comment_id}"
        response = self._http_request("GET", url_suffix, params=params)
        return response

    def create_comment(self, args: dict):
        url_suffix = "/wp-json/wp/v2/comments"
        response = self._http_request("POST", url_suffix=url_suffix, json_data=args)
        return response

    def update_comment(self, comment_id, args: dict):
        url_suffix = f"/wp-json/wp/v2/comments/{comment_id}"
        response = self._http_request("POST", url_suffix=url_suffix, json_data=args)
        return response

    def delete_comment(self, comment_id, force):
        url_suffix = f"/wp-json/wp/v2/comments/{comment_id}"
        params = {"force": force}
        response = self._http_request("DELETE", url_suffix=url_suffix, params=params)
        return response

    def list_users(self, args: dict = {}):
        url_suffix = "/wp-json/wp/v2/users"
        response = self._http_request("GET", url_suffix, params=args)
        return response

    def get_user(self, user_id, params: dict = {}):
        url_suffix = f"wp-json/wp/v2/users/{user_id}"
        response = self._http_request("GET", url_suffix, params=params)
        return response

    def create_user(self, args: dict):
        url_suffix = "/wp-json/wp/v2/users"
        response = self._http_request("POST", url_suffix=url_suffix, json_data=args)
        return response

    def update_user(self, user_id, args: dict):
        url_suffix = f"/wp-json/wp/v2/users/{user_id}"
        response = self._http_request("POST", url_suffix=url_suffix, json_data=args)
        return response

    def delete_user(self, user_id, args):
        url_suffix = f"/wp-json/wp/v2/users/{user_id}"
        response = self._http_request("DELETE", url_suffix=url_suffix, params=args)
        return response


""" HELPER FUNCTIONS """

# TODO: ADD HERE ANY HELPER FUNCTION YOU MIGHT NEED (if any)

""" COMMAND FUNCTIONS """


def test_module(client: Client) -> str:
    client.list_posts()
    return "ok"


def url_request_command(client: Client, args: dict = {}):
    url = args.get("url")
    method = str(args.get("method")).lower()
    body = args.get("body")
    if body:
        try:
            body = json.loads(body)
        except Exception as err:
            return_error(f"There was an error parsing the body:\n{err}")
    params = args.get("params")
    if params:
        try:
            params = json.loads(params)
        except Exception as err:
            return_error(f"There was an error parsing the params:\n{err}")
    response = client.url_request(method, url, body=body, params=params)
    outputs = {"url": url, "data": response}
    command_results = CommandResults(
        outputs_prefix="Wordpress.URL",
        outputs_key_field=["url"],
        outputs=outputs,
        readable_output=tableToMarkdown(f"{url}:", response),
    )
    return_results(command_results)


def list_posts_command(client: Client, args: dict = {}):
    response = client.list_posts(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Posts",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Posts:", response),
    )
    return_results(command_results)


def get_post_command(client: Client, args: dict = {}):
    post_id = args.get("id")
    params = {k: v for k, v in args.items() if k != "id"}
    response = client.get_post(post_id, params=params)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Posts",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Posts:", response),
    )
    return_results(command_results)


def create_post_command(client: Client, args: dict):
    if args.get("sticky"):
        args["sticky"] = argToBoolean(args.get("sticky"))
    if args.get("meta"):
        try:
            args["meta"] = json.loads(str(args.get("meta")))
        except Exception as err:
            return_error(f"Error converting meta: {err}")
    if args.get("categories"):
        args["categories"] = [arg_to_number(x) for x in argToList(args.get("categories"))]
    if args.get("tags"):
        args["tags"] = [arg_to_number(x) for x in argToList(args.get("tags"))]
    response = client.create_post(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Posts",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Post created:", response),
    )
    return_results(command_results)


def update_post_command(client: Client, args: dict):
    post_id = args.get("id")
    if args.get("sticky"):
        args["sticky"] = argToBoolean(args.get("sticky"))
    if args.get("meta"):
        try:
            args["meta"] = json.loads(str(args.get("meta")))
        except Exception as err:
            return_error(f"Error converting meta: {err}")
    if args.get("categories"):
        args["categories"] = [arg_to_number(x) for x in argToList(args.get("categories"))]
    if args.get("tags"):
        args["tags"] = [arg_to_number(x) for x in argToList(args.get("tags"))]
    args = {k: v for k, v in args.items() if k != "id"}
    response = client.update_post(post_id, args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Posts",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Post {post_id} updated:", response),
    )
    return_results(command_results)


def delete_post_command(client: Client, args: dict):
    post_id = args.get("id")
    force = argToBoolean(args.get("force"))
    response = client.delete_post(post_id, force)
    command_results = CommandResults()
    if force:
        command_results.readable_output = f"Post {post_id} permanently deleted."
    else:
        command_results.readable_output = tableToMarkdown(f"Post {post_id} moved to trash:", response)
        command_results.outputs_prefix = "Wordpress.Posts"
        command_results.outputs_key_field = "id"
        command_results.outputs = response
    return_results(command_results)


def list_categories_command(client: Client, args: dict):
    response = client.list_categories()
    command_results = CommandResults(
        outputs_prefix="Wordpress.Categories",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Categories:", response),
    )
    return_results(command_results)


def create_category_command(client: Client, args: dict):
    response = client.create_category(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Categories",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Created new category:", response),
    )
    return_results(command_results)


def get_category_command(client: Client, args: dict):
    category_id = args.get("id")
    params = {"context": args.get("context")}
    response = client.get_category(category_id, params)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Categories",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Category {category_id}:", response),
    )
    return_results(command_results)


def update_category_command(client: Client, args: dict):
    category_id = args.get("id")
    args = {k: v for k, v in args.items() if k != "id"}
    response = client.update_category(category_id, args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Categories",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Category {category_id} updated:", response),
    )
    return_results(command_results)


def delete_category_command(client: Client, args: dict):
    post_id = args.get("id")
    client.delete_category(post_id)
    command_results = CommandResults(readable_output=f"Category {post_id} permanently deleted.")
    return_results(command_results)


def list_tags_command(client: Client, args: dict):
    response = client.list_tags()
    command_results = CommandResults(
        outputs_prefix="Wordpress.Tags",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Tags:", response),
    )
    return_results(command_results)


def create_tag_command(client: Client, args: dict):
    response = client.create_tag(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Tags",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Created new tag:", response),
    )
    return_results(command_results)


def get_tag_command(client: Client, args: dict):
    tag_id = args.get("id")
    params = {"context": args.get("context")}
    response = client.get_tag(tag_id, params)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Tags",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Tag {tag_id}:", response),
    )
    return_results(command_results)


def update_tag_command(client: Client, args: dict):
    tag_id = args.get("id")
    args = {k: v for k, v in args.items() if k != "id"}
    response = client.update_tag(tag_id, args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Tags",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Tag {tag_id} updated:", response),
    )
    return_results(command_results)


def delete_tag_command(client: Client, args: dict):
    tag_id = args.get("id")
    client.delete_tag(tag_id)
    command_results = CommandResults(readable_output=f"Tag {tag_id} permanently deleted.")
    return_results(command_results)


def list_comments_command(client: Client, args: dict):
    response = client.list_comments()
    command_results = CommandResults(
        outputs_prefix="Wordpress.Comments",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Comments:", response),
    )
    return_results(command_results)


def create_comment_command(client: Client, args: dict):
    response = client.create_comment(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Comments",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Created new comment:", response),
    )
    return_results(command_results)


def get_comment_command(client: Client, args: dict):
    comment_id = args.get("id")
    params = {k: v for k, v in args.items() if k != "id"}
    response = client.get_comment(comment_id, params)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Comments",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Comment {comment_id}:", response),
    )
    return_results(command_results)


def update_comment_command(client: Client, args: dict):
    comment_id = args.get("id")
    args = {k: v for k, v in args.items() if k != "id"}
    response = client.update_comment(comment_id, args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Comments",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"Tag {comment_id} updated:", response),
    )
    return_results(command_results)


def delete_comment_command(client: Client, args: dict):
    comment_id = args.get("id")
    force = argToBoolean(args.get("force"))
    response = client.delete_comment(comment_id, force)
    command_results = CommandResults()
    if force:
        command_results.readable_output = f"Comment {comment_id} permanently deleted."
    else:
        command_results.readable_output = tableToMarkdown(f"Comment {comment_id} moved to trash:", response)
        command_results.outputs_prefix = "Wordpress.Comments"
        command_results.outputs_key_field = "id"
        command_results.outputs = response
    return_results(command_results)


def list_users_command(client: Client, args: dict = {}):
    response = client.list_users(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Users",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Users:", response),
    )
    return_results(command_results)


def get_user_command(client: Client, args: dict = {}):
    user_id = args.get("id")
    params = {k: v for k, v in args.items() if k != "id"}
    response = client.get_user(user_id, params=params)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Users",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("Users:", response),
    )
    return_results(command_results)


def create_user_command(client: Client, args: dict):
    response = client.create_user(args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Users",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown("User created:", response),
    )
    return_results(command_results)


def update_user_command(client: Client, args: dict):
    user_id = args.get("id")
    args = {k: v for k, v in args.items() if k != "id"}
    response = client.update_user(user_id, args)
    command_results = CommandResults(
        outputs_prefix="Wordpress.Users",
        outputs_key_field="id",
        outputs=response,
        readable_output=tableToMarkdown(f"User {user_id} updated:", response),
    )
    return_results(command_results)


def delete_user_command(client: Client, args: dict):
    user_id = args.get("id")
    reassign_id = args.get("reassign")
    args = {"force": True, "reassign": reassign_id}
    client.delete_user(user_id, args)
    command_results = CommandResults(
        readable_output=f"User {user_id} permanently deleted.\n Reassigned posts to user ID {reassign_id}"
    )
    return_results(command_results)


""" MAIN FUNCTION """


def main() -> None:
    params = demisto.params()
    args = demisto.args()
    base_url = params.get("url")
    credentials = params.get("credentials")
    user = credentials.get("identifier")
    app_password = credentials.get("password")
    verify_certificate = not demisto.params().get("insecure", False)
    proxy = demisto.params().get("proxy", False)

    command = demisto.command()
    demisto.debug(f"Command being called is {command}")
    try:
        commands: dict[str, Callable] = {
            "wordpress-list-posts": list_posts_command,
            "wordpress-get-post": get_post_command,
            "wordpress-url-request": url_request_command,
            "wordpress-create-post": create_post_command,
            "wordpress-update-post": update_post_command,
            "wordpress-delete-post": delete_post_command,
            "wordpress-list-categories": list_categories_command,
            "wordpress-create-category": create_category_command,
            "wordpress-get-category": get_category_command,
            "wordpress-update-category": update_category_command,
            "wordpress-delete-category": delete_category_command,
            "wordpress-list-tags": list_tags_command,
            "wordpress-create-tag": create_tag_command,
            "wordpress-get-tag": get_tag_command,
            "wordpress-update-tag": update_tag_command,
            "wordpress-delete-tag": delete_tag_command,
            "wordpress-list-comments": list_comments_command,
            "wordpress-create-comment": create_comment_command,
            "wordpress-get-comment": get_comment_command,
            "wordpress-update-comment": update_comment_command,
            "wordpress-delete-comment": delete_comment_command,
            "wordpress-list-users": list_users_command,
            "wordpress-create-user": create_user_command,
            "wordpress-get-user": get_user_command,
            "wordpress-update-user": update_user_command,
            "wordpress-delete-user": delete_user_command,
        }

        headers: dict = {}
        client = Client(base_url=base_url, verify=verify_certificate, headers=headers, proxy=proxy, auth=(user, app_password))

        if demisto.command() == "test-module":
            # This is the call made when pressing the integration Test button.
            result = test_module(client)
            return_results(result)

        elif command in commands:
            commands[command](client, args)  # type: ignore[operator]

    # Log exceptions and return errors
    except Exception as e:
        demisto.error(traceback.format_exc())  # print the traceback
        return_error(f"Failed to execute {demisto.command()} command.\nError:\n{str(e)}")


""" ENTRY POINT """


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()