@iflb/tutti-client
v0.3.10
Published
## Installation
Readme
Tutti JavaScript Client API
Installation
Node.js:
npm install @iflb/tutti-clientUsage
There are two ways to communicate with Tutti server: Call mode and Send mode.
Call mode
Calling commands with await prefix, the process waits there until the response is sent back, and receives it as a return value.
Directions
const data = await client.<namespace>.<command>({ <args object> }, awaited = true);OR equivalently,
const data = await client.<namespace>.<command>.call(<args object>);Send mode
Calling commands without await prefix, the process completes as soon as request is sent, and receives it in its listener.
Directions
Having defined a listener like below,
client.<namespace>.on('<command>', {
success: (data) => {
// do something for successful response...
},
error: (err) => {
// do something for errors...
},
complete: () => {
// do another thing to finalize request...
}
});Run:
client.<namespace>.<command>({ <args object> }, awaited = false);OR equivalently,
client.<namespace>.<command>.send(<args object>);Code Examples
Node.js:
const { TuttiClient } = require('@iflb/tutti-client');
async function main() {
let client = new TuttiClient(true);
await client.open('http://localhost:8080/ducts/wsd');
// Sign in with an account first
await client.resource.signIn({ user_name: 'admin', password: 'admin' })
// Get a list of created projects
const projects = await client.resource.listProjects();
// List templates for the first project
const templates = await client.resource.listTemplates({ project_name: projects[0].name });
}
main();Browser:
<script src="https://unpkg.com/@iflb/tutti-client/dist/tutti.js"></script>
<script>
async function main() {
const client = new tutti.TuttiClient(true);
await client.open('http://localhost:8080/ducts/wsd');
// Sign in with an account first
await client.resource.signIn({ user_name: 'admin', password: 'admin' })
// Get a list of created projects
const projects = await client.resource.listProjects();
// List templates for the first project
const templates = await client.resource.listTemplates({ project_name: projects[0].name });
}
main();
</script>Commands
Current options for namespaces are: resource, mturk.
TuttiClient.resource
checkProjectDiff
project_name: String- Tutti project name.
- Boolean -- True if the project is in the newest version, thus no rebuild is needed.
createNanotaskGroup
name: String- Name for the nanotask group. Must be unique.
nanotask_ids: Arrayproject_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
- String -- Created nanotask group ID.
createNanotasks
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
nanotasks: Arraytag: String- An arbitrary data field to tag nanotask for identifying purposes.
priority: Number- An integer value to represent nanotask importance. The smaller the value is, more prioritized the nanotask is among others. To learn more about nanotask priority, see Tutti's Programming Reference > Project Scheme.
num_assignable: Number- Maximum number of workers that can be assigned to nanotask.
- Object
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
nanotask_ids: Array
createProject
project_name: String- Tutti project name.
createTemplate
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
preset_group_name: Stringpreset_name: String
deleteAccount
user_id: String- User ID of Tutti account.
deleteNanotaskGroup
nanotask_group_id: String
deleteNanotasks
nanotask_ids: Array
deleteProject
project_name: String- Tutti project name.
deleteTemplate
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
getNanotaskGroup
nanotask_group_id: String
getProjectScheme
project_name: String- Tutti project name.
cached: Boolean- Whether to return cached value in the response. Note that setting this value to false may result in slower responses.
getUserIds
- [None]
getWebServiceDescriptor
- [None]
listNanotaskGroups
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
listNanotasks
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
listNanotasksWithResponses
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
listNodeSessionsForWorkSession
work_session_id: Stringonly_template: Boolean- If True, returns only node sessions for template nodes.
listProjects
- [None]
listProjectsWithResponses
- [None]
listResponsesForNanotask
nanotask_id: String
listResponsesForProject
project_name: String- Tutti project name.
listResponsesForTemplate
project_name: String- Tutti project name.
template_name: String- Tutti template name of a project.
listResponsesForWorkSession
work_session_id: String
listResponsesForWorker
worker_id: String- Tutti's internal hash ID for worker.
listTemplatePresets
project_name: String- Tutti project name.
listTemplates
project_name: String- Tutti project name.
listTemplatesWithResponses
project_name: String- Tutti project name.
listWorkSessionsWithResponses
project_name: String- Tutti project name.
listWorkersForProject
project_name: String- Tutti project name.
listWorkersWithResponses
project_name: String- Tutti project name.
rebuildProject
project_name: String- Tutti project name.
signIn
user_name: String, default null- User name of Tutti account.
password_hash: String, default null- MD5-hashed password (hex-digested) of Tutti account.
access_token: String, default null- Valid access token obtained in previous logins.
...args:- Accepts only
passwordkey (non-hashed password of Tutti account). This is not recommended; usepassword_hashoraccess_tokeninstead.
- Accepts only
signOut
- [None]
signUp
user_name: String- User name of Tutti account.
password:privilege_ids: Array- Priviledge IDs to associate with account. Currently not in use.
TuttiClient.mturk
addCredentials
access_key_id: String- Access Key ID of MTurk credentials.
secret_access_key: String- Secret Access Key of MTurk credentials.
label:
addHITsToTuttiHITBatch
batch_id: String- Tutti's internal hash ID for Tutti HIT Batch.
hit_params: Object- Parameters for CreateHIT operation of MTurk.
num_hits: Number- Number of HITs to create for Tutti HIT Batch.
approveAssignments
assignment_ids: Array- List of MTurk Assignment IDs.
requester_feedback:override_rejection:
associateQualificationsWithWorkers
qualification_type_id:worker_ids: Array- List of MTurk Worker IDs.
integer_value:send_notification:
createQualificationType
name:description:auto_granted:qualification_type_status:
createTuttiHITBatch
name:project_name: String- Tutti project name.
hit_type_params: Object- Parameters for CreateHITType operation of MTurk.
hit_params: Object- Parameters for CreateHIT operation of MTurk.
num_hits: Number- Number of HITs to create for Tutti HIT Batch.
deleteCredentials
credentials_id: String- Tutti's internal hash ID for registered MTurk credentials.
deleteHITs
request_id: String- Arbitrary string value to identify response for this request.
hit_ids: Array- List of MTurk HIT Ids.
deleteQualificationTypes
qualification_type_ids: Array- List of MTurk Qualification type IDs.
deleteTuttiHITBatch
request_id: String- Arbitrary string value to identify response for this request.
batch_id: String- Tutti's internal hash ID for Tutti HIT Batch.
execBoto3
method:parameters:
expireHITs
request_id: String- Arbitrary string value to identify response for this request.
hit_ids: Array- List of MTurk HIT Ids.
getActiveCredentials
- [None]
getCredentials
credentials_id: String- Tutti's internal hash ID for registered MTurk credentials.
listAssignmentsForTuttiHITBatch
batch_id: String- Tutti's internal hash ID for Tutti HIT Batch.
cached: Boolean- Whether to return cached value in the response. Note that setting this value to false may result in slower responses.
listCredentials
- [None]
listHITTypes
- [None]
listHITsForTuttiHITBatch
batch_id: String- Tutti's internal hash ID for Tutti HIT Batch.
cached: Boolean- Whether to return cached value in the response. Note that setting this value to false may result in slower responses.
listQualificationTypes
query:only_user_defined: Boolean- Whether to filter out Qualification types of other requesters in the results. This is directly passed to MustBeOwnedByCaller parameter for MTurk's ListQualificationTypes operation.
cached: Boolean- Whether to return cached value in the response. Note that setting this value to false may result in slower responses.
listTuttiHITBatches
- [None]
listTuttiHITBatchesWithHITs
- [None]
listWorkers
- [None]
notifyWorkers
subject:message_text:worker_ids: Array- List of MTurk Worker IDs.
rejectAssignments
assignment_ids: Array- List of MTurk Assignment IDs.
requester_feedback:
renameCredentials
credentials_id: String- Tutti's internal hash ID for registered MTurk credentials.
label:
sendBonus
worker_ids: Array- List of MTurk Worker IDs.
bonus_amount:assignment_ids: Array- List of MTurk Assignment IDs.
reason:
setActiveCredentials
credentials_id: String- Tutti's internal hash ID for registered MTurk credentials.
setActiveSandboxMode
is_sandbox: Boolean- Activation of Sandbox mode for MTurk credentials.
