-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from osmlab/dev
dev > master
- Loading branch information
Showing
27 changed files
with
703 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import maproulette | ||
import json | ||
|
||
# Create a configuration object using a url and API key | ||
config = maproulette.Configuration(api_key='{YOUR_API_KEY}') | ||
|
||
# Create an API object using your config object | ||
api = maproulette.Project(config) | ||
|
||
# We can fetch a project using the name 'Health Facilities in India': | ||
my_project_name = 'Health Facilities in India' | ||
|
||
# Print the API response | ||
print(json.dumps(api.find_project(my_project_name), indent=4, sort_keys=True)) | ||
|
||
# We can also fetch a project using the project ID: | ||
my_project_id = '4719' | ||
|
||
# Print the API response | ||
print(json.dumps(api.get_project_by_id(my_project_id), indent=4, sort_keys=True)) | ||
|
||
# We can access the project's challenges as well: | ||
print(json.dumps(api.get_project_challenges(my_project_id), indent=4, sort_keys=True)) | ||
|
||
# If we want to create a new project, we can use the Project Model: | ||
my_project = maproulette.ProjectModel(name='my_new_project_name_20200120_abc') | ||
|
||
# You can set other parameters like your project description like this: | ||
my_project.description = 'my project description' | ||
|
||
# Print the API response | ||
print(json.dumps(api.create_project(my_project), indent=4, sort_keys=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import maproulette | ||
import json | ||
|
||
# Create a configuration object for MapRoulette using your API key: | ||
config = maproulette.Configuration(api_key="API_KEY") | ||
|
||
# Create an API object with the above config object: | ||
api = maproulette.Task(config) | ||
|
||
# To fetch a task, specify the task ID | ||
task_id = '42914448' | ||
|
||
# Printing response | ||
print(json.dumps(api.get_task_by_id(task_id), indent=4, sort_keys=True)) | ||
|
||
# You can access a task's history: | ||
print(json.dumps(api.get_task_history(task_id), indent=4, sort_keys=True)) | ||
|
||
# Or get a task's tags: | ||
print(json.dumps(api.get_task_tags(task_id), indent=4, sort_keys=True)) | ||
|
||
# You can also fetch tasks by specifying a list of tags: | ||
tags = 'tag1,tag2' | ||
print(json.dumps(api.get_tasks_by_tags(tags), indent=4, sort_keys=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import maproulette | ||
import json | ||
|
||
# Create a configuration object using a url and API key | ||
config = maproulette.Configuration(api_key='{YOUR_API_KEY}') | ||
|
||
# Create an API object using your config object | ||
api = maproulette.User(config) | ||
|
||
# We want to fetch a user with a particular name | ||
username = '{YOUR_USERNAME}' | ||
|
||
# Print the API response | ||
print(json.dumps(api.find_user_by_username(username), indent=4, sort_keys=True)) | ||
|
||
# To add a user to a project, specify the user ID | ||
user_id = '{SOME_USER_ID}' | ||
|
||
# Specify the project ID to update the privileges for | ||
project_id = '{YOUR_PROJECT_ID}' | ||
|
||
# Specify what level of access you want to grant this user (1 - Admin, 2 - Write, 3 - Read) | ||
group = '2' | ||
|
||
# Print the API response | ||
print(json.dumps(api.add_user_to_project(user_id=user_id, | ||
project_id=project_id, | ||
group_type=group), indent=4, sort_keys=True)) | ||
|
||
# We can also pass a list of user IDs to save time | ||
user_ids = [123, 456, 789] | ||
|
||
# Specify the project ID to update the privileges for | ||
project_id = '{YOUR_PROJECT_ID}' | ||
|
||
# Specify what level of access you want to grant this user (1 - Admin, 2 - Write, 3 - Read) | ||
group = '2' | ||
|
||
# Print the API response | ||
print(json.dumps(api.add_user_list_to_project(user_ids=user_ids, | ||
project_id=project_id, | ||
group_type=group), indent=4, sort_keys=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
from .api.task import Task | ||
from .api.user import User | ||
|
||
__version__ = '1.1.0' | ||
__version__ = '1.2.0' |
Oops, something went wrong.