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 
	
	
	
	loggingpb 
	
	
	
)
MetricsCallOptions contains the retry settings for each method of MetricsClient.
type MetricsCallOptions struct {
	ListLogMetrics  []gax.CallOption
	GetLogMetric    []gax.CallOption
	CreateLogMetric []gax.CallOption
	UpdateLogMetric []gax.CallOption
	DeleteLogMetric []gax.CallOption
}

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

func () *MetricsCallOptions {
	 := 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 &MetricsCallOptions{
		ListLogMetrics:  [[2]string{"default", "idempotent"}],
		GetLogMetric:    [[2]string{"default", "idempotent"}],
		CreateLogMetric: [[2]string{"default", "non_idempotent"}],
		UpdateLogMetric: [[2]string{"default", "idempotent"}],
		DeleteLogMetric: [[2]string{"default", "idempotent"}],
	}
}
MetricsClient 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 call options for this service.
The x-goog-* metadata to be sent with each request.
NewMetricsClient creates a new metrics service v2 client. Service for configuring logs-based metrics.
Connection returns the client's connection to the API service.
func ( *MetricsClient) () *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 ( *MetricsClient) () 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 ( *MetricsClient) ( ...string) {
	 := append([]string{"gl-go", versionGo()}, ...)
	 = append(, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
	.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(...))
}
ListLogMetrics lists logs-based metrics.
func ( *MetricsClient) ( context.Context,  *loggingpb.ListLogMetricsRequest,  ...gax.CallOption) *LogMetricIterator {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.ListLogMetrics[0:len(.CallOptions.ListLogMetrics):len(.CallOptions.ListLogMetrics)], ...)
	 := &LogMetricIterator{}
	 = proto.Clone().(*loggingpb.ListLogMetricsRequest)
	.InternalFetch = func( int,  string) ([]*loggingpb.LogMetric, string, error) {
		var  *loggingpb.ListLogMetricsResponse
		.PageToken = 
		if  > math.MaxInt32 {
			.PageSize = math.MaxInt32
		} else {
			.PageSize = int32()
		}
		 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
			var  error
			,  = .metricsClient.ListLogMetrics(, , .GRPC...)
			return 
		}, ...)
		if  != nil {
			return nil, "", 
		}
		return .Metrics, .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 
}
GetLogMetric gets a logs-based metric.
func ( *MetricsClient) ( context.Context,  *loggingpb.GetLogMetricRequest,  ...gax.CallOption) (*loggingpb.LogMetric, error) {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "metric_name", url.QueryEscape(.GetMetricName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.GetLogMetric[0:len(.CallOptions.GetLogMetric):len(.CallOptions.GetLogMetric)], ...)
	var  *loggingpb.LogMetric
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .metricsClient.GetLogMetric(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
CreateLogMetric creates a logs-based metric.
func ( *MetricsClient) ( context.Context,  *loggingpb.CreateLogMetricRequest,  ...gax.CallOption) (*loggingpb.LogMetric, error) {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(.GetParent())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.CreateLogMetric[0:len(.CallOptions.CreateLogMetric):len(.CallOptions.CreateLogMetric)], ...)
	var  *loggingpb.LogMetric
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .metricsClient.CreateLogMetric(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
UpdateLogMetric creates or updates a logs-based metric.
func ( *MetricsClient) ( context.Context,  *loggingpb.UpdateLogMetricRequest,  ...gax.CallOption) (*loggingpb.LogMetric, error) {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "metric_name", url.QueryEscape(.GetMetricName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.UpdateLogMetric[0:len(.CallOptions.UpdateLogMetric):len(.CallOptions.UpdateLogMetric)], ...)
	var  *loggingpb.LogMetric
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		,  = .metricsClient.UpdateLogMetric(, , .GRPC...)
		return 
	}, ...)
	if  != nil {
		return nil, 
	}
	return , nil
}
DeleteLogMetric deletes a logs-based metric.
func ( *MetricsClient) ( context.Context,  *loggingpb.DeleteLogMetricRequest,  ...gax.CallOption) error {
	 := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "metric_name", url.QueryEscape(.GetMetricName())))
	 = insertMetadata(, .xGoogMetadata, )
	 = append(.CallOptions.DeleteLogMetric[0:len(.CallOptions.DeleteLogMetric):len(.CallOptions.DeleteLogMetric)], ...)
	 := gax.Invoke(, func( context.Context,  gax.CallSettings) error {
		var  error
		_,  = .metricsClient.DeleteLogMetric(, , .GRPC...)
		return 
	}, ...)
	return 
}
LogMetricIterator manages a stream of *loggingpb.LogMetric.
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.LogMetric, nextPageToken string, err error)
}
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
func ( *LogMetricIterator) () *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 ( *LogMetricIterator) () (*loggingpb.LogMetric, error) {
	var  *loggingpb.LogMetric
	if  := .nextFunc();  != nil {
		return , 
	}
	 = .items[0]
	.items = .items[1:]
	return , nil
}

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

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