-
Notifications
You must be signed in to change notification settings - Fork 4
/
shelves.clj
166 lines (148 loc) · 4.45 KB
/
shelves.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
(ns happygapi.libraryagent.shelves
"Library Agent API: shelves.
A simple Google Example Library API.
See: https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn get$
"https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves/get
Required parameters: name
Optional parameters: none
Gets a shelf. Returns NOT_FOUND if the shelf does not exist."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://libraryagent.googleapis.com/"
"v1/{+name}"
#{:name}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn list$
"https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves/list
Required parameters: none
Optional parameters: pageToken, pageSize
Lists shelves. The order is unspecified but deterministic. Newly created
shelves will not necessarily be added to the end of this list."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/get
(util/get-url
"https://libraryagent.googleapis.com/"
"v1/shelves"
#{}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn books-borrow$
"https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves/books/borrow
Required parameters: name
Optional parameters: none
Borrow a book from the library. Returns the book if it is borrowed
successfully. Returns NOT_FOUND if the book does not exist in the library.
Returns quota exceeded error if the amount of books borrowed exceeds
allocation quota in any dimensions."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/post
(util/get-url
"https://libraryagent.googleapis.com/"
"v1/{+name}:borrow"
#{:name}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn books-get$
"https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves/books/get
Required parameters: name
Optional parameters: none
Gets a book. Returns NOT_FOUND if the book does not exist."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://libraryagent.googleapis.com/"
"v1/{+name}"
#{:name}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn books-list$
"https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves/books/list
Required parameters: parent
Optional parameters: pageToken, pageSize
Lists books in a shelf. The order is unspecified but deterministic. Newly
created books will not necessarily be added to the end of this list.
Returns NOT_FOUND if the shelf does not exist."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/get
(util/get-url
"https://libraryagent.googleapis.com/"
"v1/{+parent}/books"
#{:parent}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn books-return$
"https://cloud.google.com/docs/quotaapi/reference/rest/v1/shelves/books/return
Required parameters: name
Optional parameters: none
Return a book to the library. Returns the book if it is returned to the
library successfully.
Returns error if the book does not belong to the library
or the users didn't borrow before."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/post
(util/get-url
"https://libraryagent.googleapis.com/"
"v1/{+name}:return"
#{:name}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))