| 1 |
// Copyright 2025 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 pubsub_test |
| 18 |
|
| 19 |
import ( |
| 20 |
"context" |
| 21 |
"io" |
| 22 |
|
| 23 |
iampb "cloud.google.com/go/iam/apiv1/iampb" |
| 24 |
pubsub "cloud.google.com/go/pubsub/v2/apiv1" |
| 25 |
pubsubpb "cloud.google.com/go/pubsub/v2/apiv1/pubsubpb" |
| 26 |
"google.golang.org/api/iterator" |
| 27 |
) |
| 28 |
|
| 29 |
func ExampleNewSubscriptionAdminClient() { |
| 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 := pubsub.NewSubscriptionAdminClient(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 ExampleNewSubscriptionAdminRESTClient() { |
| 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 := pubsub.NewSubscriptionAdminRESTClient(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 ExampleSubscriptionAdminClient_Acknowledge() { |
| 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 := pubsub.NewSubscriptionAdminClient(ctx) |
| 71 |
if err != nil { |
| 72 |
// TODO: Handle error. |
| 73 |
} |
| 74 |
defer c.Close() |
| 75 |
|
| 76 |
req := &pubsubpb.AcknowledgeRequest{ |
| 77 |
// TODO: Fill request struct fields. |
| 78 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#AcknowledgeRequest. |
| 79 |
} |
| 80 |
err = c.Acknowledge(ctx, req) |
| 81 |
if err != nil { |
| 82 |
// TODO: Handle error. |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
func ExampleSubscriptionAdminClient_CreateSnapshot() { |
| 87 |
ctx := context.Background() |
| 88 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 89 |
// It will require modifications to work: |
| 90 |
// - It may require correct/in-range values for request initialization. |
| 91 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 92 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 93 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 94 |
if err != nil { |
| 95 |
// TODO: Handle error. |
| 96 |
} |
| 97 |
defer c.Close() |
| 98 |
|
| 99 |
req := &pubsubpb.CreateSnapshotRequest{ |
| 100 |
// TODO: Fill request struct fields. |
| 101 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#CreateSnapshotRequest. |
| 102 |
} |
| 103 |
resp, err := c.CreateSnapshot(ctx, req) |
| 104 |
if err != nil { |
| 105 |
// TODO: Handle error. |
| 106 |
} |
| 107 |
// TODO: Use resp. |
| 108 |
_ = resp |
| 109 |
} |
| 110 |
|
| 111 |
func ExampleSubscriptionAdminClient_CreateSubscription() { |
| 112 |
ctx := context.Background() |
| 113 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 114 |
// It will require modifications to work: |
| 115 |
// - It may require correct/in-range values for request initialization. |
| 116 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 117 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 118 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 119 |
if err != nil { |
| 120 |
// TODO: Handle error. |
| 121 |
} |
| 122 |
defer c.Close() |
| 123 |
|
| 124 |
req := &pubsubpb.Subscription{ |
| 125 |
// TODO: Fill request struct fields. |
| 126 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#Subscription. |
| 127 |
} |
| 128 |
resp, err := c.CreateSubscription(ctx, req) |
| 129 |
if err != nil { |
| 130 |
// TODO: Handle error. |
| 131 |
} |
| 132 |
// TODO: Use resp. |
| 133 |
_ = resp |
| 134 |
} |
| 135 |
|
| 136 |
func ExampleSubscriptionAdminClient_DeleteSnapshot() { |
| 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 := pubsub.NewSubscriptionAdminClient(ctx) |
| 144 |
if err != nil { |
| 145 |
// TODO: Handle error. |
| 146 |
} |
| 147 |
defer c.Close() |
| 148 |
|
| 149 |
req := &pubsubpb.DeleteSnapshotRequest{ |
| 150 |
// TODO: Fill request struct fields. |
| 151 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#DeleteSnapshotRequest. |
| 152 |
} |
| 153 |
err = c.DeleteSnapshot(ctx, req) |
| 154 |
if err != nil { |
| 155 |
// TODO: Handle error. |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
func ExampleSubscriptionAdminClient_DeleteSubscription() { |
| 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 := pubsub.NewSubscriptionAdminClient(ctx) |
| 167 |
if err != nil { |
| 168 |
// TODO: Handle error. |
| 169 |
} |
| 170 |
defer c.Close() |
| 171 |
|
| 172 |
req := &pubsubpb.DeleteSubscriptionRequest{ |
| 173 |
// TODO: Fill request struct fields. |
| 174 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#DeleteSubscriptionRequest. |
| 175 |
} |
| 176 |
err = c.DeleteSubscription(ctx, req) |
| 177 |
if err != nil { |
| 178 |
// TODO: Handle error. |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
func ExampleSubscriptionAdminClient_GetSnapshot() { |
| 183 |
ctx := context.Background() |
| 184 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 185 |
// It will require modifications to work: |
| 186 |
// - It may require correct/in-range values for request initialization. |
| 187 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 188 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 189 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 190 |
if err != nil { |
| 191 |
// TODO: Handle error. |
| 192 |
} |
| 193 |
defer c.Close() |
| 194 |
|
| 195 |
req := &pubsubpb.GetSnapshotRequest{ |
| 196 |
// TODO: Fill request struct fields. |
| 197 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#GetSnapshotRequest. |
| 198 |
} |
| 199 |
resp, err := c.GetSnapshot(ctx, req) |
| 200 |
if err != nil { |
| 201 |
// TODO: Handle error. |
| 202 |
} |
| 203 |
// TODO: Use resp. |
| 204 |
_ = resp |
| 205 |
} |
| 206 |
|
| 207 |
func ExampleSubscriptionAdminClient_GetSubscription() { |
| 208 |
ctx := context.Background() |
| 209 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 210 |
// It will require modifications to work: |
| 211 |
// - It may require correct/in-range values for request initialization. |
| 212 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 213 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 214 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 215 |
if err != nil { |
| 216 |
// TODO: Handle error. |
| 217 |
} |
| 218 |
defer c.Close() |
| 219 |
|
| 220 |
req := &pubsubpb.GetSubscriptionRequest{ |
| 221 |
// TODO: Fill request struct fields. |
| 222 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#GetSubscriptionRequest. |
| 223 |
} |
| 224 |
resp, err := c.GetSubscription(ctx, req) |
| 225 |
if err != nil { |
| 226 |
// TODO: Handle error. |
| 227 |
} |
| 228 |
// TODO: Use resp. |
| 229 |
_ = resp |
| 230 |
} |
| 231 |
|
| 232 |
func ExampleSubscriptionAdminClient_ListSnapshots() { |
| 233 |
ctx := context.Background() |
| 234 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 235 |
// It will require modifications to work: |
| 236 |
// - It may require correct/in-range values for request initialization. |
| 237 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 238 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 239 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 240 |
if err != nil { |
| 241 |
// TODO: Handle error. |
| 242 |
} |
| 243 |
defer c.Close() |
| 244 |
|
| 245 |
req := &pubsubpb.ListSnapshotsRequest{ |
| 246 |
// TODO: Fill request struct fields. |
| 247 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#ListSnapshotsRequest. |
| 248 |
} |
| 249 |
it := c.ListSnapshots(ctx, req) |
| 250 |
for { |
| 251 |
resp, err := it.Next() |
| 252 |
if err == iterator.Done { |
| 253 |
break |
| 254 |
} |
| 255 |
if err != nil { |
| 256 |
// TODO: Handle error. |
| 257 |
} |
| 258 |
// TODO: Use resp. |
| 259 |
_ = resp |
| 260 |
|
| 261 |
// If you need to access the underlying RPC response, |
| 262 |
// you can do so by casting the `Response` as below. |
| 263 |
// Otherwise, remove this line. Only populated after |
| 264 |
// first call to Next(). Not safe for concurrent access. |
| 265 |
_ = it.Response.(*pubsubpb.ListSnapshotsResponse) |
| 266 |
} |
| 267 |
} |
| 268 |
|
| 269 |
func ExampleSubscriptionAdminClient_ListSubscriptions() { |
| 270 |
ctx := context.Background() |
| 271 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 272 |
// It will require modifications to work: |
| 273 |
// - It may require correct/in-range values for request initialization. |
| 274 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 275 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 276 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 277 |
if err != nil { |
| 278 |
// TODO: Handle error. |
| 279 |
} |
| 280 |
defer c.Close() |
| 281 |
|
| 282 |
req := &pubsubpb.ListSubscriptionsRequest{ |
| 283 |
// TODO: Fill request struct fields. |
| 284 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#ListSubscriptionsRequest. |
| 285 |
} |
| 286 |
it := c.ListSubscriptions(ctx, req) |
| 287 |
for { |
| 288 |
resp, err := it.Next() |
| 289 |
if err == iterator.Done { |
| 290 |
break |
| 291 |
} |
| 292 |
if err != nil { |
| 293 |
// TODO: Handle error. |
| 294 |
} |
| 295 |
// TODO: Use resp. |
| 296 |
_ = resp |
| 297 |
|
| 298 |
// If you need to access the underlying RPC response, |
| 299 |
// you can do so by casting the `Response` as below. |
| 300 |
// Otherwise, remove this line. Only populated after |
| 301 |
// first call to Next(). Not safe for concurrent access. |
| 302 |
_ = it.Response.(*pubsubpb.ListSubscriptionsResponse) |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
func ExampleSubscriptionAdminClient_ModifyAckDeadline() { |
| 307 |
ctx := context.Background() |
| 308 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 309 |
// It will require modifications to work: |
| 310 |
// - It may require correct/in-range values for request initialization. |
| 311 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 312 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 313 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 314 |
if err != nil { |
| 315 |
// TODO: Handle error. |
| 316 |
} |
| 317 |
defer c.Close() |
| 318 |
|
| 319 |
req := &pubsubpb.ModifyAckDeadlineRequest{ |
| 320 |
// TODO: Fill request struct fields. |
| 321 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#ModifyAckDeadlineRequest. |
| 322 |
} |
| 323 |
err = c.ModifyAckDeadline(ctx, req) |
| 324 |
if err != nil { |
| 325 |
// TODO: Handle error. |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
func ExampleSubscriptionAdminClient_ModifyPushConfig() { |
| 330 |
ctx := context.Background() |
| 331 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 332 |
// It will require modifications to work: |
| 333 |
// - It may require correct/in-range values for request initialization. |
| 334 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 335 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 336 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 337 |
if err != nil { |
| 338 |
// TODO: Handle error. |
| 339 |
} |
| 340 |
defer c.Close() |
| 341 |
|
| 342 |
req := &pubsubpb.ModifyPushConfigRequest{ |
| 343 |
// TODO: Fill request struct fields. |
| 344 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#ModifyPushConfigRequest. |
| 345 |
} |
| 346 |
err = c.ModifyPushConfig(ctx, req) |
| 347 |
if err != nil { |
| 348 |
// TODO: Handle error. |
| 349 |
} |
| 350 |
} |
| 351 |
|
| 352 |
func ExampleSubscriptionAdminClient_Pull() { |
| 353 |
ctx := context.Background() |
| 354 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 355 |
// It will require modifications to work: |
| 356 |
// - It may require correct/in-range values for request initialization. |
| 357 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 358 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 359 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 360 |
if err != nil { |
| 361 |
// TODO: Handle error. |
| 362 |
} |
| 363 |
defer c.Close() |
| 364 |
|
| 365 |
req := &pubsubpb.PullRequest{ |
| 366 |
// TODO: Fill request struct fields. |
| 367 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#PullRequest. |
| 368 |
} |
| 369 |
resp, err := c.Pull(ctx, req) |
| 370 |
if err != nil { |
| 371 |
// TODO: Handle error. |
| 372 |
} |
| 373 |
// TODO: Use resp. |
| 374 |
_ = resp |
| 375 |
} |
| 376 |
|
| 377 |
func ExampleSubscriptionAdminClient_Seek() { |
| 378 |
ctx := context.Background() |
| 379 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 380 |
// It will require modifications to work: |
| 381 |
// - It may require correct/in-range values for request initialization. |
| 382 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 383 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 384 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 385 |
if err != nil { |
| 386 |
// TODO: Handle error. |
| 387 |
} |
| 388 |
defer c.Close() |
| 389 |
|
| 390 |
req := &pubsubpb.SeekRequest{ |
| 391 |
// TODO: Fill request struct fields. |
| 392 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#SeekRequest. |
| 393 |
} |
| 394 |
resp, err := c.Seek(ctx, req) |
| 395 |
if err != nil { |
| 396 |
// TODO: Handle error. |
| 397 |
} |
| 398 |
// TODO: Use resp. |
| 399 |
_ = resp |
| 400 |
} |
| 401 |
|
| 402 |
func ExampleSubscriptionAdminClient_StreamingPull() { |
| 403 |
ctx := context.Background() |
| 404 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 405 |
// It will require modifications to work: |
| 406 |
// - It may require correct/in-range values for request initialization. |
| 407 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 408 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 409 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 410 |
if err != nil { |
| 411 |
// TODO: Handle error. |
| 412 |
} |
| 413 |
defer c.Close() |
| 414 |
stream, err := c.StreamingPull(ctx) |
| 415 |
if err != nil { |
| 416 |
// TODO: Handle error. |
| 417 |
} |
| 418 |
go func() { |
| 419 |
reqs := []*pubsubpb.StreamingPullRequest{ |
| 420 |
// TODO: Create requests. |
| 421 |
} |
| 422 |
for _, req := range reqs { |
| 423 |
if err := stream.Send(req); err != nil { |
| 424 |
// TODO: Handle error. |
| 425 |
} |
| 426 |
} |
| 427 |
stream.CloseSend() |
| 428 |
}() |
| 429 |
for { |
| 430 |
resp, err := stream.Recv() |
| 431 |
if err == io.EOF { |
| 432 |
break |
| 433 |
} |
| 434 |
if err != nil { |
| 435 |
// TODO: handle error. |
| 436 |
} |
| 437 |
// TODO: Use resp. |
| 438 |
_ = resp |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
func ExampleSubscriptionAdminClient_UpdateSnapshot() { |
| 443 |
ctx := context.Background() |
| 444 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 445 |
// It will require modifications to work: |
| 446 |
// - It may require correct/in-range values for request initialization. |
| 447 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 448 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 449 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 450 |
if err != nil { |
| 451 |
// TODO: Handle error. |
| 452 |
} |
| 453 |
defer c.Close() |
| 454 |
|
| 455 |
req := &pubsubpb.UpdateSnapshotRequest{ |
| 456 |
// TODO: Fill request struct fields. |
| 457 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#UpdateSnapshotRequest. |
| 458 |
} |
| 459 |
resp, err := c.UpdateSnapshot(ctx, req) |
| 460 |
if err != nil { |
| 461 |
// TODO: Handle error. |
| 462 |
} |
| 463 |
// TODO: Use resp. |
| 464 |
_ = resp |
| 465 |
} |
| 466 |
|
| 467 |
func ExampleSubscriptionAdminClient_UpdateSubscription() { |
| 468 |
ctx := context.Background() |
| 469 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 470 |
// It will require modifications to work: |
| 471 |
// - It may require correct/in-range values for request initialization. |
| 472 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 473 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 474 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 475 |
if err != nil { |
| 476 |
// TODO: Handle error. |
| 477 |
} |
| 478 |
defer c.Close() |
| 479 |
|
| 480 |
req := &pubsubpb.UpdateSubscriptionRequest{ |
| 481 |
// TODO: Fill request struct fields. |
| 482 |
// See https://pkg.go.dev/cloud.google.com/go/pubsub/v2/apiv1/pubsubpb#UpdateSubscriptionRequest. |
| 483 |
} |
| 484 |
resp, err := c.UpdateSubscription(ctx, req) |
| 485 |
if err != nil { |
| 486 |
// TODO: Handle error. |
| 487 |
} |
| 488 |
// TODO: Use resp. |
| 489 |
_ = resp |
| 490 |
} |
| 491 |
|
| 492 |
func ExampleSubscriptionAdminClient_GetIamPolicy() { |
| 493 |
ctx := context.Background() |
| 494 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 495 |
// It will require modifications to work: |
| 496 |
// - It may require correct/in-range values for request initialization. |
| 497 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 498 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 499 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 500 |
if err != nil { |
| 501 |
// TODO: Handle error. |
| 502 |
} |
| 503 |
defer c.Close() |
| 504 |
|
| 505 |
req := &iampb.GetIamPolicyRequest{ |
| 506 |
// TODO: Fill request struct fields. |
| 507 |
// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. |
| 508 |
} |
| 509 |
resp, err := c.GetIamPolicy(ctx, req) |
| 510 |
if err != nil { |
| 511 |
// TODO: Handle error. |
| 512 |
} |
| 513 |
// TODO: Use resp. |
| 514 |
_ = resp |
| 515 |
} |
| 516 |
|
| 517 |
func ExampleSubscriptionAdminClient_SetIamPolicy() { |
| 518 |
ctx := context.Background() |
| 519 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 520 |
// It will require modifications to work: |
| 521 |
// - It may require correct/in-range values for request initialization. |
| 522 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 523 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 524 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 525 |
if err != nil { |
| 526 |
// TODO: Handle error. |
| 527 |
} |
| 528 |
defer c.Close() |
| 529 |
|
| 530 |
req := &iampb.SetIamPolicyRequest{ |
| 531 |
// TODO: Fill request struct fields. |
| 532 |
// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. |
| 533 |
} |
| 534 |
resp, err := c.SetIamPolicy(ctx, req) |
| 535 |
if err != nil { |
| 536 |
// TODO: Handle error. |
| 537 |
} |
| 538 |
// TODO: Use resp. |
| 539 |
_ = resp |
| 540 |
} |
| 541 |
|
| 542 |
func ExampleSubscriptionAdminClient_TestIamPermissions() { |
| 543 |
ctx := context.Background() |
| 544 |
// This snippet has been automatically generated and should be regarded as a code template only. |
| 545 |
// It will require modifications to work: |
| 546 |
// - It may require correct/in-range values for request initialization. |
| 547 |
// - It may require specifying regional endpoints when creating the service client as shown in: |
| 548 |
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options |
| 549 |
c, err := pubsub.NewSubscriptionAdminClient(ctx) |
| 550 |
if err != nil { |
| 551 |
// TODO: Handle error. |
| 552 |
} |
| 553 |
defer c.Close() |
| 554 |
|
| 555 |
req := &iampb.TestIamPermissionsRequest{ |
| 556 |
// TODO: Fill request struct fields. |
| 557 |
// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. |
| 558 |
} |
| 559 |
resp, err := c.TestIamPermissions(ctx, req) |
| 560 |
if err != nil { |
| 561 |
// TODO: Handle error. |
| 562 |
} |
| 563 |
// TODO: Use resp. |
| 564 |
_ = resp |
| 565 |
} |