blob: ec354a857e364ad96ff37ab4f7a7a7dfefbe56e0 [file] [log] [blame]
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package pubsublite_test
import (
"context"
longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
pubsublite "cloud.google.com/go/pubsublite/apiv1"
pubsublitepb "cloud.google.com/go/pubsublite/apiv1/pubsublitepb"
"google.golang.org/api/iterator"
)
func ExampleNewAdminClient() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func ExampleAdminClient_CreateTopic() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.CreateTopicRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#CreateTopicRequest.
}
resp, err := c.CreateTopic(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_GetTopic() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.GetTopicRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#GetTopicRequest.
}
resp, err := c.GetTopic(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_GetTopicPartitions() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.GetTopicPartitionsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#GetTopicPartitionsRequest.
}
resp, err := c.GetTopicPartitions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_ListTopics() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.ListTopicsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#ListTopicsRequest.
}
it := c.ListTopics(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func ExampleAdminClient_UpdateTopic() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.UpdateTopicRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#UpdateTopicRequest.
}
resp, err := c.UpdateTopic(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_DeleteTopic() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.DeleteTopicRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#DeleteTopicRequest.
}
err = c.DeleteTopic(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleAdminClient_ListTopicSubscriptions() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.ListTopicSubscriptionsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#ListTopicSubscriptionsRequest.
}
it := c.ListTopicSubscriptions(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func ExampleAdminClient_CreateSubscription() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.CreateSubscriptionRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#CreateSubscriptionRequest.
}
resp, err := c.CreateSubscription(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_GetSubscription() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.GetSubscriptionRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#GetSubscriptionRequest.
}
resp, err := c.GetSubscription(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_ListSubscriptions() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.ListSubscriptionsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#ListSubscriptionsRequest.
}
it := c.ListSubscriptions(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func ExampleAdminClient_UpdateSubscription() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.UpdateSubscriptionRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#UpdateSubscriptionRequest.
}
resp, err := c.UpdateSubscription(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_DeleteSubscription() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.DeleteSubscriptionRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#DeleteSubscriptionRequest.
}
err = c.DeleteSubscription(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleAdminClient_SeekSubscription() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.SeekSubscriptionRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#SeekSubscriptionRequest.
}
op, err := c.SeekSubscription(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_CreateReservation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.CreateReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#CreateReservationRequest.
}
resp, err := c.CreateReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_GetReservation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.GetReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#GetReservationRequest.
}
resp, err := c.GetReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_ListReservations() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.ListReservationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#ListReservationsRequest.
}
it := c.ListReservations(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func ExampleAdminClient_UpdateReservation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.UpdateReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#UpdateReservationRequest.
}
resp, err := c.UpdateReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_DeleteReservation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.DeleteReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#DeleteReservationRequest.
}
err = c.DeleteReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleAdminClient_ListReservationTopics() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &pubsublitepb.ListReservationTopicsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/pubsublite/apiv1/pubsublitepb#ListReservationTopicsRequest.
}
it := c.ListReservationTopics(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func ExampleAdminClient_CancelOperation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.CancelOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
}
err = c.CancelOperation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleAdminClient_DeleteOperation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.DeleteOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
}
err = c.DeleteOperation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleAdminClient_GetOperation() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.GetOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
}
resp, err := c.GetOperation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleAdminClient_ListOperations() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := pubsublite.NewAdminClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &longrunningpb.ListOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
}
it := c.ListOperations(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}