kairos-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +62 -0
  9. data/Rakefile +1 -0
  10. data/kairos.gemspec +33 -0
  11. data/lib/kairos.rb +10 -0
  12. data/lib/kairos/client.rb +114 -0
  13. data/lib/kairos/configuration.rb +43 -0
  14. data/lib/kairos/version.rb +3 -0
  15. data/spec/kairos/client_spec.rb +65 -0
  16. data/spec/kairos/configuration_spec.rb +28 -0
  17. data/spec/kairos/detect_spec.rb +51 -0
  18. data/spec/kairos/enroll_spec.rb +68 -0
  19. data/spec/kairos/gallery_list_all_spec.rb +32 -0
  20. data/spec/kairos/gallery_remove_subject_spec.rb +50 -0
  21. data/spec/kairos/gallery_view_spec.rb +32 -0
  22. data/spec/kairos/recognize_spec.rb +97 -0
  23. data/spec/kairos/version_spec.rb +7 -0
  24. data/spec/spec_helper.rb +14 -0
  25. data/spec/vcr/detect.yml +124 -0
  26. data/spec/vcr/detect_with_missing_parameters.yml +42 -0
  27. data/spec/vcr/detect_with_no_faces_in_image.yml +42 -0
  28. data/spec/vcr/enroll.yml +44 -0
  29. data/spec/vcr/enroll_with_invalid_image_url.yml +44 -0
  30. data/spec/vcr/enroll_with_missing_parameters.yml +43 -0
  31. data/spec/vcr/gallery_list_all.yml +39 -0
  32. data/spec/vcr/gallery_remove_subject.yml +43 -0
  33. data/spec/vcr/gallery_remove_subject_with_missing_parameters.yml +43 -0
  34. data/spec/vcr/gallery_remove_subject_with_unmatched_subject.yml +43 -0
  35. data/spec/vcr/gallery_view.yml +43 -0
  36. data/spec/vcr/recognize.yml +47 -0
  37. data/spec/vcr/recognize_with_invalid_image_url.yml +44 -0
  38. data/spec/vcr/recognize_with_missing_parameters.yml +44 -0
  39. data/spec/vcr/recognize_with_unrecognizable_image.yml +44 -0
  40. data/spec/vcr/recognize_with_url_and_gallery_name.yml +50 -0
  41. metadata +263 -0
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/detect
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"http://upload.wikimedia.org/wikipedia/commons/thumb/2/23/Seal_of_the_US_Air_Force.svg/356px-Seal_of_the_US_Air_Force.svg.png","selector":"FULL"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 15:56:44 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '54'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: '["errors:"{"Errcode":5002,"Message":No face(s) found}]'
40
+ http_version:
41
+ recorded_at: Sat, 19 Jul 2014 15:56:35 GMT
42
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/enroll
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://some.image.url/123abc.jpg","subject_id":"image123abc","gallery_name":"randomgallery"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 03:10:11 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '218'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"images\": [\n\t\t{\n\t\t\t\"time\": 2.02606,\n\t\t\t\"transaction\":
40
+ {\n\t\t\t\t\"status\": \"Complete\",\n\t\t\t\t\"face_id\": \"7d3a0571cb8c59d5be3fee2c19fff4a3\",\n\t\t\t\t\"subject_id\":
41
+ \"image123abc\",\n\t\t\t\t\"gallery_name\": \"randomgallery\"\n\t\t\t}\n\t\t}\n\t]\n}"
42
+ http_version:
43
+ recorded_at: Sat, 19 Jul 2014 03:10:02 GMT
44
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/enroll
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://some.image.url/123abc.jpg","subject_id":"image123abc","gallery_name":"randomgallery"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 03:24:18 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '178'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\t\t\t\t\t\t \"images\": [\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t
40
+ \ \"status\": \"failure\",\n\t\t\t\t\t\t\t \"message\":
41
+ \"no face(s) found in image\"\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t}"
42
+ http_version:
43
+ recorded_at: Sat, 19 Jul 2014 03:24:09 GMT
44
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/enroll
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://some.image.url/123abc.jpg","subject_id":"image123abc"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 03:24:01 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '129'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"Errors\": [\n\t\t{\n\t\t\t\"ErrorCode\": 5006,\n\t\t\t\"Message\":
40
+ \"the following required parameter is not included: gallery_name\"\n\t\t}\n\t]\n}"
41
+ http_version:
42
+ recorded_at: Sat, 19 Jul 2014 03:23:52 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/gallery/list_all
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Typhoeus - https://github.com/typhoeus/typhoeus
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - ngx_openresty/1.2.8.6
25
+ Date:
26
+ - Sun, 20 Jul 2014 03:33:23 GMT
27
+ Content-Type:
28
+ - text/html; charset=UTF-8
29
+ Content-Length:
30
+ - '81'
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: "{\n\t\"time\": 0.00808,\n\t\"status\": \"Complete\",\n\t\"gallery_ids\":
36
+ [\n\t\t\"testgallery\"\n\t]\n}"
37
+ http_version:
38
+ recorded_at: Sun, 20 Jul 2014 03:33:12 GMT
39
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/gallery/remove_subject
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gallery_name":"randomgallery","subject_id":"image123abc"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 06:41:17 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '92'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"status\": \"complete\",\n\t\"message\": \"subject id image123abc
40
+ has been successfully removed }"
41
+ http_version:
42
+ recorded_at: Sat, 19 Jul 2014 06:41:08 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/gallery/remove_subject
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gallery_name":"gemtest"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 06:36:07 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '127'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"Errors\": [\n\t\t{\n\t\t\t\"ErrorCode\": 5006,\n\t\t\t\"Message\":
40
+ \"the following required parameter is not included: subject_id\"\n\t\t}\n\t]\n}"
41
+ http_version:
42
+ recorded_at: Sat, 19 Jul 2014 06:35:58 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/gallery/remove_subject
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gallery_name":"gemtest","subject_id":"abcdefghi"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 06:37:47 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '90'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"status\": \"complete\",\n\t\"message\": \"subject id abcdefghi
40
+ has been successfully removed }"
41
+ http_version:
42
+ recorded_at: Sat, 19 Jul 2014 06:37:38 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/gallery/view
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"gallery_name":"testgallery"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 20:29:47 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '142'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"time\": 0.00287,\n\t\"status\": \"Complete\",\n\t\"subject_ids\":
40
+ [\n\t\t\"gemtest\",\n\t\t\"gemtest\",\n\t\t\"gemtest\",\n\t\t\"gemtest\",\n\t\t\"gemtest\",\n\t\t\"gemtest\"\n\t]\n}"
41
+ http_version:
42
+ recorded_at: Sat, 19 Jul 2014 20:29:37 GMT
43
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/recognize
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://some.image.url/123abc.jpg","gallery_name":"randomgallery","threshold":".2","max_num_results":"5"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 04:45:39 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '444'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\"images\": [\n\t\t{\n\t\t\t\"time\": 2.02489,\n\t\t\t\"transaction\":
40
+ {\n\t\t\t\t\"status\": \"success\",\n\t\t\t\t\"face_id\": \"cc9424ff049026675b9f1ecccec2c076\",\n\t\t\t\t\"subject\":
41
+ \"image123abc\",\n\t\t\t\t\"confidence\": 1,\n\t\t\t\t\"gallery_name\": \"randomgallery\"\n\t\t\t},\n\t\t\t\"candidates\":
42
+ [\n\t\t\t\t{\n\t\t\t\t\t\"image456abc\": \"1\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"image789abc\":
43
+ \"2\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"image012abc\": \"3\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"image345abc\":
44
+ \"4\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"image678abc\": \"5\"\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n}"
45
+ http_version:
46
+ recorded_at: Sat, 19 Jul 2014 04:45:30 GMT
47
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.kairos.io/recognize
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"url":"https://some.image.url/123abc.jpg","gallery_name":"randomgallery"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.9
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ App-Id:
15
+ - abc1234
16
+ App-Key:
17
+ - asdfadsfasdfasdfasdf
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Server:
28
+ - ngx_openresty/1.2.8.6
29
+ Date:
30
+ - Sat, 19 Jul 2014 04:19:40 GMT
31
+ Content-Type:
32
+ - text/html; charset=UTF-8
33
+ Content-Length:
34
+ - '178'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: "{\n\t\t\t\t\t\t\t \"images\": [\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t
40
+ \ \"status\": \"failure\",\n\t\t\t\t\t\t\t \"message\":
41
+ \"no face(s) found in image\"\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t}"
42
+ http_version:
43
+ recorded_at: Sat, 19 Jul 2014 04:19:31 GMT
44
+ recorded_with: VCR 2.9.2