Examples of executing queries with CURL

LOGIN

Query:

curl -c 'cookiefile.cookie' -X GET 'http://geomongo/instance/login/debug?_id=debug_user1'

Description: to login and get cookie to the file cookiefile.cookie.

Result: in the current user’s directory file with cookie (cookiefile.cookie) should appear.

All following commands will use obtained cookie file.


LOG

Query :

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service/testservice/log?number=10&offset=0&date_from=1983-01-22T08:00:00&date_to=2016-01-22T08:00:00'

 

Description: this command returns list of number of records from testservice[log] with shift offset and specified time span.

Result: 100 or less records from database specified after ‘service/’, collection ‘log’.

Example:

[{"date": {"$date": 1432821291832}, "message": "test", "_id": {"$oid": "55671e2b13293c504d515a35"}, "user_id": "stub", "service": "testservice"}, ...]

 


CHANNELS

The next commands should be executed sequentially.

Futher CHANNEL_ID is an identifier of channel obtained after execution the first command in this section.

Query:

curl -b 'cookiefile.cookie' -H "Content-Type: application/json" -X POST -d '{"name":"test_name","json":"{1: 2, 2: 4}"}' 'http://geomongo/instance/service/testservice/channel'

 

Description: a command for creation channel with specified parameters name and json (parameters are obligatory).

Result: identifier of created channel ObjectId or null – if the channel with the same identifier already exists

Example:

{"$oid": "CHANNEL_ID"}

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service/testservice/channel?number=10&offset=0'

Description: search number of channels with shift offset, name of which contains substring (all parameters are optional).

Result: list of channel of base specified after ‘service/’, collection ‘channels’ or en empty list []

Example:

[{"owner_group": "STUB", "name": "test_name", "acl": 777, "json": "{1: 2, 2: 4}", "_id": {"$oid": "55d159027efcd636178b9f21"}, "owner_id": "STUB"}, ...]

Query:

curl -b 'cookiefile.cookie' -X PUT -d 'name=new_test_channel' 'http://geomongo/instance/service/testservice/channel/CHANNEL_ID'

Description: the command edits a record in the base or notifies that there isn’t such channel.

Result: the empty quotes {} or ‘Channel does not exist’.

Query:

 curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service/testservice/channel/CHANNEL_ID'

 

Description: search channel by its id.

Result: a record of base specified after ‘service/’ with identifier CHANNEL_ID , collection ‘channels’ or notification that there isn’t such channel.

Example:

{"owner_group": "STUB", "name": "test_name", "acl": 777, "json": "{1: 2, 2: 4}", "_id": {"$oid": "55d159027efcd636178b9f21"}, "owner_id": "STUB"}

or

‘Channel does not exist’

Query:

 curl -b 'cookiefile.cookie' -X DELETE 'http://geomongo/instance/service/testservice/channel/CHANNE_ID'

Description: deleting channel from base specified after ‘service/’ with identifier CHANNEL_ID , collection ‘channels’ or notification that there isn’t such channel.

Result: the empty quotes {} or ‘Channel does not exist’.


 POINTS

The next commands should be executed sequentially.

Further POINT_ID is a point identifier obtained after execution the first command of this section.

Query:

curl -b 'cookiefile.cookie' -H "Content-Type: application/json" -X POST -d '[{"lat":1.1,"lon":1.1,"alt":1.1,"json":{"a":"b"},"channel_id":"CHANNEL_ID"}]' 'http://geomongo/instance/service/testservice/point'

Description: creation a point with specified parameters lon, lat, alt, json, channel_id which sent in separate json and are mandatory.

Result: identifier of created record in database specified after ‘service/’, collection ‘points‘.

Example:

[”POINT_I”]

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service/testservice/point?number=10&channel_ids=CHANNEL_ID'

Description: returns list of points corresponding the search query

Query:

curl -b 'cookiefile.cookie' -X PUT -d 'alt=5' 'http://geomongo/instance/service/testservice/point/POINT_ID'

Description: editing information about a point with specified id.

Result: the command edits a record of database and return {} or Point does not exist

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service/testservice/point/POINT_ID'

Description: search point by specified id.

Result: record of database (service) specified after ‘service/’ or notification that there isn’t such point.

Example:

{"channel_id": null, "json": null, "location": {"type": "Point", "coordinates": [1.1, 1.1]}, "date": {"$date": 1439825024437}, "alt": 5.0, "_id": {"$oid": "55d1d2507efcd65a7de01205"}}

or

‘Point does not exist’

Query:

curl -b 'cookiefile.cookie' -X DELETE 'http://geomongo/instance/service/testservice/point/POINT_ID'

Description: deleting point by specified id.

Result: command  deletes a point from database and returns {} or Point does not exist.


 SERVICES

The next commands should be executed sequentially.

Further SERVICE_NAME is a name of service which chosen in execution the first command of this section.

Query:

curl -b 'cookiefile.cookie' -X POST -d 'name=SERVICE_NAME&ownerId=new_test_ownerId&logSize=10'http://geomongo/instance/service

Description: creation service with parameters name (mandatory), logSize and ownerId (optional).

Result: identifier of created service ObjectId or Service already exist

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service?number=0&offset=0'

Description: gets number of services with shift offset.

Result: list of services.

Example:

[{"_id": {"$oid": "55671ae113293c504d515a33"}, "config": {"log_size": 1048576, "logSize": 10}, "name": "testservice", "owner_id": ""}, ...]

Query:

curl -b 'cookiefile.cookie' -X PUT -d 'logSize=15' 'http://geomongo/instance/service/SERVICE_NAME'

Description: editing parameters of service with specified name.

Result: {“SERVICE_NAME”: “Service updated”}

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/service/SERVICE_NAME'

Description: search service by specified name.

Result: record from database ‘geomongo’ collection ‘services’.

Example:

{"_id": {"$oid": "55d1d7507efcd65a7de01214"}, "config": {"log_size": 10, "logSize": 15}, "name": "new_test_service", "owner_id": "new_test_ownerId"}

 

Query:

curl -b 'cookiefile.cookie' -X DELETE 'http://geomongo/instance/service/SERVICE_NAME'

 

Description: deleting service by specified service’s name.

Result: {“SERVICE_NAME”: “Service removed”}


PLUGINS

Further PLUGIN_NAME is a name of plugin, names can be obtained by first command of this section.

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/plugin'

Description: getting list of plugins.

Result: JSON – list of all plugins.

Example:

{"test_plugin_for_fail": false, "test_plugin_for_load_fail_gt_1435": false, "test_plugin": true, "ok_import": true, "testPlugin1": false, "testPlugin2": true}

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/manage_plugins?PLUGIN_NAME=True'

Description:  manage status of plugin by specified name of plugin.

Result: command edits status of plugin and returns null.


LOGOUT

Query:

curl -b 'cookiefile.cookie' -X GET 'http://geomongo/instance/logout'

Description: a command for user logout.

Results: command deletes user from session.

ShareShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VKEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *