proknow.Workspaces – Workspaces

class proknow.Workspaces.Workspaces(proknow, requestor)

This class should be used to interact with the workspaces in a ProKnow organization. It is instantiated for you as an attribute of the proknow.ProKnow.ProKnow class.

__init__(proknow, requestor)

Initializes the Workspaces class.

Parameters:
create(slug, name, protected=True)

Creates a new workspace.

Parameters:
  • slug (str) – The workspace slug.
  • name (str) – The workspace name.
  • protected (bool, optional) – Indicates whether the workspace should be protected from accidental deletion.
Returns:

A representation of the created workspace.

Return type:

proknow.Workspaces.WorkspaceItem

Raises:

AssertionError – If the input parameters are invalid.

delete(identifier)

Deletes a workspace.

Parameters:identifier (str) – The id of the workspace to delete.
Raises:AssertionError – If the input parameters are invalid.
find(**kwargs)

Finds a workspace by id, slug, or name.

Note

This method utilizes a cache of workspaces. Once it has a cache of workspaces, it will use that cache until the proknow.Workspaces.Workspaces.query() method is called to refresh the cache. If you wish to make your code resilient to workspaces changes (i.e., new workspaces, renamed workspaces, deleted workspaces, etc.) while your script is running, you should call the proknow.Workspaces.Workspaces.query() method before this method. In most use cases, this is not necessary.

Parameters:**kwargs – A dictionary of keyword arguments that may include identifier, slug, and name. These arguments are considered—in that order—to find matching workspaces.
Returns:A representation of the matching workspace.
Return type:proknow.Workspaces.WorkspaceItem
query()

Queries for workspaces.

Note

This method refreshes the workspaces cache.

Returns:A list of proknow.Workspaces.WorkspaceItem objects, each representing a workspace in the organization.
Return type:list
class proknow.Workspaces.WorkspaceItem(workspaces, workspace)

This class represents a workspace. It’s instantiated by the proknow.Workspaces.Workspaces class to represent each of the workspaces in a query result and a created workspace.

id

str – The id of the workspace (readonly).

data

dict – The complete representation of the workspace as returned from the API (readonly).

slug

str – A string used in the URL that uniquely identifies the workspace.

name

str – The name of the workspace.

protected

bool – Indicates whether the workspace should be protected from accidental deletion.

__init__(workspaces, workspace)

Initializes the WorkspaceItem class.

Parameters:
  • workspaces (proknow.Workspaces.Workspaces) – The Workspaces instance that is instantiating the object.
  • workspace (dict) – A dictionary of workspace attributes.
delete()

Deletes the workspace.

save()

Saves the changes made to a workspace.

Example

The following example illustrates how to find a workspace by its slug, modify the name, and save it:

pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json")
clinical = pk.workspaces.find(slug='clinical')
clinical.name = "Clinical Patients"
clinical.save()