1 // Copyright 2024 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 17 package dataexchange_test 18 19 import ( 20 "context" 21 22 dataexchange "cloud.google.com/go/bigquery/dataexchange/apiv1beta1" 23 dataexchangepb "cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb" 24 iampb "cloud.google.com/go/iam/apiv1/iampb" 25 "google.golang.org/api/iterator" 26 locationpb "google.golang.org/genproto/googleapis/cloud/location" 27 ) 28 29 func ExampleNewAnalyticsHubClient() { 30 ctx := context.Background() 31 // This snippet has been automatically generated and should be regarded as a code template only. 32 // It will require modifications to work: 33 // - It may require correct/in-range values for request initialization. 34 // - It may require specifying regional endpoints when creating the service client as shown in: 35 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 36 c, err := dataexchange.NewAnalyticsHubClient(ctx) 37 if err != nil { 38 // TODO: Handle error. 39 } 40 defer c.Close() 41 42 // TODO: Use client. 43 _ = c 44 } 45 46 func ExampleNewAnalyticsHubRESTClient() { 47 ctx := context.Background() 48 // This snippet has been automatically generated and should be regarded as a code template only. 49 // It will require modifications to work: 50 // - It may require correct/in-range values for request initialization. 51 // - It may require specifying regional endpoints when creating the service client as shown in: 52 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 53 c, err := dataexchange.NewAnalyticsHubRESTClient(ctx) 54 if err != nil { 55 // TODO: Handle error. 56 } 57 defer c.Close() 58 59 // TODO: Use client. 60 _ = c 61 } 62 63 func ExampleAnalyticsHubClient_CreateDataExchange() { 64 ctx := context.Background() 65 // This snippet has been automatically generated and should be regarded as a code template only. 66 // It will require modifications to work: 67 // - It may require correct/in-range values for request initialization. 68 // - It may require specifying regional endpoints when creating the service client as shown in: 69 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 70 c, err := dataexchange.NewAnalyticsHubClient(ctx) 71 if err != nil { 72 // TODO: Handle error. 73 } 74 defer c.Close() 75 76 req := &dataexchangepb.CreateDataExchangeRequest{ 77 // TODO: Fill request struct fields. 78 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#CreateDataExchangeRequest. 79 } 80 resp, err := c.CreateDataExchange(ctx, req) 81 if err != nil { 82 // TODO: Handle error. 83 } 84 // TODO: Use resp. 85 _ = resp 86 } 87 88 func ExampleAnalyticsHubClient_CreateListing() { 89 ctx := context.Background() 90 // This snippet has been automatically generated and should be regarded as a code template only. 91 // It will require modifications to work: 92 // - It may require correct/in-range values for request initialization. 93 // - It may require specifying regional endpoints when creating the service client as shown in: 94 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 95 c, err := dataexchange.NewAnalyticsHubClient(ctx) 96 if err != nil { 97 // TODO: Handle error. 98 } 99 defer c.Close() 100 101 req := &dataexchangepb.CreateListingRequest{ 102 // TODO: Fill request struct fields. 103 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#CreateListingRequest. 104 } 105 resp, err := c.CreateListing(ctx, req) 106 if err != nil { 107 // TODO: Handle error. 108 } 109 // TODO: Use resp. 110 _ = resp 111 } 112 113 func ExampleAnalyticsHubClient_DeleteDataExchange() { 114 ctx := context.Background() 115 // This snippet has been automatically generated and should be regarded as a code template only. 116 // It will require modifications to work: 117 // - It may require correct/in-range values for request initialization. 118 // - It may require specifying regional endpoints when creating the service client as shown in: 119 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 120 c, err := dataexchange.NewAnalyticsHubClient(ctx) 121 if err != nil { 122 // TODO: Handle error. 123 } 124 defer c.Close() 125 126 req := &dataexchangepb.DeleteDataExchangeRequest{ 127 // TODO: Fill request struct fields. 128 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#DeleteDataExchangeRequest. 129 } 130 err = c.DeleteDataExchange(ctx, req) 131 if err != nil { 132 // TODO: Handle error. 133 } 134 } 135 136 func ExampleAnalyticsHubClient_DeleteListing() { 137 ctx := context.Background() 138 // This snippet has been automatically generated and should be regarded as a code template only. 139 // It will require modifications to work: 140 // - It may require correct/in-range values for request initialization. 141 // - It may require specifying regional endpoints when creating the service client as shown in: 142 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 143 c, err := dataexchange.NewAnalyticsHubClient(ctx) 144 if err != nil { 145 // TODO: Handle error. 146 } 147 defer c.Close() 148 149 req := &dataexchangepb.DeleteListingRequest{ 150 // TODO: Fill request struct fields. 151 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#DeleteListingRequest. 152 } 153 err = c.DeleteListing(ctx, req) 154 if err != nil { 155 // TODO: Handle error. 156 } 157 } 158 159 func ExampleAnalyticsHubClient_GetDataExchange() { 160 ctx := context.Background() 161 // This snippet has been automatically generated and should be regarded as a code template only. 162 // It will require modifications to work: 163 // - It may require correct/in-range values for request initialization. 164 // - It may require specifying regional endpoints when creating the service client as shown in: 165 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 166 c, err := dataexchange.NewAnalyticsHubClient(ctx) 167 if err != nil { 168 // TODO: Handle error. 169 } 170 defer c.Close() 171 172 req := &dataexchangepb.GetDataExchangeRequest{ 173 // TODO: Fill request struct fields. 174 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#GetDataExchangeRequest. 175 } 176 resp, err := c.GetDataExchange(ctx, req) 177 if err != nil { 178 // TODO: Handle error. 179 } 180 // TODO: Use resp. 181 _ = resp 182 } 183 184 func ExampleAnalyticsHubClient_GetIamPolicy() { 185 ctx := context.Background() 186 // This snippet has been automatically generated and should be regarded as a code template only. 187 // It will require modifications to work: 188 // - It may require correct/in-range values for request initialization. 189 // - It may require specifying regional endpoints when creating the service client as shown in: 190 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 191 c, err := dataexchange.NewAnalyticsHubClient(ctx) 192 if err != nil { 193 // TODO: Handle error. 194 } 195 defer c.Close() 196 197 req := &iampb.GetIamPolicyRequest{ 198 // TODO: Fill request struct fields. 199 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. 200 } 201 resp, err := c.GetIamPolicy(ctx, req) 202 if err != nil { 203 // TODO: Handle error. 204 } 205 // TODO: Use resp. 206 _ = resp 207 } 208 209 func ExampleAnalyticsHubClient_GetListing() { 210 ctx := context.Background() 211 // This snippet has been automatically generated and should be regarded as a code template only. 212 // It will require modifications to work: 213 // - It may require correct/in-range values for request initialization. 214 // - It may require specifying regional endpoints when creating the service client as shown in: 215 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 216 c, err := dataexchange.NewAnalyticsHubClient(ctx) 217 if err != nil { 218 // TODO: Handle error. 219 } 220 defer c.Close() 221 222 req := &dataexchangepb.GetListingRequest{ 223 // TODO: Fill request struct fields. 224 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#GetListingRequest. 225 } 226 resp, err := c.GetListing(ctx, req) 227 if err != nil { 228 // TODO: Handle error. 229 } 230 // TODO: Use resp. 231 _ = resp 232 } 233 234 func ExampleAnalyticsHubClient_ListDataExchanges() { 235 ctx := context.Background() 236 // This snippet has been automatically generated and should be regarded as a code template only. 237 // It will require modifications to work: 238 // - It may require correct/in-range values for request initialization. 239 // - It may require specifying regional endpoints when creating the service client as shown in: 240 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 241 c, err := dataexchange.NewAnalyticsHubClient(ctx) 242 if err != nil { 243 // TODO: Handle error. 244 } 245 defer c.Close() 246 247 req := &dataexchangepb.ListDataExchangesRequest{ 248 // TODO: Fill request struct fields. 249 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#ListDataExchangesRequest. 250 } 251 it := c.ListDataExchanges(ctx, req) 252 for { 253 resp, err := it.Next() 254 if err == iterator.Done { 255 break 256 } 257 if err != nil { 258 // TODO: Handle error. 259 } 260 // TODO: Use resp. 261 _ = resp 262 263 // If you need to access the underlying RPC response, 264 // you can do so by casting the `Response` as below. 265 // Otherwise, remove this line. Only populated after 266 // first call to Next(). Not safe for concurrent access. 267 _ = it.Response.(*dataexchangepb.ListDataExchangesResponse) 268 } 269 } 270 271 func ExampleAnalyticsHubClient_ListListings() { 272 ctx := context.Background() 273 // This snippet has been automatically generated and should be regarded as a code template only. 274 // It will require modifications to work: 275 // - It may require correct/in-range values for request initialization. 276 // - It may require specifying regional endpoints when creating the service client as shown in: 277 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 278 c, err := dataexchange.NewAnalyticsHubClient(ctx) 279 if err != nil { 280 // TODO: Handle error. 281 } 282 defer c.Close() 283 284 req := &dataexchangepb.ListListingsRequest{ 285 // TODO: Fill request struct fields. 286 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#ListListingsRequest. 287 } 288 it := c.ListListings(ctx, req) 289 for { 290 resp, err := it.Next() 291 if err == iterator.Done { 292 break 293 } 294 if err != nil { 295 // TODO: Handle error. 296 } 297 // TODO: Use resp. 298 _ = resp 299 300 // If you need to access the underlying RPC response, 301 // you can do so by casting the `Response` as below. 302 // Otherwise, remove this line. Only populated after 303 // first call to Next(). Not safe for concurrent access. 304 _ = it.Response.(*dataexchangepb.ListListingsResponse) 305 } 306 } 307 308 func ExampleAnalyticsHubClient_ListOrgDataExchanges() { 309 ctx := context.Background() 310 // This snippet has been automatically generated and should be regarded as a code template only. 311 // It will require modifications to work: 312 // - It may require correct/in-range values for request initialization. 313 // - It may require specifying regional endpoints when creating the service client as shown in: 314 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 315 c, err := dataexchange.NewAnalyticsHubClient(ctx) 316 if err != nil { 317 // TODO: Handle error. 318 } 319 defer c.Close() 320 321 req := &dataexchangepb.ListOrgDataExchangesRequest{ 322 // TODO: Fill request struct fields. 323 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#ListOrgDataExchangesRequest. 324 } 325 it := c.ListOrgDataExchanges(ctx, req) 326 for { 327 resp, err := it.Next() 328 if err == iterator.Done { 329 break 330 } 331 if err != nil { 332 // TODO: Handle error. 333 } 334 // TODO: Use resp. 335 _ = resp 336 337 // If you need to access the underlying RPC response, 338 // you can do so by casting the `Response` as below. 339 // Otherwise, remove this line. Only populated after 340 // first call to Next(). Not safe for concurrent access. 341 _ = it.Response.(*dataexchangepb.ListOrgDataExchangesResponse) 342 } 343 } 344 345 func ExampleAnalyticsHubClient_SetIamPolicy() { 346 ctx := context.Background() 347 // This snippet has been automatically generated and should be regarded as a code template only. 348 // It will require modifications to work: 349 // - It may require correct/in-range values for request initialization. 350 // - It may require specifying regional endpoints when creating the service client as shown in: 351 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 352 c, err := dataexchange.NewAnalyticsHubClient(ctx) 353 if err != nil { 354 // TODO: Handle error. 355 } 356 defer c.Close() 357 358 req := &iampb.SetIamPolicyRequest{ 359 // TODO: Fill request struct fields. 360 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. 361 } 362 resp, err := c.SetIamPolicy(ctx, req) 363 if err != nil { 364 // TODO: Handle error. 365 } 366 // TODO: Use resp. 367 _ = resp 368 } 369 370 func ExampleAnalyticsHubClient_SubscribeListing() { 371 ctx := context.Background() 372 // This snippet has been automatically generated and should be regarded as a code template only. 373 // It will require modifications to work: 374 // - It may require correct/in-range values for request initialization. 375 // - It may require specifying regional endpoints when creating the service client as shown in: 376 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 377 c, err := dataexchange.NewAnalyticsHubClient(ctx) 378 if err != nil { 379 // TODO: Handle error. 380 } 381 defer c.Close() 382 383 req := &dataexchangepb.SubscribeListingRequest{ 384 // TODO: Fill request struct fields. 385 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#SubscribeListingRequest. 386 } 387 resp, err := c.SubscribeListing(ctx, req) 388 if err != nil { 389 // TODO: Handle error. 390 } 391 // TODO: Use resp. 392 _ = resp 393 } 394 395 func ExampleAnalyticsHubClient_TestIamPermissions() { 396 ctx := context.Background() 397 // This snippet has been automatically generated and should be regarded as a code template only. 398 // It will require modifications to work: 399 // - It may require correct/in-range values for request initialization. 400 // - It may require specifying regional endpoints when creating the service client as shown in: 401 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 402 c, err := dataexchange.NewAnalyticsHubClient(ctx) 403 if err != nil { 404 // TODO: Handle error. 405 } 406 defer c.Close() 407 408 req := &iampb.TestIamPermissionsRequest{ 409 // TODO: Fill request struct fields. 410 // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. 411 } 412 resp, err := c.TestIamPermissions(ctx, req) 413 if err != nil { 414 // TODO: Handle error. 415 } 416 // TODO: Use resp. 417 _ = resp 418 } 419 420 func ExampleAnalyticsHubClient_UpdateDataExchange() { 421 ctx := context.Background() 422 // This snippet has been automatically generated and should be regarded as a code template only. 423 // It will require modifications to work: 424 // - It may require correct/in-range values for request initialization. 425 // - It may require specifying regional endpoints when creating the service client as shown in: 426 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 427 c, err := dataexchange.NewAnalyticsHubClient(ctx) 428 if err != nil { 429 // TODO: Handle error. 430 } 431 defer c.Close() 432 433 req := &dataexchangepb.UpdateDataExchangeRequest{ 434 // TODO: Fill request struct fields. 435 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#UpdateDataExchangeRequest. 436 } 437 resp, err := c.UpdateDataExchange(ctx, req) 438 if err != nil { 439 // TODO: Handle error. 440 } 441 // TODO: Use resp. 442 _ = resp 443 } 444 445 func ExampleAnalyticsHubClient_UpdateListing() { 446 ctx := context.Background() 447 // This snippet has been automatically generated and should be regarded as a code template only. 448 // It will require modifications to work: 449 // - It may require correct/in-range values for request initialization. 450 // - It may require specifying regional endpoints when creating the service client as shown in: 451 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 452 c, err := dataexchange.NewAnalyticsHubClient(ctx) 453 if err != nil { 454 // TODO: Handle error. 455 } 456 defer c.Close() 457 458 req := &dataexchangepb.UpdateListingRequest{ 459 // TODO: Fill request struct fields. 460 // See https://pkg.go.dev/cloud.google.com/go/bigquery/dataexchange/apiv1beta1/dataexchangepb#UpdateListingRequest. 461 } 462 resp, err := c.UpdateListing(ctx, req) 463 if err != nil { 464 // TODO: Handle error. 465 } 466 // TODO: Use resp. 467 _ = resp 468 } 469 470 func ExampleAnalyticsHubClient_GetLocation() { 471 ctx := context.Background() 472 // This snippet has been automatically generated and should be regarded as a code template only. 473 // It will require modifications to work: 474 // - It may require correct/in-range values for request initialization. 475 // - It may require specifying regional endpoints when creating the service client as shown in: 476 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 477 c, err := dataexchange.NewAnalyticsHubClient(ctx) 478 if err != nil { 479 // TODO: Handle error. 480 } 481 defer c.Close() 482 483 req := &locationpb.GetLocationRequest{ 484 // TODO: Fill request struct fields. 485 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. 486 } 487 resp, err := c.GetLocation(ctx, req) 488 if err != nil { 489 // TODO: Handle error. 490 } 491 // TODO: Use resp. 492 _ = resp 493 } 494 495 func ExampleAnalyticsHubClient_ListLocations() { 496 ctx := context.Background() 497 // This snippet has been automatically generated and should be regarded as a code template only. 498 // It will require modifications to work: 499 // - It may require correct/in-range values for request initialization. 500 // - It may require specifying regional endpoints when creating the service client as shown in: 501 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 502 c, err := dataexchange.NewAnalyticsHubClient(ctx) 503 if err != nil { 504 // TODO: Handle error. 505 } 506 defer c.Close() 507 508 req := &locationpb.ListLocationsRequest{ 509 // TODO: Fill request struct fields. 510 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. 511 } 512 it := c.ListLocations(ctx, req) 513 for { 514 resp, err := it.Next() 515 if err == iterator.Done { 516 break 517 } 518 if err != nil { 519 // TODO: Handle error. 520 } 521 // TODO: Use resp. 522 _ = resp 523 524 // If you need to access the underlying RPC response, 525 // you can do so by casting the `Response` as below. 526 // Otherwise, remove this line. Only populated after 527 // first call to Next(). Not safe for concurrent access. 528 _ = it.Response.(*locationpb.ListLocationsResponse) 529 } 530 } 531