1// Copyright 2021 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 logging_test
18
19import (
20	"context"
21	"io"
22
23	logging "cloud.google.com/go/logging/apiv2"
24	"google.golang.org/api/iterator"
25	loggingpb "google.golang.org/genproto/googleapis/logging/v2"
26)
27
28func ExampleNewClient() {
29	ctx := context.Background()
30	c, err := logging.NewClient(ctx)
31	if err != nil {
32		// TODO: Handle error.
33	}
34	defer c.Close()
35
36	// TODO: Use client.
37	_ = c
38}
39
40func ExampleClient_DeleteLog() {
41	ctx := context.Background()
42	c, err := logging.NewClient(ctx)
43	if err != nil {
44		// TODO: Handle error.
45	}
46	defer c.Close()
47
48	req := &loggingpb.DeleteLogRequest{
49		// TODO: Fill request struct fields.
50	}
51	err = c.DeleteLog(ctx, req)
52	if err != nil {
53		// TODO: Handle error.
54	}
55}
56
57func ExampleClient_WriteLogEntries() {
58	ctx := context.Background()
59	c, err := logging.NewClient(ctx)
60	if err != nil {
61		// TODO: Handle error.
62	}
63	defer c.Close()
64
65	req := &loggingpb.WriteLogEntriesRequest{
66		// TODO: Fill request struct fields.
67	}
68	resp, err := c.WriteLogEntries(ctx, req)
69	if err != nil {
70		// TODO: Handle error.
71	}
72	// TODO: Use resp.
73	_ = resp
74}
75
76func ExampleClient_ListLogEntries() {
77	ctx := context.Background()
78	c, err := logging.NewClient(ctx)
79	if err != nil {
80		// TODO: Handle error.
81	}
82	defer c.Close()
83
84	req := &loggingpb.ListLogEntriesRequest{
85		// TODO: Fill request struct fields.
86	}
87	it := c.ListLogEntries(ctx, req)
88	for {
89		resp, err := it.Next()
90		if err == iterator.Done {
91			break
92		}
93		if err != nil {
94			// TODO: Handle error.
95		}
96		// TODO: Use resp.
97		_ = resp
98	}
99}
100
101func ExampleClient_ListMonitoredResourceDescriptors() {
102	ctx := context.Background()
103	c, err := logging.NewClient(ctx)
104	if err != nil {
105		// TODO: Handle error.
106	}
107	defer c.Close()
108
109	req := &loggingpb.ListMonitoredResourceDescriptorsRequest{
110		// TODO: Fill request struct fields.
111	}
112	it := c.ListMonitoredResourceDescriptors(ctx, req)
113	for {
114		resp, err := it.Next()
115		if err == iterator.Done {
116			break
117		}
118		if err != nil {
119			// TODO: Handle error.
120		}
121		// TODO: Use resp.
122		_ = resp
123	}
124}
125
126func ExampleClient_ListLogs() {
127	ctx := context.Background()
128	c, err := logging.NewClient(ctx)
129	if err != nil {
130		// TODO: Handle error.
131	}
132	defer c.Close()
133
134	req := &loggingpb.ListLogsRequest{
135		// TODO: Fill request struct fields.
136	}
137	it := c.ListLogs(ctx, req)
138	for {
139		resp, err := it.Next()
140		if err == iterator.Done {
141			break
142		}
143		if err != nil {
144			// TODO: Handle error.
145		}
146		// TODO: Use resp.
147		_ = resp
148	}
149}
150
151func ExampleClient_TailLogEntries() {
152	ctx := context.Background()
153	c, err := logging.NewClient(ctx)
154	if err != nil {
155		// TODO: Handle error.
156	}
157	defer c.Close()
158	stream, err := c.TailLogEntries(ctx)
159	if err != nil {
160		// TODO: Handle error.
161	}
162	go func() {
163		reqs := []*loggingpb.TailLogEntriesRequest{
164			// TODO: Create requests.
165		}
166		for _, req := range reqs {
167			if err := stream.Send(req); err != nil {
168				// TODO: Handle error.
169			}
170		}
171		stream.CloseSend()
172	}()
173	for {
174		resp, err := stream.Recv()
175		if err == io.EOF {
176			break
177		}
178		if err != nil {
179			// TODO: handle error.
180		}
181		// TODO: Use resp.
182		_ = resp
183	}
184}
185