-
Notifications
You must be signed in to change notification settings - Fork 4
/
query.clj
141 lines (123 loc) · 4.82 KB
/
query.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
(ns happygapi.cloudsearch.query
"Cloud Search API: query.
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/query"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn suggest$
"https://developers.google.com/cloud-search/docs/guides/api/reference/rest/v1/query/suggest
Required parameters: none
Optional parameters: none
Body:
{:requestOptions {:debugOptions DebugOptions,
:searchApplicationId string,
:languageCode string,
:timeZone string},
:query string,
:dataSourceRestrictions [{:filterOptions [FilterOptions],
:source Source}]}
Provides suggestions for autocompleting the query.
**Note:** This API requires a standard end user account to execute.
A service account can't perform Query API requests directly; to use a
service account to perform queries, set up [G Suite domain-wide delegation
of
authority](https://developers.google.com/cloud-search/docs/guides/delegation/)."
{:scopes ["https://www.googleapis.com/auth/cloud_search"
"https://www.googleapis.com/auth/cloud_search.query"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://cloudsearch.googleapis.com/"
"v1/query/suggest"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn search$
"https://developers.google.com/cloud-search/docs/guides/api/reference/rest/v1/query/search
Required parameters: none
Optional parameters: none
Body:
{:queryInterpretationOptions {:disableNlInterpretation boolean,
:enableVerbatimMode boolean},
:requestOptions {:debugOptions DebugOptions,
:searchApplicationId string,
:languageCode string,
:timeZone string},
:dataSourceRestrictions [{:filterOptions [FilterOptions],
:source Source}],
:facetOptions [{:sourceName string,
:numFacetBuckets integer,
:operatorName string,
:objectType string}],
:sortOptions {:operatorName string, :sortOrder string},
:pageSize integer,
:query string,
:start integer}
The Cloud Search Query API provides the search method, which returns
the most relevant results from a user query. The results can come from
G Suite Apps, such as Gmail or Google Drive, or they can come from data
that you have indexed from a third party.
**Note:** This API requires a standard end user account to execute.
A service account can't perform Query API requests directly; to use a
service account to perform queries, set up [G Suite domain-wide delegation
of
authority](https://developers.google.com/cloud-search/docs/guides/delegation/)."
{:scopes ["https://www.googleapis.com/auth/cloud_search"
"https://www.googleapis.com/auth/cloud_search.query"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://cloudsearch.googleapis.com/"
"v1/query/search"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn sources-list$
"https://developers.google.com/cloud-search/docs/guides/api/reference/rest/v1/query/sources/list
Required parameters: none
Optional parameters: requestOptions.searchApplicationId, requestOptions.timeZone, pageToken, requestOptions.debugOptions.enableDebugging, requestOptions.languageCode
Returns list of sources that user can use for Search and Suggest APIs.
**Note:** This API requires a standard end user account to execute.
A service account can't perform Query API requests directly; to use a
service account to perform queries, set up [G Suite domain-wide delegation
of
authority](https://developers.google.com/cloud-search/docs/guides/delegation/)."
{:scopes ["https://www.googleapis.com/auth/cloud_search"
"https://www.googleapis.com/auth/cloud_search.query"]}
[auth args]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/get
(util/get-url
"https://cloudsearch.googleapis.com/"
"v1/query/sources"
#{}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))