-
Notifications
You must be signed in to change notification settings - Fork 4
/
files.clj
92 lines (79 loc) · 2.91 KB
/
files.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
(ns happygapi.vision.files
"Cloud Vision API: files.
Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.
See: https://cloud.google.com/vision/api/reference/rest/v1/files"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn asyncBatchAnnotate$
"https://cloud.google.com/vision/api/reference/rest/v1/files/asyncBatchAnnotate
Required parameters: none
Optional parameters: none
Body:
{:requests [{:inputConfig InputConfig,
:features [Feature],
:imageContext ImageContext,
:outputConfig OutputConfig}],
:parent string}
Run asynchronous image detection and annotation for a list of generic
files, such as PDF files, which may contain multiple pages and multiple
images per page. Progress and results can be retrieved through the
`google.longrunning.Operations` interface.
`Operation.metadata` contains `OperationMetadata` (metadata).
`Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results)."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-vision"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://vision.googleapis.com/"
"v1/files:asyncBatchAnnotate"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn annotate$
"https://cloud.google.com/vision/api/reference/rest/v1/files/annotate
Required parameters: none
Optional parameters: none
Body:
{:parent string,
:requests [{:imageContext ImageContext,
:pages [integer],
:inputConfig InputConfig,
:features [Feature]}]}
Service that performs image detection and annotation for a batch of files.
Now only \"application/pdf\", \"image/tiff\" and \"image/gif\" are supported.
This service will extract at most 5 (customers can specify which 5 in
AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
file provided and perform detection and annotation for each image
extracted."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-vision"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://vision.googleapis.com/"
"v1/files:annotate"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))