Skip to content

Commit

Permalink
add project api
Browse files Browse the repository at this point in the history
  • Loading branch information
n00rsy committed Sep 12, 2023
1 parent ceecf75 commit 6406601
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 33 deletions.
4 changes: 4 additions & 0 deletions pybossa/api/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def options(self, **kwargs): # pragma: no cover
@jsonpify
@ratelimit(limit=ratelimits.get('LIMIT'), per=ratelimits.get('PER'))
@swag_from('docs/task/task_get.yaml', endpoint='api.api_task_oid')
@swag_from('docs/project/project_get.yaml', endpoint='api.api_project_oid')
def get(self, oid):
"""Get an object.
Expand Down Expand Up @@ -317,6 +318,7 @@ def _set_limit_and_offset(self):
@jsonpify
@ratelimit(limit=ratelimits.get('LIMIT'), per=ratelimits.get('PER'))
@swag_from('docs/task/task_post.yaml', endpoint='api.api_task')
@swag_from('docs/project/project_post.yaml', endpoint='api.api_project')
def post(self):
"""Post an item to the DB with the request.data JSON object.
Expand Down Expand Up @@ -387,6 +389,7 @@ def _create_instance_from_request(self, data):
@jsonpify
@ratelimit(limit=ratelimits.get('LIMIT'), per=ratelimits.get('PER'))
@swag_from('docs/task/task_delete.yaml', endpoint='api.api_task_oid')
@swag_from('docs/project/project_delete.yaml', endpoint='api.api_project_oid')
def delete(self, oid):
"""Delete a single item from the DB.
Expand Down Expand Up @@ -425,6 +428,7 @@ def _delete_instance(self, oid):

@jsonpify
@ratelimit(limit=ratelimits.get('LIMIT'), per=ratelimits.get('PER'))
@swag_from('docs/project/project_put.yaml', endpoint='api.api_project_oid')
def put(self, oid):
"""Update a single item in the DB.
Expand Down
16 changes: 16 additions & 0 deletions pybossa/api/docs/project/project_delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Delete a project by project id
---
tags:
- name: project
parameters:
- name: oid
in: path
type: number
required: true
description: the project id
responses:
204:
description: successfully deleted project



131 changes: 131 additions & 0 deletions pybossa/api/docs/project/project_get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
Get project information by project id
---
tags:
- name: project
definitions:
Project:
type: object
properties:
id:
type: integer
created:
type: string
updated:
type: string
name:
type: string
short_name:
type: string
description:
type: string
long_description:
type: string
webhook:
type: null
allow_anonymous_contributors:
type: boolean
published:
type: boolean
hidden:
type: boolean
featured:
type: boolean
secret_key:
type: string
zip_download:
type: boolean
contacted:
type: boolean
owner_id:
type: integer
category_id:
type: integer
info:
type: object
properties:
kpi:
type: integer
sync:
type: object
properties:
enabled:
type: boolean
sched:
type: string
product:
type: string
timeout:
type: integer
subproduct:
type: string
data_access:
type: array
items:
type: string
passwd_hash:
type: string
reserve_tasks:
type: object
properties:
category:
type: array
items:
type: string
task_presenter:
type: string
task_guidelines:
type: string
tasklist_columns:
type: array
items:
type: string
default_n_answers:
type: integer
progress_reminder:
type: object
properties:
sent:
type: boolean
webhook:
type: null
target_remaining:
type: null
allow_taskrun_edit:
type: boolean
data_classification:
type: object
properties:
input_data:
type: string
output_data:
type: string
sched_rand_within_priority:
type: boolean
sched_gold_task_probability:
type: number
allow_anonymous_contributors:
type: boolean
email_notif:
type: boolean
owners_ids:
type: array
items:
type: integer
links:
type: array
items:
type: string
link:
type: string
parameters:
- name: oid
in: path
type: number
required: true
description: the project id
responses:
200:
description: project info
schema:
$ref: '#definitions/Project'

