Map to @plone/client#

@plone/client is the JavaScript and TypeScript client for plone.restapi, used by Volto and Seven. This page maps its functions, as of version 2.0.0-alpha.8, to the methods of plone-client, so you can move between the two.

Conventions#

@plone/client

plone-client

Create a client

PloneClient.initialize({ apiPath, token })

PloneClient(url, username=…, password=…)

Log in

login({ data: { login, password } }), then pass the token

auth_method="jwt", or a token

Call style

A flat method on the client: cli.getContent(…)

A method on a manager: client.content.get(…)

Names

A verb and a noun: getX, createX, updateX, deleteX

The noun is the manager, the verb is the method: x.get, x.create, x.update, x.delete

Lists

getXs or getAllX

x.list

Arguments

One object: { path, data }

The item first, then keyword arguments: (ref, …)

Item

path

ref: a path, a URL, uid:<UID>, or a resolveuid link

Result

A promise of { status, data }

The decoded JSON, directly

Errors

A rejected promise with { status, data: { type, message } }

An exception per status, with status_code, error_type, and message

Execution

Asynchronous

Synchronous

The rule of thumb: cli.getComments({ path }) in JavaScript is client.comments.list(path) in Python, and cli.createComment({ path, data }) is client.comments.create(path, …).

Content#

Service

@plone/client

plone-client

GET item

getContent({ path, expand, fullObjects, version })

content.get(ref, expand=…, fullobjects=…, version=…)

POST item

createContent({ path, data })

content.create(parent, portal_type, data)

PATCH item

updateContent({ path, data })

content.update(ref, data)

DELETE item

deleteContent({ path })

content.delete(ref)

@copy

copyContent({ path, data })

content.copy(source, target)

@move

moveContent({ path, data })

content.move(source, target)

PATCH ordering

updateContent({ path, data: { ordering } })

content.order(folder, obj_id, delta)

@linkintegrity

getLinkintegrity({ uids })

content.link_integrity(uids)

GET @lock

getLock({ path })

content.lock_info(ref)

POST @lock

createLock({ path, data })

content.lock(ref)

PATCH @lock

updateLock({ path, locktoken })

content.refresh_lock(ref)

DELETE @lock

deleteLock({ path, data })

content.unlock(ref)

Workflow, history, and working copies#

Service

@plone/client

plone-client

GET @workflow

getWorkflow({ path })

workflow.get(ref)

POST @workflow/<transition>

createWorkflow({ path, transition, data })

workflow.transition(ref, transition)

GET @history

getHistory({ path })

history.list(ref)

GET @history/<version>

getHistoryVersion({ path, version })

history.get(ref, version)

PATCH @history

revertHistory({ path, data })

history.revert(ref, version)

GET @workingcopy

getWorkingcopy({ path })

working_copy.get(ref)

POST @workingcopy

createWorkingcopy({ path })

working_copy.create(ref)

PATCH @workingcopy

checkInWorkingcopy({ path })

working_copy.check_in(ref)

DELETE @workingcopy

deleteWorkingcopy({ path })

working_copy.delete(ref)

Comments, translations, aliases, and relations#

Service

@plone/client

plone-client

GET @comments

getComments({ path })

comments.list(ref)

POST @comments

createComment({ path, in_reply_to, data })

comments.create(ref, text, reply_to=…)

PATCH @comments/<id>

updateComment({ path, comment_id, data })

comments.update(ref, comment_id, text)

DELETE @comments/<id>

deleteComment({ path, comment_id })

comments.delete(ref, comment_id)

GET @translations

getTranslation({ path })

translations.get(ref)

POST @translations

linkTranslation({ path, data })

translations.link(ref, translation)

DELETE @translations

unlinkTranslation({ path, data })

translations.unlink(ref, language)

GET @aliases on the root

getAllAliases()

aliases.list()

GET @aliases on an item

getAliases({ path })

aliases.list(ref)

POST @aliases on an item

createAlias({ path, data })

aliases.create(ref, aliases)

POST @aliases on the root

createAliases({ data })

aliases.create_redirects(redirects)

DELETE @aliases

deleteAliases({ path, data })

aliases.delete(ref, aliases)

GET @relations

getAllRelations(), getRelations({ source, relation, onlyBroken })

relations.list(…)

POST @relations

createRelations({ data })

relations.create(relations)

DELETE @relations

deleteRelations({ data })

relations.delete(…)

POST @relations/rebuild

fixRelations({ data })

relations.rebuild(flush=…)

Users, groups, and sharing#

Service

@plone/client

plone-client

GET @users

getUsers({ query, groupsFilter, search, limit })

users.list(…)

GET @users/<id>

getUser({ id })

users.get(user_id)

POST @users

createUser({ data })

users.create(username, data)

PATCH @users/<id>

updateUser({ id, data })

users.update(user_id, data)

DELETE @users/<id>

deleteUser({ id })

