1// Copyright 2020 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 15// Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17package vision_test 18 19import ( 20 "context" 21 22 vision "cloud.google.com/go/vision/apiv1" 23 "google.golang.org/api/iterator" 24 visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 25) 26 27func ExampleNewProductSearchClient() { 28 ctx := context.Background() 29 c, err := vision.NewProductSearchClient(ctx) 30 if err != nil { 31 // TODO: Handle error. 32 } 33 // TODO: Use client. 34 _ = c 35} 36 37func ExampleProductSearchClient_CreateProductSet() { 38 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 39 40 ctx := context.Background() 41 c, err := vision.NewProductSearchClient(ctx) 42 if err != nil { 43 // TODO: Handle error. 44 } 45 46 req := &visionpb.CreateProductSetRequest{ 47 // TODO: Fill request struct fields. 48 } 49 resp, err := c.CreateProductSet(ctx, req) 50 if err != nil { 51 // TODO: Handle error. 52 } 53 // TODO: Use resp. 54 _ = resp 55} 56 57func ExampleProductSearchClient_ListProductSets() { 58 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 59 // import "google.golang.org/api/iterator" 60 61 ctx := context.Background() 62 c, err := vision.NewProductSearchClient(ctx) 63 if err != nil { 64 // TODO: Handle error. 65 } 66 67 req := &visionpb.ListProductSetsRequest{ 68 // TODO: Fill request struct fields. 69 } 70 it := c.ListProductSets(ctx, req) 71 for { 72 resp, err := it.Next() 73 if err == iterator.Done { 74 break 75 } 76 if err != nil { 77 // TODO: Handle error. 78 } 79 // TODO: Use resp. 80 _ = resp 81 } 82} 83 84func ExampleProductSearchClient_GetProductSet() { 85 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 86 87 ctx := context.Background() 88 c, err := vision.NewProductSearchClient(ctx) 89 if err != nil { 90 // TODO: Handle error. 91 } 92 93 req := &visionpb.GetProductSetRequest{ 94 // TODO: Fill request struct fields. 95 } 96 resp, err := c.GetProductSet(ctx, req) 97 if err != nil { 98 // TODO: Handle error. 99 } 100 // TODO: Use resp. 101 _ = resp 102} 103 104func ExampleProductSearchClient_UpdateProductSet() { 105 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 106 107 ctx := context.Background() 108 c, err := vision.NewProductSearchClient(ctx) 109 if err != nil { 110 // TODO: Handle error. 111 } 112 113 req := &visionpb.UpdateProductSetRequest{ 114 // TODO: Fill request struct fields. 115 } 116 resp, err := c.UpdateProductSet(ctx, req) 117 if err != nil { 118 // TODO: Handle error. 119 } 120 // TODO: Use resp. 121 _ = resp 122} 123 124func ExampleProductSearchClient_DeleteProductSet() { 125 ctx := context.Background() 126 c, err := vision.NewProductSearchClient(ctx) 127 if err != nil { 128 // TODO: Handle error. 129 } 130 131 req := &visionpb.DeleteProductSetRequest{ 132 // TODO: Fill request struct fields. 133 } 134 err = c.DeleteProductSet(ctx, req) 135 if err != nil { 136 // TODO: Handle error. 137 } 138} 139 140func ExampleProductSearchClient_CreateProduct() { 141 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 142 143 ctx := context.Background() 144 c, err := vision.NewProductSearchClient(ctx) 145 if err != nil { 146 // TODO: Handle error. 147 } 148 149 req := &visionpb.CreateProductRequest{ 150 // TODO: Fill request struct fields. 151 } 152 resp, err := c.CreateProduct(ctx, req) 153 if err != nil { 154 // TODO: Handle error. 155 } 156 // TODO: Use resp. 157 _ = resp 158} 159 160func ExampleProductSearchClient_ListProducts() { 161 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 162 // import "google.golang.org/api/iterator" 163 164 ctx := context.Background() 165 c, err := vision.NewProductSearchClient(ctx) 166 if err != nil { 167 // TODO: Handle error. 168 } 169 170 req := &visionpb.ListProductsRequest{ 171 // TODO: Fill request struct fields. 172 } 173 it := c.ListProducts(ctx, req) 174 for { 175 resp, err := it.Next() 176 if err == iterator.Done { 177 break 178 } 179 if err != nil { 180 // TODO: Handle error. 181 } 182 // TODO: Use resp. 183 _ = resp 184 } 185} 186 187func ExampleProductSearchClient_GetProduct() { 188 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 189 190 ctx := context.Background() 191 c, err := vision.NewProductSearchClient(ctx) 192 if err != nil { 193 // TODO: Handle error. 194 } 195 196 req := &visionpb.GetProductRequest{ 197 // TODO: Fill request struct fields. 198 } 199 resp, err := c.GetProduct(ctx, req) 200 if err != nil { 201 // TODO: Handle error. 202 } 203 // TODO: Use resp. 204 _ = resp 205} 206 207func ExampleProductSearchClient_UpdateProduct() { 208 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 209 210 ctx := context.Background() 211 c, err := vision.NewProductSearchClient(ctx) 212 if err != nil { 213 // TODO: Handle error. 214 } 215 216 req := &visionpb.UpdateProductRequest{ 217 // TODO: Fill request struct fields. 218 } 219 resp, err := c.UpdateProduct(ctx, req) 220 if err != nil { 221 // TODO: Handle error. 222 } 223 // TODO: Use resp. 224 _ = resp 225} 226 227func ExampleProductSearchClient_DeleteProduct() { 228 ctx := context.Background() 229 c, err := vision.NewProductSearchClient(ctx) 230 if err != nil { 231 // TODO: Handle error. 232 } 233 234 req := &visionpb.DeleteProductRequest{ 235 // TODO: Fill request struct fields. 236 } 237 err = c.DeleteProduct(ctx, req) 238 if err != nil { 239 // TODO: Handle error. 240 } 241} 242 243func ExampleProductSearchClient_CreateReferenceImage() { 244 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 245 246 ctx := context.Background() 247 c, err := vision.NewProductSearchClient(ctx) 248 if err != nil { 249 // TODO: Handle error. 250 } 251 252 req := &visionpb.CreateReferenceImageRequest{ 253 // TODO: Fill request struct fields. 254 } 255 resp, err := c.CreateReferenceImage(ctx, req) 256 if err != nil { 257 // TODO: Handle error. 258 } 259 // TODO: Use resp. 260 _ = resp 261} 262 263func ExampleProductSearchClient_DeleteReferenceImage() { 264 ctx := context.Background() 265 c, err := vision.NewProductSearchClient(ctx) 266 if err != nil { 267 // TODO: Handle error. 268 } 269 270 req := &visionpb.DeleteReferenceImageRequest{ 271 // TODO: Fill request struct fields. 272 } 273 err = c.DeleteReferenceImage(ctx, req) 274 if err != nil { 275 // TODO: Handle error. 276 } 277} 278 279func ExampleProductSearchClient_ListReferenceImages() { 280 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 281 // import "google.golang.org/api/iterator" 282 283 ctx := context.Background() 284 c, err := vision.NewProductSearchClient(ctx) 285 if err != nil { 286 // TODO: Handle error. 287 } 288 289 req := &visionpb.ListReferenceImagesRequest{ 290 // TODO: Fill request struct fields. 291 } 292 it := c.ListReferenceImages(ctx, req) 293 for { 294 resp, err := it.Next() 295 if err == iterator.Done { 296 break 297 } 298 if err != nil { 299 // TODO: Handle error. 300 } 301 // TODO: Use resp. 302 _ = resp 303 } 304} 305 306func ExampleProductSearchClient_GetReferenceImage() { 307 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 308 309 ctx := context.Background() 310 c, err := vision.NewProductSearchClient(ctx) 311 if err != nil { 312 // TODO: Handle error. 313 } 314 315 req := &visionpb.GetReferenceImageRequest{ 316 // TODO: Fill request struct fields. 317 } 318 resp, err := c.GetReferenceImage(ctx, req) 319 if err != nil { 320 // TODO: Handle error. 321 } 322 // TODO: Use resp. 323 _ = resp 324} 325 326func ExampleProductSearchClient_AddProductToProductSet() { 327 ctx := context.Background() 328 c, err := vision.NewProductSearchClient(ctx) 329 if err != nil { 330 // TODO: Handle error. 331 } 332 333 req := &visionpb.AddProductToProductSetRequest{ 334 // TODO: Fill request struct fields. 335 } 336 err = c.AddProductToProductSet(ctx, req) 337 if err != nil { 338 // TODO: Handle error. 339 } 340} 341 342func ExampleProductSearchClient_RemoveProductFromProductSet() { 343 ctx := context.Background() 344 c, err := vision.NewProductSearchClient(ctx) 345 if err != nil { 346 // TODO: Handle error. 347 } 348 349 req := &visionpb.RemoveProductFromProductSetRequest{ 350 // TODO: Fill request struct fields. 351 } 352 err = c.RemoveProductFromProductSet(ctx, req) 353 if err != nil { 354 // TODO: Handle error. 355 } 356} 357 358func ExampleProductSearchClient_ListProductsInProductSet() { 359 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 360 // import "google.golang.org/api/iterator" 361 362 ctx := context.Background() 363 c, err := vision.NewProductSearchClient(ctx) 364 if err != nil { 365 // TODO: Handle error. 366 } 367 368 req := &visionpb.ListProductsInProductSetRequest{ 369 // TODO: Fill request struct fields. 370 } 371 it := c.ListProductsInProductSet(ctx, req) 372 for { 373 resp, err := it.Next() 374 if err == iterator.Done { 375 break 376 } 377 if err != nil { 378 // TODO: Handle error. 379 } 380 // TODO: Use resp. 381 _ = resp 382 } 383} 384 385func ExampleProductSearchClient_ImportProductSets() { 386 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 387 388 ctx := context.Background() 389 c, err := vision.NewProductSearchClient(ctx) 390 if err != nil { 391 // TODO: Handle error. 392 } 393 394 req := &visionpb.ImportProductSetsRequest{ 395 // TODO: Fill request struct fields. 396 } 397 op, err := c.ImportProductSets(ctx, req) 398 if err != nil { 399 // TODO: Handle error. 400 } 401 402 resp, err := op.Wait(ctx) 403 if err != nil { 404 // TODO: Handle error. 405 } 406 // TODO: Use resp. 407 _ = resp 408} 409 410func ExampleProductSearchClient_PurgeProducts() { 411 // import visionpb "google.golang.org/genproto/googleapis/cloud/vision/v1" 412 413 ctx := context.Background() 414 c, err := vision.NewProductSearchClient(ctx) 415 if err != nil { 416 // TODO: Handle error. 417 } 418 419 req := &visionpb.PurgeProductsRequest{ 420 // TODO: Fill request struct fields. 421 } 422 op, err := c.PurgeProducts(ctx, req) 423 if err != nil { 424 // TODO: Handle error. 425 } 426 427 err = op.Wait(ctx) 428 if err != nil { 429 // TODO: Handle error. 430 } 431} 432