vision-gen.go 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  1. // Package vision provides access to the Cloud Vision API.
  2. //
  3. // See https://cloud.google.com/vision/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/vision/v1"
  8. // ...
  9. // visionService, err := vision.New(oauthHttpClient)
  10. package vision // import "google.golang.org/api/vision/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "vision:v1"
  41. const apiName = "vision"
  42. const apiVersion = "v1"
  43. const basePath = "https://vision.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. )
  49. func New(client *http.Client) (*Service, error) {
  50. if client == nil {
  51. return nil, errors.New("client is nil")
  52. }
  53. s := &Service{client: client, BasePath: basePath}
  54. s.Images = NewImagesService(s)
  55. return s, nil
  56. }
  57. type Service struct {
  58. client *http.Client
  59. BasePath string // API endpoint base URL
  60. UserAgent string // optional additional User-Agent fragment
  61. Images *ImagesService
  62. }
  63. func (s *Service) userAgent() string {
  64. if s.UserAgent == "" {
  65. return googleapi.UserAgent
  66. }
  67. return googleapi.UserAgent + " " + s.UserAgent
  68. }
  69. func NewImagesService(s *Service) *ImagesService {
  70. rs := &ImagesService{s: s}
  71. return rs
  72. }
  73. type ImagesService struct {
  74. s *Service
  75. }
  76. // AnnotateImageRequest: Request for performing Vision tasks over a
  77. // user-provided image, with
  78. // user-requested features.
  79. type AnnotateImageRequest struct {
  80. // Features: Requested features.
  81. Features []*Feature `json:"features,omitempty"`
  82. // Image: The image to be processed.
  83. Image *Image `json:"image,omitempty"`
  84. // ImageContext: Additional context that may accompany the image.
  85. ImageContext *ImageContext `json:"imageContext,omitempty"`
  86. // ForceSendFields is a list of field names (e.g. "Features") to
  87. // unconditionally include in API requests. By default, fields with
  88. // empty values are omitted from API requests. However, any non-pointer,
  89. // non-interface field appearing in ForceSendFields will be sent to the
  90. // server regardless of whether the field is empty or not. This may be
  91. // used to include empty fields in Patch requests.
  92. ForceSendFields []string `json:"-"`
  93. }
  94. func (s *AnnotateImageRequest) MarshalJSON() ([]byte, error) {
  95. type noMethod AnnotateImageRequest
  96. raw := noMethod(*s)
  97. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  98. }
  99. // AnnotateImageResponse: Response to an image annotation request.
  100. type AnnotateImageResponse struct {
  101. // Error: If set, represents the error message for the operation.
  102. // Note that filled-in mage annotations are guaranteed to be
  103. // correct, even when <code>error</code> is non-empty.
  104. Error *Status `json:"error,omitempty"`
  105. // FaceAnnotations: If present, face detection completed successfully.
  106. FaceAnnotations []*FaceAnnotation `json:"faceAnnotations,omitempty"`
  107. // LabelAnnotations: If present, label detection completed successfully.
  108. LabelAnnotations []*EntityAnnotation `json:"labelAnnotations,omitempty"`
  109. // LandmarkAnnotations: If present, landmark detection completed
  110. // successfully.
  111. LandmarkAnnotations []*EntityAnnotation `json:"landmarkAnnotations,omitempty"`
  112. // LogoAnnotations: If present, logo detection completed successfully.
  113. LogoAnnotations []*EntityAnnotation `json:"logoAnnotations,omitempty"`
  114. // SafeSearchAnnotation: If present, safe-search annotation completed
  115. // successfully.
  116. SafeSearchAnnotation *SafeSearchAnnotation `json:"safeSearchAnnotation,omitempty"`
  117. // TextAnnotations: If present, text (OCR) detection completed
  118. // successfully.
  119. TextAnnotations []*EntityAnnotation `json:"textAnnotations,omitempty"`
  120. // ForceSendFields is a list of field names (e.g. "Error") to
  121. // unconditionally include in API requests. By default, fields with
  122. // empty values are omitted from API requests. However, any non-pointer,
  123. // non-interface field appearing in ForceSendFields will be sent to the
  124. // server regardless of whether the field is empty or not. This may be
  125. // used to include empty fields in Patch requests.
  126. ForceSendFields []string `json:"-"`
  127. }
  128. func (s *AnnotateImageResponse) MarshalJSON() ([]byte, error) {
  129. type noMethod AnnotateImageResponse
  130. raw := noMethod(*s)
  131. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  132. }
  133. // BatchAnnotateImagesRequest: Multiple image annotation requests are
  134. // batched into a single service call.
  135. type BatchAnnotateImagesRequest struct {
  136. // Requests: Individual image annotation requests for this batch.
  137. Requests []*AnnotateImageRequest `json:"requests,omitempty"`
  138. // ForceSendFields is a list of field names (e.g. "Requests") to
  139. // unconditionally include in API requests. By default, fields with
  140. // empty values are omitted from API requests. However, any non-pointer,
  141. // non-interface field appearing in ForceSendFields will be sent to the
  142. // server regardless of whether the field is empty or not. This may be
  143. // used to include empty fields in Patch requests.
  144. ForceSendFields []string `json:"-"`
  145. }
  146. func (s *BatchAnnotateImagesRequest) MarshalJSON() ([]byte, error) {
  147. type noMethod BatchAnnotateImagesRequest
  148. raw := noMethod(*s)
  149. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  150. }
  151. // BatchAnnotateImagesResponse: Response to a batch image annotation
  152. // request.
  153. type BatchAnnotateImagesResponse struct {
  154. // Responses: Individual responses to image annotation requests within
  155. // the batch.
  156. Responses []*AnnotateImageResponse `json:"responses,omitempty"`
  157. // ServerResponse contains the HTTP response code and headers from the
  158. // server.
  159. googleapi.ServerResponse `json:"-"`
  160. // ForceSendFields is a list of field names (e.g. "Responses") to
  161. // unconditionally include in API requests. By default, fields with
  162. // empty values are omitted from API requests. However, any non-pointer,
  163. // non-interface field appearing in ForceSendFields will be sent to the
  164. // server regardless of whether the field is empty or not. This may be
  165. // used to include empty fields in Patch requests.
  166. ForceSendFields []string `json:"-"`
  167. }
  168. func (s *BatchAnnotateImagesResponse) MarshalJSON() ([]byte, error) {
  169. type noMethod BatchAnnotateImagesResponse
  170. raw := noMethod(*s)
  171. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  172. }
  173. // BoundingPoly: A bounding polygon for the detected image annotation.
  174. type BoundingPoly struct {
  175. // Vertices: The bounding polygon vertices.
  176. Vertices []*Vertex `json:"vertices,omitempty"`
  177. // ForceSendFields is a list of field names (e.g. "Vertices") to
  178. // unconditionally include in API requests. By default, fields with
  179. // empty values are omitted from API requests. However, any non-pointer,
  180. // non-interface field appearing in ForceSendFields will be sent to the
  181. // server regardless of whether the field is empty or not. This may be
  182. // used to include empty fields in Patch requests.
  183. ForceSendFields []string `json:"-"`
  184. }
  185. func (s *BoundingPoly) MarshalJSON() ([]byte, error) {
  186. type noMethod BoundingPoly
  187. raw := noMethod(*s)
  188. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  189. }
  190. // EntityAnnotation: Set of detected entity features.
  191. type EntityAnnotation struct {
  192. // BoundingPoly: Image region to which this entity belongs.
  193. BoundingPoly *BoundingPoly `json:"boundingPoly,omitempty"`
  194. // Confidence: The accuracy of the entity recognition in an image.
  195. // For example, for an image containing 'Eiffel Tower,' this field
  196. // represents
  197. // the confidence that there is a tower in the query image. Range [0,
  198. // 1].
  199. Confidence float64 `json:"confidence,omitempty"`
  200. // Description: Entity textual description, expressed in its
  201. // <code>locale</code> language.
  202. Description string `json:"description,omitempty"`
  203. // Locale: The language code for the locale in which the entity
  204. // textual
  205. // <code>description</code> (next field) is expressed.
  206. Locale string `json:"locale,omitempty"`
  207. // Locations: The location information for the recognized entity.
  208. // Multiple
  209. // <code>LocationInfo</code> elements can be present since one location
  210. // may
  211. // indicate the location of the scene in the query image, and another
  212. // the
  213. // location of the place where the query image was taken. Location
  214. // information
  215. // is usually present for landmarks.
  216. Locations []*LocationInfo `json:"locations,omitempty"`
  217. // Mid: Knowledge Graph entity ID. Maps to a freebase entity ID.
  218. // (for example, "Google" maps to: mid /m/045c7b).
  219. Mid string `json:"mid,omitempty"`
  220. // Properties: Some entities can have additional optional
  221. // <code>Property</code> fields.
  222. // For example a different kind of score or string that qualifies the
  223. // entity.
  224. Properties []*Property `json:"properties,omitempty"`
  225. // Score: Overall score of the result. Range [0, 1].
  226. Score float64 `json:"score,omitempty"`
  227. // Topicality: The relevancy of the ICA (Image Content Annotation) label
  228. // to the
  229. // image. For example, the relevancy of 'tower' to an image
  230. // containing
  231. // 'Eiffel Tower' is likely higher than an image containing a distant
  232. // towering
  233. // building, though the confidence that there is a tower may be the
  234. // same.
  235. // Range [0, 1].
  236. Topicality float64 `json:"topicality,omitempty"`
  237. // ForceSendFields is a list of field names (e.g. "BoundingPoly") to
  238. // unconditionally include in API requests. By default, fields with
  239. // empty values are omitted from API requests. However, any non-pointer,
  240. // non-interface field appearing in ForceSendFields will be sent to the
  241. // server regardless of whether the field is empty or not. This may be
  242. // used to include empty fields in Patch requests.
  243. ForceSendFields []string `json:"-"`
  244. }
  245. func (s *EntityAnnotation) MarshalJSON() ([]byte, error) {
  246. type noMethod EntityAnnotation
  247. raw := noMethod(*s)
  248. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  249. }
  250. // FaceAnnotation: A face annotation contains the results of face
  251. // detection.
  252. type FaceAnnotation struct {
  253. // AngerLikelihood: Anger likelihood.
  254. //
  255. // Possible values:
  256. // "UNKNOWN" - Unknown likelihood.
  257. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  258. // specified.
  259. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  260. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  261. // "LIKELY" - The image likely belongs to the vertical specified.
  262. // "VERY_LIKELY" - The image very likely belongs to the vertical
  263. // specified.
  264. AngerLikelihood string `json:"angerLikelihood,omitempty"`
  265. // BlurredLikelihood: Blurred likelihood.
  266. //
  267. // Possible values:
  268. // "UNKNOWN" - Unknown likelihood.
  269. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  270. // specified.
  271. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  272. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  273. // "LIKELY" - The image likely belongs to the vertical specified.
  274. // "VERY_LIKELY" - The image very likely belongs to the vertical
  275. // specified.
  276. BlurredLikelihood string `json:"blurredLikelihood,omitempty"`
  277. // BoundingPoly: The bounding polygon around the face. The coordinates
  278. // of the bounding box
  279. // are in the original image's scale, as returned in ImageParams.
  280. // The bounding box is computed to "frame" the face in accordance with
  281. // human
  282. // expectations. It is based on the landmarker results.
  283. BoundingPoly *BoundingPoly `json:"boundingPoly,omitempty"`
  284. // DetectionConfidence: Detection confidence. Range [0, 1].
  285. DetectionConfidence float64 `json:"detectionConfidence,omitempty"`
  286. // FdBoundingPoly: This bounding polygon is tighter than the
  287. // previous
  288. // <code>boundingPoly</code>, and
  289. // encloses only the skin part of the face. Typically, it is used
  290. // to
  291. // eliminate the face from any image analysis that detects the
  292. // "amount of skin" visible in an image. It is not based on
  293. // the
  294. // landmarker results, only on the initial face detection, hence
  295. // the <code>fd</code> (face detection) prefix.
  296. FdBoundingPoly *BoundingPoly `json:"fdBoundingPoly,omitempty"`
  297. // HeadwearLikelihood: Headwear likelihood.
  298. //
  299. // Possible values:
  300. // "UNKNOWN" - Unknown likelihood.
  301. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  302. // specified.
  303. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  304. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  305. // "LIKELY" - The image likely belongs to the vertical specified.
  306. // "VERY_LIKELY" - The image very likely belongs to the vertical
  307. // specified.
  308. HeadwearLikelihood string `json:"headwearLikelihood,omitempty"`
  309. // JoyLikelihood: Joy likelihood.
  310. //
  311. // Possible values:
  312. // "UNKNOWN" - Unknown likelihood.
  313. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  314. // specified.
  315. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  316. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  317. // "LIKELY" - The image likely belongs to the vertical specified.
  318. // "VERY_LIKELY" - The image very likely belongs to the vertical
  319. // specified.
  320. JoyLikelihood string `json:"joyLikelihood,omitempty"`
  321. // LandmarkingConfidence: Face landmarking confidence. Range [0, 1].
  322. LandmarkingConfidence float64 `json:"landmarkingConfidence,omitempty"`
  323. // Landmarks: Detected face landmarks.
  324. Landmarks []*Landmark `json:"landmarks,omitempty"`
  325. // PanAngle: Yaw angle. Indicates the leftward/rightward angle that the
  326. // face is
  327. // pointing, relative to the vertical plane perpendicular to the image.
  328. // Range
  329. // [-180,180].
  330. PanAngle float64 `json:"panAngle,omitempty"`
  331. // RollAngle: Roll angle. Indicates the amount of
  332. // clockwise/anti-clockwise rotation of
  333. // the
  334. // face relative to the image vertical, about the axis perpendicular to
  335. // the
  336. // face. Range [-180,180].
  337. RollAngle float64 `json:"rollAngle,omitempty"`
  338. // SorrowLikelihood: Sorrow likelihood.
  339. //
  340. // Possible values:
  341. // "UNKNOWN" - Unknown likelihood.
  342. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  343. // specified.
  344. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  345. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  346. // "LIKELY" - The image likely belongs to the vertical specified.
  347. // "VERY_LIKELY" - The image very likely belongs to the vertical
  348. // specified.
  349. SorrowLikelihood string `json:"sorrowLikelihood,omitempty"`
  350. // SurpriseLikelihood: Surprise likelihood.
  351. //
  352. // Possible values:
  353. // "UNKNOWN" - Unknown likelihood.
  354. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  355. // specified.
  356. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  357. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  358. // "LIKELY" - The image likely belongs to the vertical specified.
  359. // "VERY_LIKELY" - The image very likely belongs to the vertical
  360. // specified.
  361. SurpriseLikelihood string `json:"surpriseLikelihood,omitempty"`
  362. // TiltAngle: Pitch angle. Indicates the upwards/downwards angle that
  363. // the face is
  364. // pointing
  365. // relative to the image's horizontal plane. Range [-180,180].
  366. TiltAngle float64 `json:"tiltAngle,omitempty"`
  367. // UnderExposedLikelihood: Under-exposed likelihood.
  368. //
  369. // Possible values:
  370. // "UNKNOWN" - Unknown likelihood.
  371. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  372. // specified.
  373. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  374. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  375. // "LIKELY" - The image likely belongs to the vertical specified.
  376. // "VERY_LIKELY" - The image very likely belongs to the vertical
  377. // specified.
  378. UnderExposedLikelihood string `json:"underExposedLikelihood,omitempty"`
  379. // ForceSendFields is a list of field names (e.g. "AngerLikelihood") to
  380. // unconditionally include in API requests. By default, fields with
  381. // empty values are omitted from API requests. However, any non-pointer,
  382. // non-interface field appearing in ForceSendFields will be sent to the
  383. // server regardless of whether the field is empty or not. This may be
  384. // used to include empty fields in Patch requests.
  385. ForceSendFields []string `json:"-"`
  386. }
  387. func (s *FaceAnnotation) MarshalJSON() ([]byte, error) {
  388. type noMethod FaceAnnotation
  389. raw := noMethod(*s)
  390. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  391. }
  392. // Feature: The <em>Feature</em> indicates what type of image detection
  393. // task to perform.
  394. // Users describe the type of Vision tasks to perform over images
  395. // by
  396. // using <em>Feature</em>s. Features encode the Vision vertical to
  397. // operate on
  398. // and the number of top-scoring results to return.
  399. type Feature struct {
  400. // MaxResults: Maximum number of results of this type.
  401. MaxResults int64 `json:"maxResults,omitempty"`
  402. // Type: The feature type.
  403. //
  404. // Possible values:
  405. // "TYPE_UNSPECIFIED" - Unspecified feature type.
  406. // "FACE_DETECTION" - Run face detection.
  407. // "LANDMARK_DETECTION" - Run landmark detection.
  408. // "LOGO_DETECTION" - Run logo detection.
  409. // "LABEL_DETECTION" - Run label detection.
  410. // "TEXT_DETECTION" - Run OCR.
  411. // "SAFE_SEARCH_DETECTION" - Run various computer vision models to
  412. // "IMAGE_PROPERTIES" - compute image safe-search properties.
  413. // Compute image properties.
  414. Type string `json:"type,omitempty"`
  415. // ForceSendFields is a list of field names (e.g. "MaxResults") to
  416. // unconditionally include in API requests. By default, fields with
  417. // empty values are omitted from API requests. However, any non-pointer,
  418. // non-interface field appearing in ForceSendFields will be sent to the
  419. // server regardless of whether the field is empty or not. This may be
  420. // used to include empty fields in Patch requests.
  421. ForceSendFields []string `json:"-"`
  422. }
  423. func (s *Feature) MarshalJSON() ([]byte, error) {
  424. type noMethod Feature
  425. raw := noMethod(*s)
  426. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  427. }
  428. // Image: Client image to perform Vision tasks over.
  429. type Image struct {
  430. // Content: Image content, represented as a stream of bytes.
  431. Content string `json:"content,omitempty"`
  432. // Source: Google Cloud Storage image location. If both 'content' and
  433. // 'source'
  434. // are filled for an image, 'content' takes precedence and it will
  435. // be
  436. // used for performing the image annotation request.
  437. Source *ImageSource `json:"source,omitempty"`
  438. // ForceSendFields is a list of field names (e.g. "Content") to
  439. // unconditionally include in API requests. By default, fields with
  440. // empty values are omitted from API requests. However, any non-pointer,
  441. // non-interface field appearing in ForceSendFields will be sent to the
  442. // server regardless of whether the field is empty or not. This may be
  443. // used to include empty fields in Patch requests.
  444. ForceSendFields []string `json:"-"`
  445. }
  446. func (s *Image) MarshalJSON() ([]byte, error) {
  447. type noMethod Image
  448. raw := noMethod(*s)
  449. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  450. }
  451. // ImageContext: Image context.
  452. type ImageContext struct {
  453. // LanguageHints: List of languages to use for TEXT_DETECTION. In most
  454. // cases, an empty value
  455. // will yield the best results as it will allow text detection
  456. // to
  457. // automatically detect the text language. For languages based on the
  458. // latin
  459. // alphabet a hint is not needed. In rare cases, when the language
  460. // of
  461. // the text in the image is known in advance, setting this hint will
  462. // help get
  463. // better results (although it will hurt a great deal if the hint is
  464. // wrong).
  465. // Text detection will return an error if one or more of the
  466. // languages
  467. // specified here are not supported. The exact list of supported
  468. // languages are
  469. // specified
  470. // here:
  471. // https://cloud.google.com/translate/v2/using_rest#language-params
  472. LanguageHints []string `json:"languageHints,omitempty"`
  473. // LatLongRect: Lat/long rectangle that specifies the location of the
  474. // image.
  475. LatLongRect *LatLongRect `json:"latLongRect,omitempty"`
  476. // ForceSendFields is a list of field names (e.g. "LanguageHints") to
  477. // unconditionally include in API requests. By default, fields with
  478. // empty values are omitted from API requests. However, any non-pointer,
  479. // non-interface field appearing in ForceSendFields will be sent to the
  480. // server regardless of whether the field is empty or not. This may be
  481. // used to include empty fields in Patch requests.
  482. ForceSendFields []string `json:"-"`
  483. }
  484. func (s *ImageContext) MarshalJSON() ([]byte, error) {
  485. type noMethod ImageContext
  486. raw := noMethod(*s)
  487. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  488. }
  489. // ImageSource: External image source (i.e. Google Cloud Storage image
  490. // location).
  491. type ImageSource struct {
  492. // GcsImageUri: Google Cloud Storage image URI. It must be in the
  493. // following form:
  494. // "gs://bucket_name/object_name". For more
  495. // details, please see:
  496. // https://cloud.google.com/storage/docs/reference-uris.
  497. // NOTE: GCS object versioning is not supported!
  498. GcsImageUri string `json:"gcsImageUri,omitempty"`
  499. // ForceSendFields is a list of field names (e.g. "GcsImageUri") to
  500. // unconditionally include in API requests. By default, fields with
  501. // empty values are omitted from API requests. However, any non-pointer,
  502. // non-interface field appearing in ForceSendFields will be sent to the
  503. // server regardless of whether the field is empty or not. This may be
  504. // used to include empty fields in Patch requests.
  505. ForceSendFields []string `json:"-"`
  506. }
  507. func (s *ImageSource) MarshalJSON() ([]byte, error) {
  508. type noMethod ImageSource
  509. raw := noMethod(*s)
  510. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  511. }
  512. // Landmark: A face-specific landmark (for example, a face
  513. // feature).
  514. // Landmark positions may fall outside the bounds of the image
  515. // when the face is near one or more edges of the image.
  516. // Therefore it is NOT guaranteed that 0 <= x < width or 0 <= y <
  517. // height.
  518. type Landmark struct {
  519. // Position: Face landmark position.
  520. Position *Position `json:"position,omitempty"`
  521. // Type: Face landmark type.
  522. //
  523. // Possible values:
  524. // "UNKNOWN_LANDMARK" - Unknown face landmark detected. Should not be
  525. // filled.
  526. // "LEFT_EYE" - Left eye.
  527. // "RIGHT_EYE" - Right eye.
  528. // "LEFT_OF_LEFT_EYEBROW" - Left of left eyebrow.
  529. // "RIGHT_OF_LEFT_EYEBROW" - Right of left eyebrow.
  530. // "LEFT_OF_RIGHT_EYEBROW" - Left of right eyebrow.
  531. // "RIGHT_OF_RIGHT_EYEBROW" - Right of right eyebrow.
  532. // "MIDPOINT_BETWEEN_EYES" - Midpoint between eyes.
  533. // "NOSE_TIP" - Nose tip.
  534. // "UPPER_LIP" - Upper lip.
  535. // "LOWER_LIP" - Lower lip.
  536. // "MOUTH_LEFT" - Mouth left.
  537. // "MOUTH_RIGHT" - Mouth right.
  538. // "MOUTH_CENTER" - Mouth center.
  539. // "NOSE_BOTTOM_RIGHT" - Nose, bottom right.
  540. // "NOSE_BOTTOM_LEFT" - Nose, bottom left.
  541. // "NOSE_BOTTOM_CENTER" - Nose, bottom center.
  542. // "LEFT_EYE_TOP_BOUNDARY" - Left eye, top boundary.
  543. // "LEFT_EYE_RIGHT_CORNER" - Left eye, right corner.
  544. // "LEFT_EYE_BOTTOM_BOUNDARY" - Left eye, bottom boundary.
  545. // "LEFT_EYE_LEFT_CORNER" - Left eye, left corner.
  546. // "RIGHT_EYE_TOP_BOUNDARY" - Right eye, top boundary.
  547. // "RIGHT_EYE_RIGHT_CORNER" - Right eye, right corner.
  548. // "RIGHT_EYE_BOTTOM_BOUNDARY" - Right eye, bottom boundary.
  549. // "RIGHT_EYE_LEFT_CORNER" - Right eye, left corner.
  550. // "LEFT_EYEBROW_UPPER_MIDPOINT" - Left eyebrow, upper midpoint.
  551. // "RIGHT_EYEBROW_UPPER_MIDPOINT" - Right eyebrow, upper midpoint.
  552. // "LEFT_EAR_TRAGION" - Left ear tragion.
  553. // "RIGHT_EAR_TRAGION" - Right ear tragion.
  554. // "LEFT_EYE_PUPIL" - Left eye pupil.
  555. // "RIGHT_EYE_PUPIL" - Right eye pupil.
  556. // "FOREHEAD_GLABELLA" - Forehead glabella.
  557. // "CHIN_GNATHION" - Chin gnathion.
  558. // "CHIN_LEFT_GONION" - Chin left gonion.
  559. // "CHIN_RIGHT_GONION" - Chin right gonion.
  560. Type string `json:"type,omitempty"`
  561. // ForceSendFields is a list of field names (e.g. "Position") to
  562. // unconditionally include in API requests. By default, fields with
  563. // empty values are omitted from API requests. However, any non-pointer,
  564. // non-interface field appearing in ForceSendFields will be sent to the
  565. // server regardless of whether the field is empty or not. This may be
  566. // used to include empty fields in Patch requests.
  567. ForceSendFields []string `json:"-"`
  568. }
  569. func (s *Landmark) MarshalJSON() ([]byte, error) {
  570. type noMethod Landmark
  571. raw := noMethod(*s)
  572. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  573. }
  574. // LatLng: An object representing a latitude/longitude pair. This is
  575. // expressed as a pair
  576. // of doubles representing degrees latitude and degrees longitude.
  577. // Unless
  578. // specified otherwise, this must conform to the
  579. // <a
  580. // href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
  581. // st
  582. // andard</a>. Values must be within normalized ranges.
  583. //
  584. // Example of normalization code in Python:
  585. //
  586. // def NormalizeLongitude(longitude):
  587. // """Wraps decimal degrees longitude to [-180.0, 180.0]."""
  588. // q, r = divmod(longitude, 360.0)
  589. // if r > 180.0 or (r == 180.0 and q <= -1.0):
  590. // return r - 360.0
  591. // return r
  592. //
  593. // def NormalizeLatLng(latitude, longitude):
  594. // """Wraps decimal degrees latitude and longitude to
  595. // [-180.0, 180.0] and [-90.0, 90.0], respectively."""
  596. // r = latitude % 360.0
  597. // if r <= 90.0:
  598. // return r, NormalizeLongitude(longitude)
  599. // elif r >= 270.0:
  600. // return r - 360, NormalizeLongitude(longitude)
  601. // else:
  602. // return 180 - r, NormalizeLongitude(longitude + 180.0)
  603. //
  604. // assert 180.0 == NormalizeLongitude(180.0)
  605. // assert -180.0 == NormalizeLongitude(-180.0)
  606. // assert -179.0 == NormalizeLongitude(181.0)
  607. // assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0)
  608. // assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0)
  609. // assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0)
  610. // assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0)
  611. // assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0)
  612. // assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0)
  613. // assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0)
  614. // assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0)
  615. // assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0)
  616. // assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0)
  617. type LatLng struct {
  618. // Latitude: The latitude in degrees. It must be in the range [-90.0,
  619. // +90.0].
  620. Latitude float64 `json:"latitude,omitempty"`
  621. // Longitude: The longitude in degrees. It must be in the range [-180.0,
  622. // +180.0].
  623. Longitude float64 `json:"longitude,omitempty"`
  624. // ForceSendFields is a list of field names (e.g. "Latitude") to
  625. // unconditionally include in API requests. By default, fields with
  626. // empty values are omitted from API requests. However, any non-pointer,
  627. // non-interface field appearing in ForceSendFields will be sent to the
  628. // server regardless of whether the field is empty or not. This may be
  629. // used to include empty fields in Patch requests.
  630. ForceSendFields []string `json:"-"`
  631. }
  632. func (s *LatLng) MarshalJSON() ([]byte, error) {
  633. type noMethod LatLng
  634. raw := noMethod(*s)
  635. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  636. }
  637. // LatLongRect: Rectangle determined by min and max LatLng pairs.
  638. type LatLongRect struct {
  639. // MaxLatLng: Max lat/long pair.
  640. MaxLatLng *LatLng `json:"maxLatLng,omitempty"`
  641. // MinLatLng: Min lat/long pair.
  642. MinLatLng *LatLng `json:"minLatLng,omitempty"`
  643. // ForceSendFields is a list of field names (e.g. "MaxLatLng") to
  644. // unconditionally include in API requests. By default, fields with
  645. // empty values are omitted from API requests. However, any non-pointer,
  646. // non-interface field appearing in ForceSendFields will be sent to the
  647. // server regardless of whether the field is empty or not. This may be
  648. // used to include empty fields in Patch requests.
  649. ForceSendFields []string `json:"-"`
  650. }
  651. func (s *LatLongRect) MarshalJSON() ([]byte, error) {
  652. type noMethod LatLongRect
  653. raw := noMethod(*s)
  654. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  655. }
  656. // LocationInfo: Detected entity location information.
  657. type LocationInfo struct {
  658. // LatLng: Lat - long location coordinates.
  659. LatLng *LatLng `json:"latLng,omitempty"`
  660. // ForceSendFields is a list of field names (e.g. "LatLng") to
  661. // unconditionally include in API requests. By default, fields with
  662. // empty values are omitted from API requests. However, any non-pointer,
  663. // non-interface field appearing in ForceSendFields will be sent to the
  664. // server regardless of whether the field is empty or not. This may be
  665. // used to include empty fields in Patch requests.
  666. ForceSendFields []string `json:"-"`
  667. }
  668. func (s *LocationInfo) MarshalJSON() ([]byte, error) {
  669. type noMethod LocationInfo
  670. raw := noMethod(*s)
  671. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  672. }
  673. // Position: A 3D position in the image, used primarily for Face
  674. // detection landmarks.
  675. // A valid Position must have both x and y coordinates.
  676. // The position coordinates are in the same scale as the original image.
  677. type Position struct {
  678. // X: X coordinate.
  679. X float64 `json:"x,omitempty"`
  680. // Y: Y coordinate.
  681. Y float64 `json:"y,omitempty"`
  682. // Z: Z coordinate (or depth).
  683. Z float64 `json:"z,omitempty"`
  684. // ForceSendFields is a list of field names (e.g. "X") to
  685. // unconditionally include in API requests. By default, fields with
  686. // empty values are omitted from API requests. However, any non-pointer,
  687. // non-interface field appearing in ForceSendFields will be sent to the
  688. // server regardless of whether the field is empty or not. This may be
  689. // used to include empty fields in Patch requests.
  690. ForceSendFields []string `json:"-"`
  691. }
  692. func (s *Position) MarshalJSON() ([]byte, error) {
  693. type noMethod Position
  694. raw := noMethod(*s)
  695. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  696. }
  697. // Property: Arbitrary name/value pair.
  698. type Property struct {
  699. // Name: Name of the property.
  700. Name string `json:"name,omitempty"`
  701. // Value: Value of the property.
  702. Value string `json:"value,omitempty"`
  703. // ForceSendFields is a list of field names (e.g. "Name") to
  704. // unconditionally include in API requests. By default, fields with
  705. // empty values are omitted from API requests. However, any non-pointer,
  706. // non-interface field appearing in ForceSendFields will be sent to the
  707. // server regardless of whether the field is empty or not. This may be
  708. // used to include empty fields in Patch requests.
  709. ForceSendFields []string `json:"-"`
  710. }
  711. func (s *Property) MarshalJSON() ([]byte, error) {
  712. type noMethod Property
  713. raw := noMethod(*s)
  714. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  715. }
  716. // SafeSearchAnnotation: Set of features pertaining to the image,
  717. // computed by various computer vision
  718. // methods over safe-search verticals (for example, adult, spoof,
  719. // medical,
  720. // violence).
  721. type SafeSearchAnnotation struct {
  722. // Adult: Represents the adult contents likelihood for the image.
  723. //
  724. // Possible values:
  725. // "UNKNOWN" - Unknown likelihood.
  726. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  727. // specified.
  728. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  729. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  730. // "LIKELY" - The image likely belongs to the vertical specified.
  731. // "VERY_LIKELY" - The image very likely belongs to the vertical
  732. // specified.
  733. Adult string `json:"adult,omitempty"`
  734. // Medical: Likelihood this is a medical image.
  735. //
  736. // Possible values:
  737. // "UNKNOWN" - Unknown likelihood.
  738. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  739. // specified.
  740. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  741. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  742. // "LIKELY" - The image likely belongs to the vertical specified.
  743. // "VERY_LIKELY" - The image very likely belongs to the vertical
  744. // specified.
  745. Medical string `json:"medical,omitempty"`
  746. // Spoof: Spoof likelihood. The likelihood that an obvious
  747. // modification
  748. // was made to the image's canonical version to make it appear
  749. // funny or offensive.
  750. //
  751. // Possible values:
  752. // "UNKNOWN" - Unknown likelihood.
  753. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  754. // specified.
  755. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  756. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  757. // "LIKELY" - The image likely belongs to the vertical specified.
  758. // "VERY_LIKELY" - The image very likely belongs to the vertical
  759. // specified.
  760. Spoof string `json:"spoof,omitempty"`
  761. // Violence: Violence likelihood.
  762. //
  763. // Possible values:
  764. // "UNKNOWN" - Unknown likelihood.
  765. // "VERY_UNLIKELY" - The image very unlikely belongs to the vertical
  766. // specified.
  767. // "UNLIKELY" - The image unlikely belongs to the vertical specified.
  768. // "POSSIBLE" - The image possibly belongs to the vertical specified.
  769. // "LIKELY" - The image likely belongs to the vertical specified.
  770. // "VERY_LIKELY" - The image very likely belongs to the vertical
  771. // specified.
  772. Violence string `json:"violence,omitempty"`
  773. // ForceSendFields is a list of field names (e.g. "Adult") to
  774. // unconditionally include in API requests. By default, fields with
  775. // empty values are omitted from API requests. However, any non-pointer,
  776. // non-interface field appearing in ForceSendFields will be sent to the
  777. // server regardless of whether the field is empty or not. This may be
  778. // used to include empty fields in Patch requests.
  779. ForceSendFields []string `json:"-"`
  780. }
  781. func (s *SafeSearchAnnotation) MarshalJSON() ([]byte, error) {
  782. type noMethod SafeSearchAnnotation
  783. raw := noMethod(*s)
  784. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  785. }
  786. // Status: The `Status` type defines a logical error model that is
  787. // suitable for different
  788. // programming environments, including REST APIs and RPC APIs. It is
  789. // used by
  790. // [gRPC](https://github.com/grpc). The error model is designed to
  791. // be:
  792. //
  793. // - Simple to use and understand for most users
  794. // - Flexible enough to meet unexpected needs
  795. //
  796. // # Overview
  797. //
  798. // The `Status` message contains three pieces of data: error code, error
  799. // message,
  800. // and error details. The error code should be an enum value
  801. // of
  802. // google.rpc.Code, but it may accept additional error codes if needed.
  803. // The
  804. // error message should be a developer-facing English message that
  805. // helps
  806. // developers *understand* and *resolve* the error. If a localized
  807. // user-facing
  808. // error message is needed, put the localized message in the error
  809. // details or
  810. // localize it in the client. The optional error details may contain
  811. // arbitrary
  812. // information about the error. There is a predefined set of error
  813. // detail types
  814. // in the package `google.rpc` which can be used for common error
  815. // conditions.
  816. //
  817. // # Language mapping
  818. //
  819. // The `Status` message is the logical representation of the error
  820. // model, but it
  821. // is not necessarily the actual wire format. When the `Status` message
  822. // is
  823. // exposed in different client libraries and different wire protocols,
  824. // it can be
  825. // mapped differently. For example, it will likely be mapped to some
  826. // exceptions
  827. // in Java, but more likely mapped to some error codes in C.
  828. //
  829. // # Other uses
  830. //
  831. // The error model and the `Status` message can be used in a variety
  832. // of
  833. // environments, either with or without APIs, to provide a
  834. // consistent developer experience across different
  835. // environments.
  836. //
  837. // Example uses of this error model include:
  838. //
  839. // - Partial errors. If a service needs to return partial errors to the
  840. // client,
  841. // it may embed the `Status` in the normal response to indicate the
  842. // partial
  843. // errors.
  844. //
  845. // - Workflow errors. A typical workflow has multiple steps. Each step
  846. // may
  847. // have a `Status` message for error reporting purpose.
  848. //
  849. // - Batch operations. If a client uses batch request and batch
  850. // response, the
  851. // `Status` message should be used directly inside batch response,
  852. // one for
  853. // each error sub-response.
  854. //
  855. // - Asynchronous operations. If an API call embeds asynchronous
  856. // operation
  857. // results in its response, the status of those operations should
  858. // be
  859. // represented directly using the `Status` message.
  860. //
  861. // - Logging. If some API errors are stored in logs, the message
  862. // `Status` could
  863. // be used directly after any stripping needed for security/privacy
  864. // reasons.
  865. type Status struct {
  866. // Code: The status code, which should be an enum value of
  867. // google.rpc.Code.
  868. Code int64 `json:"code,omitempty"`
  869. // Details: A list of messages that carry the error details. There will
  870. // be a
  871. // common set of message types for APIs to use.
  872. Details []StatusDetails `json:"details,omitempty"`
  873. // Message: A developer-facing error message, which should be in
  874. // English. Any
  875. // user-facing error message should be localized and sent in
  876. // the
  877. // google.rpc.Status.details field, or localized by the client.
  878. Message string `json:"message,omitempty"`
  879. // ForceSendFields is a list of field names (e.g. "Code") to
  880. // unconditionally include in API requests. By default, fields with
  881. // empty values are omitted from API requests. However, any non-pointer,
  882. // non-interface field appearing in ForceSendFields will be sent to the
  883. // server regardless of whether the field is empty or not. This may be
  884. // used to include empty fields in Patch requests.
  885. ForceSendFields []string `json:"-"`
  886. }
  887. func (s *Status) MarshalJSON() ([]byte, error) {
  888. type noMethod Status
  889. raw := noMethod(*s)
  890. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  891. }
  892. type StatusDetails interface{}
  893. // Vertex: A vertex represents a 2D point in the image.
  894. // NOTE: the vertex coordinates are in the same scale as the original
  895. // image.
  896. type Vertex struct {
  897. // X: X coordinate.
  898. X int64 `json:"x,omitempty"`
  899. // Y: Y coordinate.
  900. Y int64 `json:"y,omitempty"`
  901. // ForceSendFields is a list of field names (e.g. "X") to
  902. // unconditionally include in API requests. By default, fields with
  903. // empty values are omitted from API requests. However, any non-pointer,
  904. // non-interface field appearing in ForceSendFields will be sent to the
  905. // server regardless of whether the field is empty or not. This may be
  906. // used to include empty fields in Patch requests.
  907. ForceSendFields []string `json:"-"`
  908. }
  909. func (s *Vertex) MarshalJSON() ([]byte, error) {
  910. type noMethod Vertex
  911. raw := noMethod(*s)
  912. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  913. }
  914. // method id "vision.images.annotate":
  915. type ImagesAnnotateCall struct {
  916. s *Service
  917. batchannotateimagesrequest *BatchAnnotateImagesRequest
  918. urlParams_ gensupport.URLParams
  919. ctx_ context.Context
  920. }
  921. // Annotate: Run image detection and annotation for a batch of images.
  922. func (r *ImagesService) Annotate(batchannotateimagesrequest *BatchAnnotateImagesRequest) *ImagesAnnotateCall {
  923. c := &ImagesAnnotateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  924. c.batchannotateimagesrequest = batchannotateimagesrequest
  925. return c
  926. }
  927. // Fields allows partial responses to be retrieved. See
  928. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  929. // for more information.
  930. func (c *ImagesAnnotateCall) Fields(s ...googleapi.Field) *ImagesAnnotateCall {
  931. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  932. return c
  933. }
  934. // Context sets the context to be used in this call's Do method. Any
  935. // pending HTTP request will be aborted if the provided context is
  936. // canceled.
  937. func (c *ImagesAnnotateCall) Context(ctx context.Context) *ImagesAnnotateCall {
  938. c.ctx_ = ctx
  939. return c
  940. }
  941. func (c *ImagesAnnotateCall) doRequest(alt string) (*http.Response, error) {
  942. var body io.Reader = nil
  943. body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchannotateimagesrequest)
  944. if err != nil {
  945. return nil, err
  946. }
  947. ctype := "application/json"
  948. c.urlParams_.Set("alt", alt)
  949. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/images:annotate")
  950. urls += "?" + c.urlParams_.Encode()
  951. req, _ := http.NewRequest("POST", urls, body)
  952. googleapi.SetOpaque(req.URL)
  953. req.Header.Set("Content-Type", ctype)
  954. req.Header.Set("User-Agent", c.s.userAgent())
  955. if c.ctx_ != nil {
  956. return ctxhttp.Do(c.ctx_, c.s.client, req)
  957. }
  958. return c.s.client.Do(req)
  959. }
  960. // Do executes the "vision.images.annotate" call.
  961. // Exactly one of *BatchAnnotateImagesResponse or error will be non-nil.
  962. // Any non-2xx status code is an error. Response headers are in either
  963. // *BatchAnnotateImagesResponse.ServerResponse.Header or (if a response
  964. // was returned at all) in error.(*googleapi.Error).Header. Use
  965. // googleapi.IsNotModified to check whether the returned error was
  966. // because http.StatusNotModified was returned.
  967. func (c *ImagesAnnotateCall) Do(opts ...googleapi.CallOption) (*BatchAnnotateImagesResponse, error) {
  968. gensupport.SetOptions(c.urlParams_, opts...)
  969. res, err := c.doRequest("json")
  970. if res != nil && res.StatusCode == http.StatusNotModified {
  971. if res.Body != nil {
  972. res.Body.Close()
  973. }
  974. return nil, &googleapi.Error{
  975. Code: res.StatusCode,
  976. Header: res.Header,
  977. }
  978. }
  979. if err != nil {
  980. return nil, err
  981. }
  982. defer googleapi.CloseBody(res)
  983. if err := googleapi.CheckResponse(res); err != nil {
  984. return nil, err
  985. }
  986. ret := &BatchAnnotateImagesResponse{
  987. ServerResponse: googleapi.ServerResponse{
  988. Header: res.Header,
  989. HTTPStatusCode: res.StatusCode,
  990. },
  991. }
  992. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  993. return nil, err
  994. }
  995. return ret, nil
  996. // {
  997. // "description": "Run image detection and annotation for a batch of images.",
  998. // "flatPath": "v1/images:annotate",
  999. // "httpMethod": "POST",
  1000. // "id": "vision.images.annotate",
  1001. // "parameterOrder": [],
  1002. // "parameters": {},
  1003. // "path": "v1/images:annotate",
  1004. // "request": {
  1005. // "$ref": "BatchAnnotateImagesRequest"
  1006. // },
  1007. // "response": {
  1008. // "$ref": "BatchAnnotateImagesResponse"
  1009. // },
  1010. // "scopes": [
  1011. // "https://www.googleapis.com/auth/cloud-platform"
  1012. // ]
  1013. // }
  1014. }