-
Notifications
You must be signed in to change notification settings - Fork 4
/
notifications.clj
137 lines (119 loc) · 4.23 KB
/
notifications.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
(ns happygapi.storage.notifications
"Cloud Storage JSON API: notifications.
Stores and retrieves potentially large, immutable data objects.
See: https://developers.google.com/storage/docs/json_api/api/reference/rest/v1/notifications"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn delete$
"https://developers.google.com/storage/docs/json_api/api/reference/rest/v1/notifications/delete
Required parameters: bucket, notification
Optional parameters: userProject
Permanently deletes a notification subscription."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/devstorage.full_control"
"https://www.googleapis.com/auth/devstorage.read_write"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:notification :bucket})]}
(util/get-response
(http/delete
(util/get-url
"https://storage.googleapis.com/storage/v1/"
"b/{bucket}/notificationConfigs/{notification}"
#{:notification :bucket}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn get$
"https://developers.google.com/storage/docs/json_api/api/reference/rest/v1/notifications/get
Required parameters: bucket, notification
Optional parameters: userProject
View a notification configuration."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"
"https://www.googleapis.com/auth/devstorage.full_control"
"https://www.googleapis.com/auth/devstorage.read_only"
"https://www.googleapis.com/auth/devstorage.read_write"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:notification :bucket})]}
(util/get-response
(http/get
(util/get-url
"https://storage.googleapis.com/storage/v1/"
"b/{bucket}/notificationConfigs/{notification}"
#{:notification :bucket}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn insert$
"https://developers.google.com/storage/docs/json_api/api/reference/rest/v1/notifications/insert
Required parameters: bucket
Optional parameters: userProject
Body:
{:payload_format string,
:selfLink string,
:etag string,
:topic string,
:event_types [string],
:id string,
:kind string,
:custom_attributes {},
:object_name_prefix string}
Creates a notification subscription for a given bucket."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/devstorage.full_control"
"https://www.googleapis.com/auth/devstorage.read_write"]}
[auth parameters body]
{:pre [(util/has-keys? parameters #{:bucket})]}
(util/get-response
(http/post
(util/get-url
"https://storage.googleapis.com/storage/v1/"
"b/{bucket}/notificationConfigs"
#{:bucket}
parameters)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/storage/docs/json_api/api/reference/rest/v1/notifications/list
Required parameters: bucket
Optional parameters: userProject
Retrieves a list of notification subscriptions for a given bucket."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform.read-only"
"https://www.googleapis.com/auth/devstorage.full_control"
"https://www.googleapis.com/auth/devstorage.read_only"
"https://www.googleapis.com/auth/devstorage.read_write"]}
[auth parameters]
{:pre [(util/has-keys? parameters #{:bucket})]}
(util/get-response
(http/get
(util/get-url
"https://storage.googleapis.com/storage/v1/"
"b/{bucket}/notificationConfigs"
#{:bucket}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))