-
Notifications
You must be signed in to change notification settings - Fork 4
/
media.clj
61 lines (50 loc) · 2.15 KB
/
media.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
(ns happygapi.cloudsearch.media
"Cloud Search API: media.
Cloud Search provides cloud-based search capabilities over G Suite data. The Cloud Search API allows indexing of non-G Suite data into Cloud Search.
See: https://developers.google.com/cloud-search/docs/guides/api/reference/rest/v1/media"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn upload$
"https://developers.google.com/cloud-search/docs/guides/api/reference/rest/v1/media/upload
Required parameters: resourceName
Optional parameters: none
Body:
{:resourceName string}
Uploads media for indexing.
The upload endpoint supports direct and resumable upload protocols and
is intended for large items that can not be
[inlined during index requests](https://developers.google.com/cloud-search/docs/reference/rest/v1/indexing.datasources.items#itemcontent).
To index large content:
1. Call
indexing.datasources.items.upload
with the resource name to begin an upload session and retrieve the
UploadItemRef.
1. Call media.upload to upload the content using the same resource name from step 1.
1. Call indexing.datasources.items.index
to index the item. Populate the
[ItemContent](/cloud-search/docs/reference/rest/v1/indexing.datasources.items#ItemContent)
with the UploadItemRef from step 1.
For additional information, see
[Create a content connector using the REST API](https://developers.google.com/cloud-search/docs/guides/content-connector#rest).
**Note:** This API requires a service account to execute."
{:scopes ["https://www.googleapis.com/auth/cloud_search"
"https://www.googleapis.com/auth/cloud_search.indexing"]}
[auth args body]
{:pre [(util/has-keys? args #{:resourceName})]}
(util/get-response
(http/post
(util/get-url
"https://cloudsearch.googleapis.com/"
"v1/media/{+resourceName}"
#{:resourceName}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))