Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

379 righe
7.9 KiB

  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. package vision_test
  16. import (
  17. "context"
  18. vision "cloud.google.com/go/vision/apiv1"
  19. "google.golang.org/api/iterator"
  20. visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1"
  21. )
  22. func ExampleNewProductSearchClient() {
  23. ctx := context.Background()
  24. c, err := vision.NewProductSearchClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExampleProductSearchClient_CreateProduct() {
  32. ctx := context.Background()
  33. c, err := vision.NewProductSearchClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &visionpb.CreateProductRequest{
  38. // TODO: Fill request struct fields.
  39. }
  40. resp, err := c.CreateProduct(ctx, req)
  41. if err != nil {
  42. // TODO: Handle error.
  43. }
  44. // TODO: Use resp.
  45. _ = resp
  46. }
  47. func ExampleProductSearchClient_ListProducts() {
  48. ctx := context.Background()
  49. c, err := vision.NewProductSearchClient(ctx)
  50. if err != nil {
  51. // TODO: Handle error.
  52. }
  53. req := &visionpb.ListProductsRequest{
  54. // TODO: Fill request struct fields.
  55. }
  56. it := c.ListProducts(ctx, req)
  57. for {
  58. resp, err := it.Next()
  59. if err == iterator.Done {
  60. break
  61. }
  62. if err != nil {
  63. // TODO: Handle error.
  64. }
  65. // TODO: Use resp.
  66. _ = resp
  67. }
  68. }
  69. func ExampleProductSearchClient_GetProduct() {
  70. ctx := context.Background()
  71. c, err := vision.NewProductSearchClient(ctx)
  72. if err != nil {
  73. // TODO: Handle error.
  74. }
  75. req := &visionpb.GetProductRequest{
  76. // TODO: Fill request struct fields.
  77. }
  78. resp, err := c.GetProduct(ctx, req)
  79. if err != nil {
  80. // TODO: Handle error.
  81. }
  82. // TODO: Use resp.
  83. _ = resp
  84. }
  85. func ExampleProductSearchClient_UpdateProduct() {
  86. ctx := context.Background()
  87. c, err := vision.NewProductSearchClient(ctx)
  88. if err != nil {
  89. // TODO: Handle error.
  90. }
  91. req := &visionpb.UpdateProductRequest{
  92. // TODO: Fill request struct fields.
  93. }
  94. resp, err := c.UpdateProduct(ctx, req)
  95. if err != nil {
  96. // TODO: Handle error.
  97. }
  98. // TODO: Use resp.
  99. _ = resp
  100. }
  101. func ExampleProductSearchClient_DeleteProduct() {
  102. ctx := context.Background()
  103. c, err := vision.NewProductSearchClient(ctx)
  104. if err != nil {
  105. // TODO: Handle error.
  106. }
  107. req := &visionpb.DeleteProductRequest{
  108. // TODO: Fill request struct fields.
  109. }
  110. err = c.DeleteProduct(ctx, req)
  111. if err != nil {
  112. // TODO: Handle error.
  113. }
  114. }
  115. func ExampleProductSearchClient_ListReferenceImages() {
  116. ctx := context.Background()
  117. c, err := vision.NewProductSearchClient(ctx)
  118. if err != nil {
  119. // TODO: Handle error.
  120. }
  121. req := &visionpb.ListReferenceImagesRequest{
  122. // TODO: Fill request struct fields.
  123. }
  124. it := c.ListReferenceImages(ctx, req)
  125. for {
  126. resp, err := it.Next()
  127. if err == iterator.Done {
  128. break
  129. }
  130. if err != nil {
  131. // TODO: Handle error.
  132. }
  133. // TODO: Use resp.
  134. _ = resp
  135. }
  136. }
  137. func ExampleProductSearchClient_GetReferenceImage() {
  138. ctx := context.Background()
  139. c, err := vision.NewProductSearchClient(ctx)
  140. if err != nil {
  141. // TODO: Handle error.
  142. }
  143. req := &visionpb.GetReferenceImageRequest{
  144. // TODO: Fill request struct fields.
  145. }
  146. resp, err := c.GetReferenceImage(ctx, req)
  147. if err != nil {
  148. // TODO: Handle error.
  149. }
  150. // TODO: Use resp.
  151. _ = resp
  152. }
  153. func ExampleProductSearchClient_DeleteReferenceImage() {
  154. ctx := context.Background()
  155. c, err := vision.NewProductSearchClient(ctx)
  156. if err != nil {
  157. // TODO: Handle error.
  158. }
  159. req := &visionpb.DeleteReferenceImageRequest{
  160. // TODO: Fill request struct fields.
  161. }
  162. err = c.DeleteReferenceImage(ctx, req)
  163. if err != nil {
  164. // TODO: Handle error.
  165. }
  166. }
  167. func ExampleProductSearchClient_CreateReferenceImage() {
  168. ctx := context.Background()
  169. c, err := vision.NewProductSearchClient(ctx)
  170. if err != nil {
  171. // TODO: Handle error.
  172. }
  173. req := &visionpb.CreateReferenceImageRequest{
  174. // TODO: Fill request struct fields.
  175. }
  176. resp, err := c.CreateReferenceImage(ctx, req)
  177. if err != nil {
  178. // TODO: Handle error.
  179. }
  180. // TODO: Use resp.
  181. _ = resp
  182. }
  183. func ExampleProductSearchClient_CreateProductSet() {
  184. ctx := context.Background()
  185. c, err := vision.NewProductSearchClient(ctx)
  186. if err != nil {
  187. // TODO: Handle error.
  188. }
  189. req := &visionpb.CreateProductSetRequest{
  190. // TODO: Fill request struct fields.
  191. }
  192. resp, err := c.CreateProductSet(ctx, req)
  193. if err != nil {
  194. // TODO: Handle error.
  195. }
  196. // TODO: Use resp.
  197. _ = resp
  198. }
  199. func ExampleProductSearchClient_ListProductSets() {
  200. ctx := context.Background()
  201. c, err := vision.NewProductSearchClient(ctx)
  202. if err != nil {
  203. // TODO: Handle error.
  204. }
  205. req := &visionpb.ListProductSetsRequest{
  206. // TODO: Fill request struct fields.
  207. }
  208. it := c.ListProductSets(ctx, req)
  209. for {
  210. resp, err := it.Next()
  211. if err == iterator.Done {
  212. break
  213. }
  214. if err != nil {
  215. // TODO: Handle error.
  216. }
  217. // TODO: Use resp.
  218. _ = resp
  219. }
  220. }
  221. func ExampleProductSearchClient_GetProductSet() {
  222. ctx := context.Background()
  223. c, err := vision.NewProductSearchClient(ctx)
  224. if err != nil {
  225. // TODO: Handle error.
  226. }
  227. req := &visionpb.GetProductSetRequest{
  228. // TODO: Fill request struct fields.
  229. }
  230. resp, err := c.GetProductSet(ctx, req)
  231. if err != nil {
  232. // TODO: Handle error.
  233. }
  234. // TODO: Use resp.
  235. _ = resp
  236. }
  237. func ExampleProductSearchClient_UpdateProductSet() {
  238. ctx := context.Background()
  239. c, err := vision.NewProductSearchClient(ctx)
  240. if err != nil {
  241. // TODO: Handle error.
  242. }
  243. req := &visionpb.UpdateProductSetRequest{
  244. // TODO: Fill request struct fields.
  245. }
  246. resp, err := c.UpdateProductSet(ctx, req)
  247. if err != nil {
  248. // TODO: Handle error.
  249. }
  250. // TODO: Use resp.
  251. _ = resp
  252. }
  253. func ExampleProductSearchClient_DeleteProductSet() {
  254. ctx := context.Background()
  255. c, err := vision.NewProductSearchClient(ctx)
  256. if err != nil {
  257. // TODO: Handle error.
  258. }
  259. req := &visionpb.DeleteProductSetRequest{
  260. // TODO: Fill request struct fields.
  261. }
  262. err = c.DeleteProductSet(ctx, req)
  263. if err != nil {
  264. // TODO: Handle error.
  265. }
  266. }
  267. func ExampleProductSearchClient_AddProductToProductSet() {
  268. ctx := context.Background()
  269. c, err := vision.NewProductSearchClient(ctx)
  270. if err != nil {
  271. // TODO: Handle error.
  272. }
  273. req := &visionpb.AddProductToProductSetRequest{
  274. // TODO: Fill request struct fields.
  275. }
  276. err = c.AddProductToProductSet(ctx, req)
  277. if err != nil {
  278. // TODO: Handle error.
  279. }
  280. }
  281. func ExampleProductSearchClient_RemoveProductFromProductSet() {
  282. ctx := context.Background()
  283. c, err := vision.NewProductSearchClient(ctx)
  284. if err != nil {
  285. // TODO: Handle error.
  286. }
  287. req := &visionpb.RemoveProductFromProductSetRequest{
  288. // TODO: Fill request struct fields.
  289. }
  290. err = c.RemoveProductFromProductSet(ctx, req)
  291. if err != nil {
  292. // TODO: Handle error.
  293. }
  294. }
  295. func ExampleProductSearchClient_ListProductsInProductSet() {
  296. ctx := context.Background()
  297. c, err := vision.NewProductSearchClient(ctx)
  298. if err != nil {
  299. // TODO: Handle error.
  300. }
  301. req := &visionpb.ListProductsInProductSetRequest{
  302. // TODO: Fill request struct fields.
  303. }
  304. it := c.ListProductsInProductSet(ctx, req)
  305. for {
  306. resp, err := it.Next()
  307. if err == iterator.Done {
  308. break
  309. }
  310. if err != nil {
  311. // TODO: Handle error.
  312. }
  313. // TODO: Use resp.
  314. _ = resp
  315. }
  316. }
  317. func ExampleProductSearchClient_ImportProductSets() {
  318. ctx := context.Background()
  319. c, err := vision.NewProductSearchClient(ctx)
  320. if err != nil {
  321. // TODO: Handle error.
  322. }
  323. req := &visionpb.ImportProductSetsRequest{
  324. // TODO: Fill request struct fields.
  325. }
  326. op, err := c.ImportProductSets(ctx, req)
  327. if err != nil {
  328. // TODO: Handle error.
  329. }
  330. resp, err := op.Wait(ctx)
  331. if err != nil {
  332. // TODO: Handle error.
  333. }
  334. // TODO: Use resp.
  335. _ = resp
  336. }