-
Notifications
You must be signed in to change notification settings - Fork 4
/
tabledata.clj
73 lines (64 loc) · 2.44 KB
/
tabledata.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
(ns happygapi.bigquery.tabledata
"BigQuery API: tabledata.
A data platform for customers to create, manage, share and query data.
See: https://cloud.google.com/bigquery/api/reference/rest/v2/tabledata"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn insertAll$
"https://cloud.google.com/bigquery/api/reference/rest/v2/tabledata/insertAll
Required parameters: tableId, projectId, datasetId
Optional parameters: none
Body:
{:ignoreUnknownValues boolean,
:skipInvalidRows boolean,
:rows [{:insertId string, :json {}}],
:kind string,
:templateSuffix string}
Streams data into BigQuery one record at a time without needing to run a load job. Requires the WRITER dataset role."
{:scopes ["https://www.googleapis.com/auth/bigquery"
"https://www.googleapis.com/auth/bigquery.insertdata"
"https://www.googleapis.com/auth/cloud-platform"]}
[auth args body]
{:pre [(util/has-keys? args #{:tableId :datasetId :projectId})]}
(util/get-response
(http/post
(util/get-url
"https://bigquery.googleapis.com/bigquery/v2/"
"projects/{projectId}/datasets/{datasetId}/tables/{tableId}/insertAll"
#{:tableId :datasetId :projectId}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn list$
"https://cloud.google.com/bigquery/api/reference/rest/v2/tabledata/list
Required parameters: datasetId, projectId, tableId
Optional parameters: maxResults, selectedFields, startIndex, pageToken
Retrieves table data from a specified set of rows. Requires the READER dataset role."
{:scopes ["https://www.googleapis.com/auth/bigquery"
"https://www.googleapis.com/auth/bigquery.readonly"
"https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"]}
[auth args]
{:pre [(util/has-keys? args #{:tableId :datasetId :projectId})]}
(util/get-response
(http/get
(util/get-url
"https://bigquery.googleapis.com/bigquery/v2/"
"projects/{projectId}/datasets/{datasetId}/tables/{tableId}/data"
#{:tableId :datasetId :projectId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))