108 changes: 108 additions & 0 deletions pybossa/api/docs/project/project_post.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
Create project with json data payload
---
tags:
- name: project
parameters:
- name: project
required: true
description: the project to create
in: body
schema:
type: object
required:
- project_id
info
properties:
type: object
properties:
name:
type: string
short_name:
type: string
description:
type: string
password:
type: string
info:
type: object
properties:
subproduct:
type: string
product:
type: string
kpi:
type: integer
data_classification:
type: object
properties:
input_data:
type: string
output_data:
type: string
responses:
200:
description: created project info
schema:
$ref: '#definitions/Project'
examples:
{
"id": 13,
"created": "2023-06-14T19:54:34.839245",
"updated": "2023-09-12T16:33:28.384714",
"name": "user pref test 2",
"short_name": "userpreftest2",
"description": "user pref test",
"long_description": "user pref test",
"webhook": null,
"allow_anonymous_contributors": true,
"published": true,
"hidden": false,
"featured": false,
"secret_key": "c57cca94-29d7-471c-8eee-4bcbbc7a9cb5",
"zip_download": true,
"contacted": false,
"owner_id": 1,
"category_id": 1,
"info": {
"kpi": 3,
"sync": {
"enabled": false
},
"sched": "user_pref_scheduler",
"product": "Companies",
"timeout": 3600,
"subproduct": "Entity Management",
"data_access": [
"L4"
],
"passwd_hash": "pbkdf2:sha256:260000$6TmmSmlNFEjKRZrT$85ea2bb992c8baf68933616c4de78d021d45f817acf92dae899e74c852006a9d",
"reserve_tasks": {
"category": []
},
"task_presenter": "<div id=\"task-app\"><\\div>",
"task_guidelines": "<p>do the task.</p>",
"tasklist_columns": [],
"default_n_answers": 1,
"progress_reminder": {
"sent": false,
"webhook": null,
"target_remaining": null
},
"allow_taskrun_edit": false,
"data_classification": {
"input_data": "L4 - Public Third-Party Data",
"output_data": "L4 - Public Third-Party Data"
},
"sched_rand_within_priority": false,
"sched_gold_task_probability": 0.1,
"allow_anonymous_contributors": false
},
"email_notif": false,
"owners_ids": [
1
],
"links": [
"<link rel='category' title='category' href='http://localhost:5000/api/category?oid=1'/>"
],
"link": "<link rel='self' title='project' href='http://localhost:5000/api/project?oid=13'/>"
}
36 changes: 36 additions & 0 deletions pybossa/api/docs/project/project_put.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Update a project by project id
---
tags:
- name: project
parameters:
- name: oid
in: path
type: number
required: true
description: the project id
- name: project_info
in: body
type: ojbect
properties:
name:
type: string
short_name:
type: string
description:
type: string
long_description:
type: string
published:
type: boolean
task_presenter:
type: string
required: true
description: the new project info

responses:
200:
description: new project info
schema:
$ref: '#definitions/Project'


37 changes: 5 additions & 32 deletions pybossa/api/docs/task/task_delete.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
Delete a task
---
tags:
- name: task
parameters:
- name: oid
in: path
type: number
required: true
description: the task id
responses:
200:
description: deleted task info
schema:
$ref: '#definitions/Task'
examples:
{
"info": {
"company": "Bloomberg",
"task": "2",
"set_id": "2"
},
"fav_user_ids": null,
"user_pref": {
},
"n_answers": 1,
"quorum": 0,
"links": [
"<link rel='parent' title='project' href='https://qa.gigwork.net/api/project/2454'/>"
],
"calibration": 0,
"expiration": null,
"created": "2021-04-30T21:56:30.632483",
"worker_filter": null,
"state": "completed",
"gold_answers": null,
"link": "<link rel='self' title='task' href='https://qa.gigwork.net/api/task/7225337'/>",
"exported": true,
"project_id": 2454,
"worker_pref": null,
"id": 7225337,
"priority_0": 0.99
}
204:
description: successfully deleted task

2 changes: 2 additions & 0 deletions pybossa/api/docs/task/task_get.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Get task information by task id
---
tags:
- name: task
definitions:
Task:
type: object
Expand Down
5 changes: 4 additions & 1 deletion pybossa/api/docs/task/task_post.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Create task via POST with json data payload
Create task with json data payload
---
tags:
- name: task
parameters:
- name: task
required: true
description: the task to create
in: body
schema:
type: object
required:
Expand Down
Loading

0 comments on commit 6406601

Please sign in to comment.