A Python 3 client for the Pyrus API. The full documentation for API can be found here
-
instal pyrus-api library:
-
pip (preffered)
$ pip install --upgrade pyrus-api
-
Setuptools: Use the easy_install tool included in the setuptools package:
$ easy_install --upgrade pyrus-api
-
Manual installation: Download the latest version of pyrus-api client, unpack the code, and run:
$ python setup.py install
-
-
Import packages into your project:
from pyrus import client
import pyrus.models
- Create API client:
pyrus_client = client.PyrusAPI(login='[email protected]', security_key='sadf2R5Wrdkn..')
- Perform authorization:
auth_response = pyrus_client.auth()
if auth_response.success:
pass
- Get all form templates:
forms_response = pyrus_client.get_forms()
forms = forms_response.forms
- Get tasks list by form template:
request = pyrus.models.requests.FormRegisterRequest(
include_archived=True,
steps=[1,2],
filters=[pyrus.models.entities.EqualsFilter(1, "hello world")])
form_register_response = pyrus_client.get_registry(forms[0].id, request)
tasks = form_register_response.tasks
- Get task with all comments:
task = pyrus_client.get_task(tasks[0].id).task
- Add task comment:
request = pyrus.models.requests.TaskCommentRequest(text="hello", action="finished")
task = pyrus_client.comment_task(tasks[0].id, request).task
- Create a task:
request = CreateTaskRequest(
text="Task from python client",
participants=['[email protected]', 10196]
attachments = ['BEFCE22E-AEFF-4771-83D4-2A4B78FB05C6'])
task = pyrus_client.create_task(request).task
- Upload a file:
response = pyrus_client.upload_file('C:\\path\\to\\file.txt').guid
- Get catalog with all items:
catalog_id = 1525
catalog_response = pyrus_client.get_catalog(catalog_id)
items = catalog_response.items
- Create catalog
request = pyrus.models.requests.CreateCatalogRequest(
name = "NewCatalog",
catalog_headers = ["Column1", "Column2", "Column3"],
items = [
["A1", "A2", "A3"],
["B1", "B2", "B3"],
["C1", "C2", "C3"]
]
)
catalog_id = pyrus_client.create_catalog(request).catalog_id
- Sync catalog (All unspecified catalog items and text columns will be deleted)
catalog_id = 7825
request = pyrus.models.requests.SyncCatalogRequest(
apply = True,
catalog_headers = ["Column1", "Column4", "Column3"],
items = [
["A1", "A2", "A3"],
["B1", "B4", "B5"],
["D1", "D2", "D3"]
]
)
response = pyrus_client.sync_catalog(catalog_id, request)
deleted = response.deleted
updated = response.updated
added = response.added
new_headers = response.catalog_headers
- Update catalog items (All unspecified items will be left intact)
catalog_id = 7825
request = pyrus.models.requests.UpdateCatalogItemsRequest(
upsert = [
["A1", "A5", "A6"],
["E1", "E2", "E3"]
],
delete = ["B1"]
)
response = pyrus_client.update_catalog_items(catalog_id, request)
deleted = response.deleted
updated = response.updated
added = response.added
- Get all available contacts:
contacts = pyrus_client.get_contacts()
- Get all lists
response = pyrus_client.get_lists()
lists = response.lists
- Get all tasks in list
list_id = 1522
response = pyrus_client.get_task_list(list_id, item_count=25, include_archived=True)
tasks = response.tasks
- Get profile:
profile_response = pyrus_client.get_profile()
- Get all organization roles:
roles_response = pyrus_client.get_roles()
roles = roles_response.roles
- Create role:
create_role_request = CreateRoleRequest(
name='TechSupport',
members=[1233, 3043])
role_response = pyrus_client.create_role(create_role_request)
- Update role:
Update_role_request = UpdateRoleRequest(
name='InternalTechSupport',
added_members=[2766],
removed_members=[1233])
role_response = pyrus_client.update_role(create_role_request)
- Get profile:
profile_response = pyrus_client.get_profile()
- Get inbox:
inbox_response = pyrus_client.get_inbox(tasks_count=100)
- Get calendar:
calendar_response = (pyrus_client.get_calendar_tasks(req.CalendarRequest(
datetime.datetime.utcnow() - datetime.timedelta(days=30),
datetime.datetime.utcnow() + datetime.timedelta(days=30),
all_accessed_tasks=True,
item_count=55,
filter_mask=0b0111)))
- Get announcement with all comments:
announcement = pyrus_client.get_announcement(12321321).announcement
- Get announcements with all comments:
announcements = pyrus_client.get_announcements().announcements
- Add announcement comment:
request = pyrus.models.requests.AnnouncementCommentRequest(text="hello", attachments = ['BEFCE22E-AEFF-4771-83D4-2A4B78FB05C6'])
announcement = pyrus_client.comment_announcement(12321321, request).announcement
- Create an announcement:
request = CreateAnnouncementRequest(
text="Announcement from python client",
attachments = ['BEFCE22E-AEFF-4771-83D4-2A4B78FB05C6'])
announcement = pyrus_client.create_announcement(request).announcement
- Get form permissions:
permissions = pyrus_client.get_permissions(123)
- Change form permissions:
request = pyrus.models.requests.ChangePermissionsRequest({1733:'member'})
changed_permissions = pyrus_client.change_permissions(123, request)
If you have any questions or comments please send an email to [email protected]