users.delete(user_id)

POST @users/<id>/reset-password, to email a link

resetPassword({ id })

users.reset_password(user_id)

POST @users/<id>/reset-password, with the old password

updatePassword({ id, data })

users.update_password(user_id, new_password, old_password=…)

POST @users/<id>/reset-password, with a reset token

resetPasswordWithToken({ id, data })

users.update_password does not take a token yet

@userschema

getUserschema()

users.schema()

GET @groups

getGroups()

groups.list()

GET @groups/<id>

getGroup({ id })

groups.get(group_id)

POST @groups

createGroup({ data })

groups.create(groupname, data)

PATCH @groups/<id>

updateGroup({ id, data })

groups.update(group_id, data); groups.add_members and groups.remove_members for membership

DELETE @groups/<id>

deleteGroup({ id })

groups.delete(group_id)

GET @sharing

getSharing({ path, search })

sharing.get(ref, search=…)

POST @sharing

updateSharing({ path, data })

sharing.update(ref, entries)

@principals

getPrincipals({ search })

sharing.principals(search)

@roles

getRoles()

sharing.roles()

Types and vocabularies#

Service

@plone/client

plone-client

GET @types

getTypes()

types.list()

GET @types/<type>

getType({ type })

types.get(portal_type)

GET @types/<type>/<field>

getTypeField({ contentFieldPath })

types.get_field(portal_type, name)

POST @types/<type>

createTypeField({ contentPath, data })

types.create_field(portal_type, data)

PATCH @types/<type>

updateTypeField({ contentPath, data })

types.update(portal_type, data, name=…)

GET @vocabularies

getVocabularies()

vocabularies.list()

GET @vocabularies/<name>

getVocabulary({ path, title, token, tokens, b_size })

vocabularies.get(name, …), vocabularies.iter for every page

@sources/<field>

getSource({ path, field })

vocabularies.source(ref, field)

@querysources/<field>

getQuerysources({ path, field, query })

vocabularies.querysource(ref, field, query)

Site administration#

Service

@plone/client

plone-client

GET @registry

getRegistry()

registry.list()

GET @registry/<name>

getRegistryRecord({ name })

registry.get(key)

PATCH @registry

updateRegistry({ data })

registry.update(values)

GET @controlpanels

getControlpanels()

controlpanels.list()

GET @controlpanels/<id>

getControlpanel({ id })

controlpanels.get(panel)

POST @controlpanels/<id>

createControlpanel({ path, data })

controlpanels.create(panel, data)

PATCH @controlpanels/<id>

updateControlpanel({ path, data })

controlpanels.update(panel, data)

DELETE @controlpanels/<id>

deleteControlpanel({ path, data })

controlpanels.delete(panel, item)

GET @addons

getAddons()

addons.list()

GET @addons/<id>

getAddon({ id })

addons.get(addon)

POST @addons/<id>/install

installAddon({ id })

addons.install(addon)

POST @addons/<id>/uninstall

uninstallAddon({ id })

addons.uninstall(addon)

POST @addons/<id>/upgrade

upgradeAddon({ id })

addons.upgrade(addon)

POST @addons/<id>/<profile>

installAddonProfile({ id, profile })

addons.install_profile(addon, profile)

GET @content-rules

getRules()

content_rules.get(ref)

POST @content-rules/<id>

createRule({ ruleId })

content_rules.assign(ref, rule_id)

PATCH @content-rules

updateRules({ data })

content_rules.enable, disable, apply_to_subfolders, move

DELETE @content-rules

deleteRules({ data })

content_rules.unassign(ref, rule_ids)

@site

getSite()

system.site()

@system

getSystem()

system.system()

@database

getDatabase()

system.database()

GET @transactions

getTransactions()

system.transactions()

PATCH @transactions

revertTransactions({ data })

system.revert_transactions(transaction_ids)

GET @upgrade

getUpgrade()

system.upgrade_info()

POST @upgrade

runUpgrade({ data })

system.upgrade(dry_run=…)

@email-send

emailSend({ data })

system.email_send(…)

@email-notification

emailNotification({ user, data })

system.email_notification(…)

POST @login

login({ data })

PloneClient(…, auth_method="jwt") logs in by itself

Only in plone-client#

plone-client

Does

content.children, exists, find_by_uid, resolve, sort

Conveniences built on @search and PATCH.

search.count

The number of results of a search.

files

Uploads, @tus-upload, @tus-replace, downloads, and image scales.

navigation.inherit

@inherit.

translations.locate

@translation-locator.

relations.stats

GET @relations without a filter, as counts.

types.addable, replace, delete_field

Addable types, and PUT and DELETE on @types.

users.portrait

@portrait.

system.login_providers

GET @login.

Only in @plone/client#

@plone/client

Does

resetPasswordWithToken({ id, data })

Sets a new password with the token from a reset email.

PloneClient.extend({ … })

Adds methods for add-on services to the client class.