Debian Codegraph @

apigeeconnect/apiv1/tether_client_example_test.go

raw
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 apigeeconnect_test
18
19 import (
20 "context"
21 "io"
22
23 apigeeconnect "cloud.google.com/go/apigeeconnect/apiv1"
24 apigeeconnectpb "cloud.google.com/go/apigeeconnect/apiv1/apigeeconnectpb"
25 )
26
27 func ExampleNewTetherClient() {
28 ctx := context.Background()
29 // This snippet has been automatically generated and should be regarded as a code template only.
30 // It will require modifications to work:
31 // - It may require correct/in-range values for request initialization.
32 // - It may require specifying regional endpoints when creating the service client as shown in:
33 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
34 c, err := apigeeconnect.NewTetherClient(ctx)
35 if err != nil {
36 // TODO: Handle error.
37 }
38 defer c.Close()
39
40 // TODO: Use client.
41 _ = c
42 }
43
44 func ExampleTetherClient_Egress() {
45 ctx := context.Background()
46 // This snippet has been automatically generated and should be regarded as a code template only.
47 // It will require modifications to work:
48 // - It may require correct/in-range values for request initialization.
49 // - It may require specifying regional endpoints when creating the service client as shown in:
50 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
51 c, err := apigeeconnect.NewTetherClient(ctx)
52 if err != nil {
53 // TODO: Handle error.
54 }
55 defer c.Close()
56 stream, err := c.Egress(ctx)
57 if err != nil {
58 // TODO: Handle error.
59 }
60 go func() {
61 reqs := []*apigeeconnectpb.EgressResponse{
62 // TODO: Create requests.
63 }
64 for _, req := range reqs {
65 if err := stream.Send(req); err != nil {
66 // TODO: Handle error.
67 }
68 }
69 stream.CloseSend()
70 }()
71 for {
72 resp, err := stream.Recv()
73 if err == io.EOF {
74 break
75 }
76 if err != nil {
77 // TODO: handle error.
78 }
79 // TODO: Use resp.
80 _ = resp
81 }
82 }