-
Notifications
You must be signed in to change notification settings - Fork 4
/
photo.clj
257 lines (219 loc) · 7.41 KB
/
photo.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
(ns happygapi.streetviewpublish.photo
"Street View Publish API: photo.
Publishes 360 photos to Google Maps, along with position, orientation, and connectivity metadata. Apps can offer an interface for positioning, connecting, and uploading user-generated Street View images.
See: https://developers.google.com/streetview/publish/api/reference/rest/v1/photo"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn delete$
"https://developers.google.com/streetview/publish/api/reference/rest/v1/photo/delete
Required parameters: photoId
Optional parameters: none
Deletes a Photo and its metadata.
This method returns the following error codes:
* google.rpc.Code.PERMISSION_DENIED if the requesting user did not
create the requested photo.
* google.rpc.Code.NOT_FOUND if the photo ID does not exist."
{:scopes ["https://www.googleapis.com/auth/streetviewpublish"]}
[auth args]
{:pre [(util/has-keys? args #{:photoId})]}
(util/get-response
(http/delete
(util/get-url
"https://streetviewpublish.googleapis.com/"
"v1/photo/{photoId}"
#{:photoId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn get$
"https://developers.google.com/streetview/publish/api/reference/rest/v1/photo/get
Required parameters: photoId
Optional parameters: languageCode, view
Gets the metadata of the specified
Photo.
This method returns the following error codes:
* google.rpc.Code.PERMISSION_DENIED if the requesting user did not
create the requested Photo.
* google.rpc.Code.NOT_FOUND if the requested
Photo does not exist.
* google.rpc.Code.UNAVAILABLE if the requested
Photo is still being indexed."
{:scopes ["https://www.googleapis.com/auth/streetviewpublish"]}
[auth args]
{:pre [(util/has-keys? args #{:photoId})]}
(util/get-response
(http/get
(util/get-url
"https://streetviewpublish.googleapis.com/"
"v1/photo/{photoId}"
#{:photoId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn update$
"https://developers.google.com/streetview/publish/api/reference/rest/v1/photo/update
Required parameters: id
Optional parameters: updateMask
Body:
{:captureTime string,
:thumbnailUrl string,
:uploadReference {:uploadUrl string},
:viewCount string,
:transferStatus string,
:pose {:pitch number,
:latLngPair LatLng,
:roll number,
:accuracyMeters number,
:level Level,
:heading number,
:altitude number},
:shareLink string,
:mapsPublishStatus string,
:downloadUrl string,
:connections [{:target PhotoId}],
:places [{:languageCode string, :name string, :placeId string}],
:photoId {:id string}}
Updates the metadata of a Photo, such
as pose, place association, connections, etc. Changing the pixels of a
photo is not supported.
Only the fields specified in the
updateMask
field are used. If `updateMask` is not present, the update applies to all
fields.
This method returns the following error codes:
* google.rpc.Code.PERMISSION_DENIED if the requesting user did not
create the requested photo.
* google.rpc.Code.INVALID_ARGUMENT if the request is malformed.
* google.rpc.Code.NOT_FOUND if the requested photo does not exist.
* google.rpc.Code.UNAVAILABLE if the requested
Photo is still being indexed."
{:scopes ["https://www.googleapis.com/auth/streetviewpublish"]}
[auth args body]
{:pre [(util/has-keys? args #{:id})]}
(util/get-response
(http/put
(util/get-url
"https://streetviewpublish.googleapis.com/"
"v1/photo/{id}"
#{:id}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn create$
"https://developers.google.com/streetview/publish/api/reference/rest/v1/photo/create
Required parameters: none
Optional parameters: none
Body:
{:captureTime string,
:thumbnailUrl string,
:uploadReference {:uploadUrl string},
:viewCount string,
:transferStatus string,
:pose {:pitch number,
:latLngPair LatLng,
:roll number,
:accuracyMeters number,
:level Level,
:heading number,
:altitude number},
:shareLink string,
:mapsPublishStatus string,
:downloadUrl string,
:connections [{:target PhotoId}],
:places [{:languageCode string, :name string, :placeId string}],
:photoId {:id string}}
After the client finishes uploading the photo with the returned
UploadRef,
CreatePhoto
publishes the uploaded Photo to
Street View on Google Maps.
Currently, the only way to set heading, pitch, and roll in CreatePhoto is
through the [Photo Sphere XMP
metadata](https://developers.google.com/streetview/spherical-metadata) in
the photo bytes. CreatePhoto ignores the `pose.heading`, `pose.pitch`,
`pose.roll`, `pose.altitude`, and `pose.level` fields in Pose.
This method returns the following error codes:
* google.rpc.Code.INVALID_ARGUMENT if the request is malformed or if
the uploaded photo is not a 360 photo.
* google.rpc.Code.NOT_FOUND if the upload reference does not exist.
* google.rpc.Code.RESOURCE_EXHAUSTED if the account has reached the
storage limit."
{:scopes ["https://www.googleapis.com/auth/streetviewpublish"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://streetviewpublish.googleapis.com/"
"v1/photo"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn startUpload$
"https://developers.google.com/streetview/publish/api/reference/rest/v1/photo/startUpload
Required parameters: none
Optional parameters: none
Body:
{}
Creates an upload session to start uploading photo bytes. The method uses
the upload URL of the returned
UploadRef to upload the bytes for
the Photo.
In addition to the photo requirements shown in
https://support.google.com/maps/answer/7012050?hl=en&ref_topic=6275604,
the photo must meet the following requirements:
* Photo Sphere XMP metadata must be included in the photo metadata. See
https://developers.google.com/streetview/spherical-metadata for the
required fields.
* The pixel size of the photo must meet the size requirements listed in
https://support.google.com/maps/answer/7012050?hl=en&ref_topic=6275604, and
the photo must be a full 360 horizontally.
After the upload completes, the method uses
UploadRef with
CreatePhoto
to create the Photo object entry."
{:scopes ["https://www.googleapis.com/auth/streetviewpublish"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://streetviewpublish.googleapis.com/"
"v1/photo:startUpload"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))