Skip to content

Commit 22906a3

Browse files
authored
Refactor API module and add server health check (#25)
* Refactored API module to be separate modules * Added new health check method * Small changes to session * Made health check private * Updated getting started docs
1 parent eca6a5f commit 22906a3

26 files changed

Lines changed: 438 additions & 323 deletions

docs/usage/functionality.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
Functionality
22
=====================================================
33

4-
Module: api
4+
Module: project
55
-----------------------------------------------------
66

7-
.. automodule:: maproulette.api.api
7+
.. automodule:: maproulette.api.project
88
:members:
9+
:show-inheritance:
10+
11+
Module: challenge
12+
-----------------------------------------------------
13+
14+
.. automodule:: maproulette.api.challenge
15+
:members:
16+
:show-inheritance:
17+
18+
Module: task
19+
-----------------------------------------------------
20+
21+
.. automodule:: maproulette.api.task
22+
:members:
23+
:show-inheritance:
924

1025
Module: configuration
1126
-----------------------------------------------------
1227

1328
.. automodule:: maproulette.api.configuration
1429
:members:
30+
:show-inheritance:

docs/usage/getting_started.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ that when you create your configuration. For example:
2222
config = maproulette.Configuration(api_key='{YOUR_API_KEY}')
2323
2424
25-
Once you have your configuration object, we can create our API object. This gives us access to all of the functionality
26-
in the MapRoulette package.
25+
Once you have your configuration object we can create an API object using one of several modules depending on the
26+
functionality that the user is looking for. For example, creating a Project object allows the user to interact with all
27+
of the project-related functionality in the MapRoulette package.
2728

2829
.. code-block:: python
2930
30-
api = maproulette.Api(config)
31+
api = maproulette.Project(config)
3132
3233
33-
Now we have access to the MapRoulette API methods. In the example below, I want to find a project by name using a search
34-
string:
34+
Now we have access to the MapRoulette Project API methods. In the example below, I want to find a project by name using
35+
a search string:
3536

3637
.. code-block:: python
3738

examples/add_tasks_to_challenge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config = maproulette.Configuration(api_key="API_KEY")
66

77
# Create an API objects with the above config object:
8-
api = maproulette.Api(config)
8+
api = maproulette.Challenge(config)
99

1010
# Specify the ID of the challenge you want to add tasks to:
1111
challenge_id = 'TEST_ID'

examples/create_challenge_from_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config = maproulette.Configuration(api_key="API_KEY")
66

77
# Create an API objects with the above config object:
8-
api = maproulette.Api(config)
8+
api = maproulette.Challenge(config)
99

1010
# Creating a test challenge model with name and child task
1111
challenge_data = maproulette.ChallengeModel(name='Test_Challenge_Name')

examples/create_project_from_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
configuration = maproulette.Configuration(api_key='{YOUR_API_KEY}')
66

77
# Create an API object using your config object
8-
api = maproulette.Api(configuration)
8+
api = maproulette.Project(configuration)
99

1010
# Initialize a project model using the project name
1111
my_project = maproulette.ProjectModel(name='my_new_project_name_20200120_abc')

examples/find_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config = maproulette.Configuration(api_key='{YOUR_API_KEY}')
66

77
# Create an API object using your config object
8-
api = maproulette.Api(config)
8+
api = maproulette.Project(config)
99

1010
# We want to fetch a project with name 'Health Facilities in India'
1111
my_project_name = 'Health Facilities in India'

examples/get_challenge_by_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config = maproulette.Configuration(api_key="API_KEY")
66

77
# Create an API objects with the above config object:
8-
api = maproulette.Api(config)
8+
api = maproulette.Challenge(config)
99

1010
# Specify the ID of the challenge you want up add tasks to:
1111
challenge_id = '12974'

examples/get_challenge_statistics_by_id.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
config = maproulette.Configuration(api_key="API_KEY")
66

77
# Create an API objects with the above config object:
8-
api = maproulette.Api(config)
8+
api = maproulette.Challenge(config)
99

1010
# Specify the ID of the challenge you want up add tasks to:
1111
challenge_id = 'TEST_ID'
1212

1313
# Printing response
14-
print(json.dumps(api.get_challenge_metadata_by_id(challenge_id)))
14+
print(json.dumps(api.get_challenge_statistics_by_id(challenge_id)))

examples/get_challenge_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config = maproulette.Configuration(api_key="API_KEY")
66

77
# Create an API objects with the above config object:
8-
api = maproulette.Api(config)
8+
api = maproulette.Challenge(config)
99

1010
# Specify the ID of the challenge you want up add tasks to:
1111
challenge_id = '12978'

examples/get_project_by_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config = maproulette.Configuration(api_key='{YOUR_API_KEY}')
66

77
# Create an API object using your config object
8-
api = maproulette.Api(config)
8+
api = maproulette.Project(config)
99

1010
# We want to fetch a project with ID '4719'
1111
my_project_id = '4719'

0 commit comments

Comments
 (0)