Copyright 2019 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 gapic-generator. DO NOT EDIT.

package logging

import (
	
	
	
	
	

	
	gax 
	
	
	
	monitoredrespb 
	loggingpb 
	
	
	
)
CallOptions contains the retry settings for each method of Client.
type CallOptions struct {
	DeleteLog                        []gax.CallOption
	WriteLogEntries                  []gax.CallOption
	ListLogEntries                   []gax.CallOption
	ListMonitoredResourceDescriptors []gax.CallOption
	ListLogs                         []gax.CallOption
}

func () []option.ClientOption {
	return []option.ClientOption{
		option.WithEndpoint("logging.googleapis.com:443"),
		option.WithScopes(DefaultAuthScopes()...),
	}
}

func () *CallOptions {
	 := map[[2]string][]gax.CallOption{
		{"default", "idempotent"}: {
			gax.WithRetry(func() gax.Retryer {
				return gax.OnCodes([]codes.Code{
					codes.DeadlineExceeded,
					codes.Internal,
					codes.Unavailable,
				}, gax.Backoff{
					Initial:    100 * time.Millisecond,
					Max:        60000 * time.Millisecond,
					Multiplier: 1.3,
				})
			}),
		},
	}
	return &CallOptions{
		DeleteLog:                        [[2]string{"default", "idempotent"}],
		WriteLogEntries:                  [[2]string{"default", "idempotent"}],
		ListLogEntries:                   [[2]string{"default", "idempotent"}],
		ListMonitoredResourceDescriptors: [[2]string{"default", "idempotent"}],
		ListLogs:                         [[2]string{"default", "idempotent"}],
	}
}
Client is a client for interacting with Stackdriver Logging API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The connection to the service.
The gRPC API client.
The call options for this service.
The x-goog-* metadata to be sent with each request.
NewClient creates a new logging service v2 client. Service for ingesting and querying logs.
func ( context.Context,  ...option.ClientOption) (*Client, error) {
	,  := transport.DialGRPC(, append(defaultClientOptions(), ...)...)
	if  != nil {
		return nil, 
	}
	 := &Client{
		conn:        ,
		CallOptions: defaultCallOptions(),

		client: loggingpb.NewLoggingServiceV2Client(),
	}
	.SetGoogleClientInfo()
	return , nil
}
Connection returns the client's connection to the API service.
func ( *Client) () *grpc.ClientConn {
	return .conn
}
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func ( *Client) () error {
	return .conn.Close()
}
SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.
func ( *Client) ( ...string) {
	 := append([]string{"gl-go", versionGo()}, ...)
	 = append(, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
	.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(...))
}
DeleteLog deletes all the log entries in a log. The log reappears if it receives new entries. Log entries written shortly before the delete operation might not be deleted.
func ( *Client) ( context.Context,  *loggingpb.DeleteLogRequest,  ...gax.CallOption) error {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "log_name", url.QueryEscape(.GetLogName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.DeleteLog[0:len(.CallOptions.DeleteLog):len(.CallOptions.DeleteLog)], ...)
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		_,  = .client.DeleteLog(, , .GRPC...)
		return 
	}, ...)
	return 
}
WriteLogEntries writes log entries to Logging. This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)
func ( *Client) ( context.Context,  *loggingpb.WriteLogEntriesRequest,  ...gax.CallOption) (*loggingpb.WriteLogEntriesResponse, error) {
	 = insertMetadata(, .xGoogMetadata)
	 = append(.CallOptions.WriteLogEntries[0:len(.CallOptions.WriteLogEntries):len(.CallOptions.WriteLogEntries)], ...)
	var  *loggingpb.WriteLogEntriesResponse
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .client.WriteLogEntries(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
ListLogEntries lists log entries. Use this method to retrieve log entries from Logging. For ways to export log entries, see Exporting Logs (at /logging/docs/export).
func ( *Client) ( context.Context,  *loggingpb.ListLogEntriesRequest,  ...gax.CallOption) *LogEntryIterator {
	 = insertMetadata(, .xGoogMetadata)
	 = append(.CallOptions.ListLogEntries[0:len(.CallOptions.ListLogEntries):len(.CallOptions.ListLogEntries)], ...)
	 := &LogEntryIterator{}
	 = proto.Clone().(*loggingpb.ListLogEntriesRequest)
	.InternalFetch = func( int,  string) ([]*loggingpb.LogEntry, string, error) {
		var  *loggingpb.ListLogEntriesResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .client.ListLogEntries(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}
		return .Entries, .NextPageToken, nil
	}
	 := func( int,  string) (string, error) {
		, ,  := .InternalFetch(, )
		if  != nil {
			return "", 
		}
		.items = append(.items, ...)
		return , nil
	}
	.pageInfo, .nextFunc = iterator.NewPageInfo(, .bufLen, .takeBuf)
	.pageInfo.MaxSize = int(.PageSize)
	.pageInfo.Token = .PageToken
	return 
}
ListMonitoredResourceDescriptors lists the descriptors for monitored resource types used by Logging.
func ( *Client) ( context.Context,  *loggingpb.ListMonitoredResourceDescriptorsRequest,  ...gax.CallOption) *MonitoredResourceDescriptorIterator {
	 = insertMetadata(, .xGoogMetadata)
	 = append(.CallOptions.ListMonitoredResourceDescriptors[0:len(.CallOptions.ListMonitoredResourceDescriptors):len(.CallOptions.ListMonitoredResourceDescriptors)], ...)
	 := &MonitoredResourceDescriptorIterator{}
	 = proto.Clone().(*loggingpb.ListMonitoredResourceDescriptorsRequest)
	.InternalFetch = func( int,  string) ([]*monitoredrespb.MonitoredResourceDescriptor, string, error) {
		var  *loggingpb.ListMonitoredResourceDescriptorsResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .client.ListMonitoredResourceDescriptors(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}
		return .ResourceDescriptors, .NextPageToken, nil
	}
	 := func( int,  string) (string, error) {
		, ,  := .InternalFetch(, )
		if  != nil {
			return "", 
		}
		.items = append(.items, ...)
		return , nil
	}
	.pageInfo, .nextFunc = iterator.NewPageInfo(, .bufLen, .takeBuf)
	.pageInfo.MaxSize = int(.PageSize)
	.pageInfo.Token = .PageToken
	return 
}
ListLogs lists the logs in projects, organizations, folders, or billing accounts. Only logs that have entries are listed.
func ( *Client) ( context.Context,  *loggingpb.ListLogsRequest,  ...gax.CallOption) *StringIterator {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.ListLogs[0:len(.CallOptions.ListLogs):len(.CallOptions.ListLogs)], ...)
	 := &StringIterator{}
	 = proto.Clone().(*loggingpb.ListLogsRequest)
	.InternalFetch = func( int,  string) ([]string, string, error) {
		var  *loggingpb.ListLogsResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .client.ListLogs(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}
		return .LogNames, .NextPageToken, nil
	}
	 := func( int,  string) (string, error) {
		, ,  := .InternalFetch(, )
		if  != nil {
			return "", 
		}
		.items = append(.items, ...)
		return , nil
	}
	.pageInfo, .nextFunc = iterator.NewPageInfo(, .bufLen, .takeBuf)
	.pageInfo.MaxSize = int(.PageSize)
	.pageInfo.Token = .PageToken
	return 
}
LogEntryIterator manages a stream of *loggingpb.LogEntry.
InternalFetch is for use by the Google Cloud Libraries only. It is not part of the stable interface of this package. InternalFetch returns results from a single call to the underlying RPC. The number of results is no greater than pageSize. If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogEntry, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func ( *LogEntryIterator) () *iterator.PageInfo {
	return .pageInfo
}
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func ( *LogEntryIterator) () (*loggingpb.LogEntry, error) {
	var  *loggingpb.LogEntry
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

func ( *LogEntryIterator) () int {
	return len(.items)
}

func ( *LogEntryIterator) () interface{} {
	 := .items
	.items = nil
	return 
}
MonitoredResourceDescriptorIterator manages a stream of *monitoredrespb.MonitoredResourceDescriptor.
InternalFetch is for use by the Google Cloud Libraries only. It is not part of the stable interface of this package. InternalFetch returns results from a single call to the underlying RPC. The number of results is no greater than pageSize. If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResourceDescriptor, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func ( *MonitoredResourceDescriptorIterator) () (*monitoredrespb.MonitoredResourceDescriptor, error) {
	var  *monitoredrespb.MonitoredResourceDescriptor
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

func ( *MonitoredResourceDescriptorIterator) () int {
	return len(.items)
}

func ( *MonitoredResourceDescriptorIterator) () interface{} {
	 := .items
	.items = nil
	return 
}
StringIterator manages a stream of string.
InternalFetch is for use by the Google Cloud Libraries only. It is not part of the stable interface of this package. InternalFetch returns results from a single call to the underlying RPC. The number of results is no greater than pageSize. If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func ( *StringIterator) () *iterator.PageInfo {
	return .pageInfo
}
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func ( *StringIterator) () (string, error) {
	var  string
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

func ( *StringIterator) () int {
	return len(.items)
}

func ( *StringIterator) () interface{} {
	 := .items
	.items = nil
	return