aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/cloud.google.com/go/logging/apiv2
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-06-13 20:23:21 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-06-13 20:23:21 +0200
commitb41e96b421acda1761e9ba2ee17da16efad436cd (patch)
treeb6200bf1c3665161b6d76453bb56f7bd5ce32f42 /vendor/cloud.google.com/go/logging/apiv2
parentf58147fb5ea43427d38c2a4437f35647138fbf9d (diff)
vendor: switch from dep to godep
dep tool vendored too much code (100MB) including tests and unused packages. godep vendored significantly less (12MB) without tests and unused packages. The main advantage is that pre-Go1.9 toolchain does not run tests of all vendor packages now.
Diffstat (limited to 'vendor/cloud.google.com/go/logging/apiv2')
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/README.md11
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/WriteLogEntries_smoke_test.go66
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/config_client.go314
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/config_client_example_test.go125
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/doc.go46
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/logging_client.go443
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/logging_client_example_test.go133
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/metrics_client.go301
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/metrics_client_example_test.go125
-rw-r--r--vendor/cloud.google.com/go/logging/apiv2/mock_test.go1248
10 files changed, 0 insertions, 2812 deletions
diff --git a/vendor/cloud.google.com/go/logging/apiv2/README.md b/vendor/cloud.google.com/go/logging/apiv2/README.md
deleted file mode 100644
index d2d9a176e..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-Auto-generated logging v2 clients
-=================================
-
-This package includes auto-generated clients for the logging v2 API.
-
-Use the handwritten logging client (in the parent directory,
-cloud.google.com/go/logging) in preference to this.
-
-This code is EXPERIMENTAL and subject to CHANGE AT ANY TIME.
-
-
diff --git a/vendor/cloud.google.com/go/logging/apiv2/WriteLogEntries_smoke_test.go b/vendor/cloud.google.com/go/logging/apiv2/WriteLogEntries_smoke_test.go
deleted file mode 100644
index b4d91ab45..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/WriteLogEntries_smoke_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging
-
-import (
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
-)
-
-import (
- "strconv"
- "testing"
- "time"
-
- "cloud.google.com/go/internal/testutil"
- "golang.org/x/net/context"
- "google.golang.org/api/iterator"
- "google.golang.org/api/option"
-)
-
-var _ = iterator.Done
-var _ = strconv.FormatUint
-var _ = time.Now
-
-func TestLoggingServiceV2Smoke(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping smoke test in short mode")
- }
- ctx := context.Background()
- ts := testutil.TokenSource(ctx, DefaultAuthScopes()...)
- if ts == nil {
- t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
- }
-
- projectId := testutil.ProjID()
- _ = projectId
-
- c, err := NewClient(ctx, option.WithTokenSource(ts))
- if err != nil {
- t.Fatal(err)
- }
-
- var entries []*loggingpb.LogEntry = nil
- var formattedLogName string = LoggingLogPath(projectId, "test-"+strconv.FormatInt(time.Now().UnixNano(), 10)+"")
- var request = &loggingpb.WriteLogEntriesRequest{
- Entries: entries,
- LogName: formattedLogName,
- }
-
- if _, err := c.WriteLogEntries(ctx, request); err != nil {
- t.Error(err)
- }
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/config_client.go b/vendor/cloud.google.com/go/logging/apiv2/config_client.go
deleted file mode 100644
index 417769b09..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/config_client.go
+++ /dev/null
@@ -1,314 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging
-
-import (
- "math"
- "time"
-
- "cloud.google.com/go/internal/version"
- gax "github.com/googleapis/gax-go"
- "golang.org/x/net/context"
- "google.golang.org/api/iterator"
- "google.golang.org/api/option"
- "google.golang.org/api/transport"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
-)
-
-var (
- configProjectPathTemplate = gax.MustCompilePathTemplate("projects/{project}")
- configSinkPathTemplate = gax.MustCompilePathTemplate("projects/{project}/sinks/{sink}")
-)
-
-// ConfigCallOptions contains the retry settings for each method of ConfigClient.
-type ConfigCallOptions struct {
- ListSinks []gax.CallOption
- GetSink []gax.CallOption
- CreateSink []gax.CallOption
- UpdateSink []gax.CallOption
- DeleteSink []gax.CallOption
-}
-
-func defaultConfigClientOptions() []option.ClientOption {
- return []option.ClientOption{
- option.WithEndpoint("logging.googleapis.com:443"),
- option.WithScopes(DefaultAuthScopes()...),
- }
-}
-
-func defaultConfigCallOptions() *ConfigCallOptions {
- retry := map[[2]string][]gax.CallOption{
- {"default", "idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.DeadlineExceeded,
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- {"default", "non_idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- }
- return &ConfigCallOptions{
- ListSinks: retry[[2]string{"default", "idempotent"}],
- GetSink: retry[[2]string{"default", "idempotent"}],
- CreateSink: retry[[2]string{"default", "non_idempotent"}],
- UpdateSink: retry[[2]string{"default", "non_idempotent"}],
- DeleteSink: retry[[2]string{"default", "idempotent"}],
- }
-}
-
-// ConfigClient is a client for interacting with Stackdriver Logging API.
-type ConfigClient struct {
- // The connection to the service.
- conn *grpc.ClientConn
-
- // The gRPC API client.
- configClient loggingpb.ConfigServiceV2Client
-
- // The call options for this service.
- CallOptions *ConfigCallOptions
-
- // The metadata to be sent with each request.
- xGoogHeader []string
-}
-
-// NewConfigClient creates a new config service v2 client.
-//
-// Service for configuring sinks used to export log entries outside of
-// Stackdriver Logging.
-func NewConfigClient(ctx context.Context, opts ...option.ClientOption) (*ConfigClient, error) {
- conn, err := transport.DialGRPC(ctx, append(defaultConfigClientOptions(), opts...)...)
- if err != nil {
- return nil, err
- }
- c := &ConfigClient{
- conn: conn,
- CallOptions: defaultConfigCallOptions(),
-
- configClient: loggingpb.NewConfigServiceV2Client(conn),
- }
- c.SetGoogleClientInfo()
- return c, nil
-}
-
-// Connection returns the client's connection to the API service.
-func (c *ConfigClient) Connection() *grpc.ClientConn {
- return c.conn
-}
-
-// Close closes the connection to the API service. The user should invoke this when
-// the client is no longer required.
-func (c *ConfigClient) Close() error {
- return c.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 (c *ConfigClient) SetGoogleClientInfo(keyval ...string) {
- kv := append([]string{"gl-go", version.Go()}, keyval...)
- kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
- c.xGoogHeader = []string{gax.XGoogHeader(kv...)}
-}
-
-// ConfigProjectPath returns the path for the project resource.
-func ConfigProjectPath(project string) string {
- path, err := configProjectPathTemplate.Render(map[string]string{
- "project": project,
- })
- if err != nil {
- panic(err)
- }
- return path
-}
-
-// ConfigSinkPath returns the path for the sink resource.
-func ConfigSinkPath(project, sink string) string {
- path, err := configSinkPathTemplate.Render(map[string]string{
- "project": project,
- "sink": sink,
- })
- if err != nil {
- panic(err)
- }
- return path
-}
-
-// ListSinks lists sinks.
-func (c *ConfigClient) ListSinks(ctx context.Context, req *loggingpb.ListSinksRequest, opts ...gax.CallOption) *LogSinkIterator {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.ListSinks[0:len(c.CallOptions.ListSinks):len(c.CallOptions.ListSinks)], opts...)
- it := &LogSinkIterator{}
- it.InternalFetch = func(pageSize int, pageToken string) ([]*loggingpb.LogSink, string, error) {
- var resp *loggingpb.ListSinksResponse
- req.PageToken = pageToken
- if pageSize > math.MaxInt32 {
- req.PageSize = math.MaxInt32
- } else {
- req.PageSize = int32(pageSize)
- }
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.configClient.ListSinks(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, "", err
- }
- return resp.Sinks, resp.NextPageToken, nil
- }
- fetch := func(pageSize int, pageToken string) (string, error) {
- items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
- if err != nil {
- return "", err
- }
- it.items = append(it.items, items...)
- return nextPageToken, nil
- }
- it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
- return it
-}
-
-// GetSink gets a sink.
-func (c *ConfigClient) GetSink(ctx context.Context, req *loggingpb.GetSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.GetSink[0:len(c.CallOptions.GetSink):len(c.CallOptions.GetSink)], opts...)
- var resp *loggingpb.LogSink
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.configClient.GetSink(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// CreateSink creates a sink that exports specified log entries to a destination. The
-// export of newly-ingested log entries begins immediately, unless the current
-// time is outside the sink's start and end times or the sink's
-// `writer_identity` is not permitted to write to the destination. A sink can
-// export log entries only from the resource owning the sink.
-func (c *ConfigClient) CreateSink(ctx context.Context, req *loggingpb.CreateSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.CreateSink[0:len(c.CallOptions.CreateSink):len(c.CallOptions.CreateSink)], opts...)
- var resp *loggingpb.LogSink
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.configClient.CreateSink(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// UpdateSink updates a sink. If the named sink doesn't exist, then this method is
-// identical to
-// [sinks.create](/logging/docs/api/reference/rest/v2/projects.sinks/create).
-// If the named sink does exist, then this method replaces the following
-// fields in the existing sink with values from the new sink: `destination`,
-// `filter`, `output_version_format`, `start_time`, and `end_time`.
-// The updated filter might also have a new `writer_identity`; see the
-// `unique_writer_identity` field.
-func (c *ConfigClient) UpdateSink(ctx context.Context, req *loggingpb.UpdateSinkRequest, opts ...gax.CallOption) (*loggingpb.LogSink, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.UpdateSink[0:len(c.CallOptions.UpdateSink):len(c.CallOptions.UpdateSink)], opts...)
- var resp *loggingpb.LogSink
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.configClient.UpdateSink(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteSink deletes a sink. If the sink has a unique `writer_identity`, then that
-// service account is also deleted.
-func (c *ConfigClient) DeleteSink(ctx context.Context, req *loggingpb.DeleteSinkRequest, opts ...gax.CallOption) error {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.DeleteSink[0:len(c.CallOptions.DeleteSink):len(c.CallOptions.DeleteSink)], opts...)
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- _, err = c.configClient.DeleteSink(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- return err
-}
-
-// LogSinkIterator manages a stream of *loggingpb.LogSink.
-type LogSinkIterator struct {
- items []*loggingpb.LogSink
- pageInfo *iterator.PageInfo
- nextFunc func() error
-
- // 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.LogSink, nextPageToken string, err error)
-}
-
-// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
-func (it *LogSinkIterator) PageInfo() *iterator.PageInfo {
- return it.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 (it *LogSinkIterator) Next() (*loggingpb.LogSink, error) {
- var item *loggingpb.LogSink
- if err := it.nextFunc(); err != nil {
- return item, err
- }
- item = it.items[0]
- it.items = it.items[1:]
- return item, nil
-}
-
-func (it *LogSinkIterator) bufLen() int {
- return len(it.items)
-}
-
-func (it *LogSinkIterator) takeBuf() interface{} {
- b := it.items
- it.items = nil
- return b
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/config_client_example_test.go b/vendor/cloud.google.com/go/logging/apiv2/config_client_example_test.go
deleted file mode 100644
index 620aa6505..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/config_client_example_test.go
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging_test
-
-import (
- "cloud.google.com/go/logging/apiv2"
- "golang.org/x/net/context"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
-)
-
-func ExampleNewConfigClient() {
- ctx := context.Background()
- c, err := logging.NewConfigClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use client.
- _ = c
-}
-
-func ExampleConfigClient_ListSinks() {
- ctx := context.Background()
- c, err := logging.NewConfigClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.ListSinksRequest{
- // TODO: Fill request struct fields.
- }
- it := c.ListSinks(ctx, req)
- for {
- resp, err := it.Next()
- if err != nil {
- // TODO: Handle error.
- break
- }
- // TODO: Use resp.
- _ = resp
- }
-}
-
-func ExampleConfigClient_GetSink() {
- ctx := context.Background()
- c, err := logging.NewConfigClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.GetSinkRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.GetSink(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleConfigClient_CreateSink() {
- ctx := context.Background()
- c, err := logging.NewConfigClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.CreateSinkRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.CreateSink(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleConfigClient_UpdateSink() {
- ctx := context.Background()
- c, err := logging.NewConfigClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.UpdateSinkRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.UpdateSink(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleConfigClient_DeleteSink() {
- ctx := context.Background()
- c, err := logging.NewConfigClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.DeleteSinkRequest{
- // TODO: Fill request struct fields.
- }
- err = c.DeleteSink(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/doc.go b/vendor/cloud.google.com/go/logging/apiv2/doc.go
deleted file mode 100644
index 3963c8b7d..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/doc.go
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-// Package logging is an experimental, auto-generated package for the
-// logging API.
-//
-// The Stackdriver Logging API lets you write log entries and manage your
-// logs, log sinks and logs-based metrics.
-//
-// Use the client at cloud.google.com/go/logging in preference to this.
-package logging // import "cloud.google.com/go/logging/apiv2"
-
-import (
- "golang.org/x/net/context"
- "google.golang.org/grpc/metadata"
-)
-
-func insertXGoog(ctx context.Context, val []string) context.Context {
- md, _ := metadata.FromOutgoingContext(ctx)
- md = md.Copy()
- md["x-goog-api-client"] = val
- return metadata.NewOutgoingContext(ctx, md)
-}
-
-func DefaultAuthScopes() []string {
- return []string{
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/cloud-platform.read-only",
- "https://www.googleapis.com/auth/logging.admin",
- "https://www.googleapis.com/auth/logging.read",
- "https://www.googleapis.com/auth/logging.write",
- }
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/logging_client.go b/vendor/cloud.google.com/go/logging/apiv2/logging_client.go
deleted file mode 100644
index 603893b35..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/logging_client.go
+++ /dev/null
@@ -1,443 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging
-
-import (
- "math"
- "time"
-
- "cloud.google.com/go/internal/version"
- gax "github.com/googleapis/gax-go"
- "golang.org/x/net/context"
- "google.golang.org/api/iterator"
- "google.golang.org/api/option"
- "google.golang.org/api/transport"
- monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
-)
-
-var (
- loggingProjectPathTemplate = gax.MustCompilePathTemplate("projects/{project}")
- loggingLogPathTemplate = gax.MustCompilePathTemplate("projects/{project}/logs/{log}")
-)
-
-// 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 defaultClientOptions() []option.ClientOption {
- return []option.ClientOption{
- option.WithEndpoint("logging.googleapis.com:443"),
- option.WithScopes(DefaultAuthScopes()...),
- }
-}
-
-func defaultCallOptions() *CallOptions {
- retry := map[[2]string][]gax.CallOption{
- {"default", "idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.DeadlineExceeded,
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- {"default", "non_idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- {"list", "idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.DeadlineExceeded,
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- }
- return &CallOptions{
- DeleteLog: retry[[2]string{"default", "idempotent"}],
- WriteLogEntries: retry[[2]string{"default", "non_idempotent"}],
- ListLogEntries: retry[[2]string{"list", "idempotent"}],
- ListMonitoredResourceDescriptors: retry[[2]string{"default", "idempotent"}],
- ListLogs: retry[[2]string{"default", "idempotent"}],
- }
-}
-
-// Client is a client for interacting with Stackdriver Logging API.
-type Client struct {
- // The connection to the service.
- conn *grpc.ClientConn
-
- // The gRPC API client.
- client loggingpb.LoggingServiceV2Client
-
- // The call options for this service.
- CallOptions *CallOptions
-
- // The metadata to be sent with each request.
- xGoogHeader []string
-}
-
-// NewClient creates a new logging service v2 client.
-//
-// Service for ingesting and querying logs.
-func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
- conn, err := transport.DialGRPC(ctx, append(defaultClientOptions(), opts...)...)
- if err != nil {
- return nil, err
- }
- c := &Client{
- conn: conn,
- CallOptions: defaultCallOptions(),
-
- client: loggingpb.NewLoggingServiceV2Client(conn),
- }
- c.SetGoogleClientInfo()
- return c, nil
-}
-
-// Connection returns the client's connection to the API service.
-func (c *Client) Connection() *grpc.ClientConn {
- return c.conn
-}
-
-// Close closes the connection to the API service. The user should invoke this when
-// the client is no longer required.
-func (c *Client) Close() error {
- return c.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 (c *Client) SetGoogleClientInfo(keyval ...string) {
- kv := append([]string{"gl-go", version.Go()}, keyval...)
- kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
- c.xGoogHeader = []string{gax.XGoogHeader(kv...)}
-}
-
-// LoggingProjectPath returns the path for the project resource.
-func LoggingProjectPath(project string) string {
- path, err := loggingProjectPathTemplate.Render(map[string]string{
- "project": project,
- })
- if err != nil {
- panic(err)
- }
- return path
-}
-
-// LoggingLogPath returns the path for the log resource.
-func LoggingLogPath(project, log string) string {
- path, err := loggingLogPathTemplate.Render(map[string]string{
- "project": project,
- "log": log,
- })
- if err != nil {
- panic(err)
- }
- return path
-}
-
-// 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 (c *Client) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest, opts ...gax.CallOption) error {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.DeleteLog[0:len(c.CallOptions.DeleteLog):len(c.CallOptions.DeleteLog)], opts...)
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- _, err = c.client.DeleteLog(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- return err
-}
-
-// WriteLogEntries writes log entries to Stackdriver Logging.
-func (c *Client) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest, opts ...gax.CallOption) (*loggingpb.WriteLogEntriesResponse, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.WriteLogEntries[0:len(c.CallOptions.WriteLogEntries):len(c.CallOptions.WriteLogEntries)], opts...)
- var resp *loggingpb.WriteLogEntriesResponse
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.client.WriteLogEntries(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// ListLogEntries lists log entries. Use this method to retrieve log entries from
-// Stackdriver Logging. For ways to export log entries, see
-// [Exporting Logs](/logging/docs/export).
-func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest, opts ...gax.CallOption) *LogEntryIterator {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.ListLogEntries[0:len(c.CallOptions.ListLogEntries):len(c.CallOptions.ListLogEntries)], opts...)
- it := &LogEntryIterator{}
- it.InternalFetch = func(pageSize int, pageToken string) ([]*loggingpb.LogEntry, string, error) {
- var resp *loggingpb.ListLogEntriesResponse
- req.PageToken = pageToken
- if pageSize > math.MaxInt32 {
- req.PageSize = math.MaxInt32
- } else {
- req.PageSize = int32(pageSize)
- }
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.client.ListLogEntries(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, "", err
- }
- return resp.Entries, resp.NextPageToken, nil
- }
- fetch := func(pageSize int, pageToken string) (string, error) {
- items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
- if err != nil {
- return "", err
- }
- it.items = append(it.items, items...)
- return nextPageToken, nil
- }
- it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
- return it
-}
-
-// ListMonitoredResourceDescriptors lists the descriptors for monitored resource types used by Stackdriver
-// Logging.
-func (c *Client) ListMonitoredResourceDescriptors(ctx context.Context, req *loggingpb.ListMonitoredResourceDescriptorsRequest, opts ...gax.CallOption) *MonitoredResourceDescriptorIterator {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.ListMonitoredResourceDescriptors[0:len(c.CallOptions.ListMonitoredResourceDescriptors):len(c.CallOptions.ListMonitoredResourceDescriptors)], opts...)
- it := &MonitoredResourceDescriptorIterator{}
- it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoredrespb.MonitoredResourceDescriptor, string, error) {
- var resp *loggingpb.ListMonitoredResourceDescriptorsResponse
- req.PageToken = pageToken
- if pageSize > math.MaxInt32 {
- req.PageSize = math.MaxInt32
- } else {
- req.PageSize = int32(pageSize)
- }
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.client.ListMonitoredResourceDescriptors(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, "", err
- }
- return resp.ResourceDescriptors, resp.NextPageToken, nil
- }
- fetch := func(pageSize int, pageToken string) (string, error) {
- items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
- if err != nil {
- return "", err
- }
- it.items = append(it.items, items...)
- return nextPageToken, nil
- }
- it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
- return it
-}
-
-// ListLogs lists the logs in projects, organizations, folders, or billing accounts.
-// Only logs that have entries are listed.
-func (c *Client) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest, opts ...gax.CallOption) *StringIterator {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.ListLogs[0:len(c.CallOptions.ListLogs):len(c.CallOptions.ListLogs)], opts...)
- it := &StringIterator{}
- it.InternalFetch = func(pageSize int, pageToken string) ([]string, string, error) {
- var resp *loggingpb.ListLogsResponse
- req.PageToken = pageToken
- if pageSize > math.MaxInt32 {
- req.PageSize = math.MaxInt32
- } else {
- req.PageSize = int32(pageSize)
- }
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.client.ListLogs(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, "", err
- }
- return resp.LogNames, resp.NextPageToken, nil
- }
- fetch := func(pageSize int, pageToken string) (string, error) {
- items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
- if err != nil {
- return "", err
- }
- it.items = append(it.items, items...)
- return nextPageToken, nil
- }
- it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
- return it
-}
-
-// LogEntryIterator manages a stream of *loggingpb.LogEntry.
-type LogEntryIterator struct {
- items []*loggingpb.LogEntry
- pageInfo *iterator.PageInfo
- nextFunc func() error
-
- // 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 (it *LogEntryIterator) PageInfo() *iterator.PageInfo {
- return it.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 (it *LogEntryIterator) Next() (*loggingpb.LogEntry, error) {
- var item *loggingpb.LogEntry
- if err := it.nextFunc(); err != nil {
- return item, err
- }
- item = it.items[0]
- it.items = it.items[1:]
- return item, nil
-}
-
-func (it *LogEntryIterator) bufLen() int {
- return len(it.items)
-}
-
-func (it *LogEntryIterator) takeBuf() interface{} {
- b := it.items
- it.items = nil
- return b
-}
-
-// MonitoredResourceDescriptorIterator manages a stream of *monitoredrespb.MonitoredResourceDescriptor.
-type MonitoredResourceDescriptorIterator struct {
- items []*monitoredrespb.MonitoredResourceDescriptor
- pageInfo *iterator.PageInfo
- nextFunc func() error
-
- // 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.
-func (it *MonitoredResourceDescriptorIterator) PageInfo() *iterator.PageInfo {
- return it.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 (it *MonitoredResourceDescriptorIterator) Next() (*monitoredrespb.MonitoredResourceDescriptor, error) {
- var item *monitoredrespb.MonitoredResourceDescriptor
- if err := it.nextFunc(); err != nil {
- return item, err
- }
- item = it.items[0]
- it.items = it.items[1:]
- return item, nil
-}
-
-func (it *MonitoredResourceDescriptorIterator) bufLen() int {
- return len(it.items)
-}
-
-func (it *MonitoredResourceDescriptorIterator) takeBuf() interface{} {
- b := it.items
- it.items = nil
- return b
-}
-
-// StringIterator manages a stream of string.
-type StringIterator struct {
- items []string
- pageInfo *iterator.PageInfo
- nextFunc func() error
-
- // 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 (it *StringIterator) PageInfo() *iterator.PageInfo {
- return it.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 (it *StringIterator) Next() (string, error) {
- var item string
- if err := it.nextFunc(); err != nil {
- return item, err
- }
- item = it.items[0]
- it.items = it.items[1:]
- return item, nil
-}
-
-func (it *StringIterator) bufLen() int {
- return len(it.items)
-}
-
-func (it *StringIterator) takeBuf() interface{} {
- b := it.items
- it.items = nil
- return b
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/logging_client_example_test.go b/vendor/cloud.google.com/go/logging/apiv2/logging_client_example_test.go
deleted file mode 100644
index 6dc537f5a..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/logging_client_example_test.go
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging_test
-
-import (
- "cloud.google.com/go/logging/apiv2"
- "golang.org/x/net/context"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
-)
-
-func ExampleNewClient() {
- ctx := context.Background()
- c, err := logging.NewClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use client.
- _ = c
-}
-
-func ExampleClient_DeleteLog() {
- ctx := context.Background()
- c, err := logging.NewClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.DeleteLogRequest{
- // TODO: Fill request struct fields.
- }
- err = c.DeleteLog(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
-}
-
-func ExampleClient_WriteLogEntries() {
- ctx := context.Background()
- c, err := logging.NewClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.WriteLogEntriesRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.WriteLogEntries(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleClient_ListLogEntries() {
- ctx := context.Background()
- c, err := logging.NewClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.ListLogEntriesRequest{
- // TODO: Fill request struct fields.
- }
- it := c.ListLogEntries(ctx, req)
- for {
- resp, err := it.Next()
- if err != nil {
- // TODO: Handle error.
- break
- }
- // TODO: Use resp.
- _ = resp
- }
-}
-
-func ExampleClient_ListMonitoredResourceDescriptors() {
- ctx := context.Background()
- c, err := logging.NewClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.ListMonitoredResourceDescriptorsRequest{
- // TODO: Fill request struct fields.
- }
- it := c.ListMonitoredResourceDescriptors(ctx, req)
- for {
- resp, err := it.Next()
- if err != nil {
- // TODO: Handle error.
- break
- }
- // TODO: Use resp.
- _ = resp
- }
-}
-
-func ExampleClient_ListLogs() {
- ctx := context.Background()
- c, err := logging.NewClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.ListLogsRequest{
- // TODO: Fill request struct fields.
- }
- it := c.ListLogs(ctx, req)
- for {
- resp, err := it.Next()
- if err != nil {
- // TODO: Handle error.
- break
- }
- // TODO: Use resp.
- _ = resp
- }
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/metrics_client.go b/vendor/cloud.google.com/go/logging/apiv2/metrics_client.go
deleted file mode 100644
index ba2af9284..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/metrics_client.go
+++ /dev/null
@@ -1,301 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging
-
-import (
- "math"
- "time"
-
- "cloud.google.com/go/internal/version"
- gax "github.com/googleapis/gax-go"
- "golang.org/x/net/context"
- "google.golang.org/api/iterator"
- "google.golang.org/api/option"
- "google.golang.org/api/transport"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
-)
-
-var (
- metricsProjectPathTemplate = gax.MustCompilePathTemplate("projects/{project}")
- metricsMetricPathTemplate = gax.MustCompilePathTemplate("projects/{project}/metrics/{metric}")
-)
-
-// 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 defaultMetricsClientOptions() []option.ClientOption {
- return []option.ClientOption{
- option.WithEndpoint("logging.googleapis.com:443"),
- option.WithScopes(DefaultAuthScopes()...),
- }
-}
-
-func defaultMetricsCallOptions() *MetricsCallOptions {
- retry := map[[2]string][]gax.CallOption{
- {"default", "idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.DeadlineExceeded,
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- {"default", "non_idempotent"}: {
- gax.WithRetry(func() gax.Retryer {
- return gax.OnCodes([]codes.Code{
- codes.Unavailable,
- }, gax.Backoff{
- Initial: 100 * time.Millisecond,
- Max: 1000 * time.Millisecond,
- Multiplier: 1.2,
- })
- }),
- },
- }
- return &MetricsCallOptions{
- ListLogMetrics: retry[[2]string{"default", "idempotent"}],
- GetLogMetric: retry[[2]string{"default", "idempotent"}],
- CreateLogMetric: retry[[2]string{"default", "non_idempotent"}],
- UpdateLogMetric: retry[[2]string{"default", "non_idempotent"}],
- DeleteLogMetric: retry[[2]string{"default", "idempotent"}],
- }
-}
-
-// MetricsClient is a client for interacting with Stackdriver Logging API.
-type MetricsClient struct {
- // The connection to the service.
- conn *grpc.ClientConn
-
- // The gRPC API client.
- metricsClient loggingpb.MetricsServiceV2Client
-
- // The call options for this service.
- CallOptions *MetricsCallOptions
-
- // The metadata to be sent with each request.
- xGoogHeader []string
-}
-
-// NewMetricsClient creates a new metrics service v2 client.
-//
-// Service for configuring logs-based metrics.
-func NewMetricsClient(ctx context.Context, opts ...option.ClientOption) (*MetricsClient, error) {
- conn, err := transport.DialGRPC(ctx, append(defaultMetricsClientOptions(), opts...)...)
- if err != nil {
- return nil, err
- }
- c := &MetricsClient{
- conn: conn,
- CallOptions: defaultMetricsCallOptions(),
-
- metricsClient: loggingpb.NewMetricsServiceV2Client(conn),
- }
- c.SetGoogleClientInfo()
- return c, nil
-}
-
-// Connection returns the client's connection to the API service.
-func (c *MetricsClient) Connection() *grpc.ClientConn {
- return c.conn
-}
-
-// Close closes the connection to the API service. The user should invoke this when
-// the client is no longer required.
-func (c *MetricsClient) Close() error {
- return c.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 (c *MetricsClient) SetGoogleClientInfo(keyval ...string) {
- kv := append([]string{"gl-go", version.Go()}, keyval...)
- kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
- c.xGoogHeader = []string{gax.XGoogHeader(kv...)}
-}
-
-// MetricsProjectPath returns the path for the project resource.
-func MetricsProjectPath(project string) string {
- path, err := metricsProjectPathTemplate.Render(map[string]string{
- "project": project,
- })
- if err != nil {
- panic(err)
- }
- return path
-}
-
-// MetricsMetricPath returns the path for the metric resource.
-func MetricsMetricPath(project, metric string) string {
- path, err := metricsMetricPathTemplate.Render(map[string]string{
- "project": project,
- "metric": metric,
- })
- if err != nil {
- panic(err)
- }
- return path
-}
-
-// ListLogMetrics lists logs-based metrics.
-func (c *MetricsClient) ListLogMetrics(ctx context.Context, req *loggingpb.ListLogMetricsRequest, opts ...gax.CallOption) *LogMetricIterator {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.ListLogMetrics[0:len(c.CallOptions.ListLogMetrics):len(c.CallOptions.ListLogMetrics)], opts...)
- it := &LogMetricIterator{}
- it.InternalFetch = func(pageSize int, pageToken string) ([]*loggingpb.LogMetric, string, error) {
- var resp *loggingpb.ListLogMetricsResponse
- req.PageToken = pageToken
- if pageSize > math.MaxInt32 {
- req.PageSize = math.MaxInt32
- } else {
- req.PageSize = int32(pageSize)
- }
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.metricsClient.ListLogMetrics(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, "", err
- }
- return resp.Metrics, resp.NextPageToken, nil
- }
- fetch := func(pageSize int, pageToken string) (string, error) {
- items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
- if err != nil {
- return "", err
- }
- it.items = append(it.items, items...)
- return nextPageToken, nil
- }
- it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
- return it
-}
-
-// GetLogMetric gets a logs-based metric.
-func (c *MetricsClient) GetLogMetric(ctx context.Context, req *loggingpb.GetLogMetricRequest, opts ...gax.CallOption) (*loggingpb.LogMetric, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.GetLogMetric[0:len(c.CallOptions.GetLogMetric):len(c.CallOptions.GetLogMetric)], opts...)
- var resp *loggingpb.LogMetric
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.metricsClient.GetLogMetric(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// CreateLogMetric creates a logs-based metric.
-func (c *MetricsClient) CreateLogMetric(ctx context.Context, req *loggingpb.CreateLogMetricRequest, opts ...gax.CallOption) (*loggingpb.LogMetric, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.CreateLogMetric[0:len(c.CallOptions.CreateLogMetric):len(c.CallOptions.CreateLogMetric)], opts...)
- var resp *loggingpb.LogMetric
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.metricsClient.CreateLogMetric(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// UpdateLogMetric creates or updates a logs-based metric.
-func (c *MetricsClient) UpdateLogMetric(ctx context.Context, req *loggingpb.UpdateLogMetricRequest, opts ...gax.CallOption) (*loggingpb.LogMetric, error) {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.UpdateLogMetric[0:len(c.CallOptions.UpdateLogMetric):len(c.CallOptions.UpdateLogMetric)], opts...)
- var resp *loggingpb.LogMetric
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- resp, err = c.metricsClient.UpdateLogMetric(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- if err != nil {
- return nil, err
- }
- return resp, nil
-}
-
-// DeleteLogMetric deletes a logs-based metric.
-func (c *MetricsClient) DeleteLogMetric(ctx context.Context, req *loggingpb.DeleteLogMetricRequest, opts ...gax.CallOption) error {
- ctx = insertXGoog(ctx, c.xGoogHeader)
- opts = append(c.CallOptions.DeleteLogMetric[0:len(c.CallOptions.DeleteLogMetric):len(c.CallOptions.DeleteLogMetric)], opts...)
- err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
- var err error
- _, err = c.metricsClient.DeleteLogMetric(ctx, req, settings.GRPC...)
- return err
- }, opts...)
- return err
-}
-
-// LogMetricIterator manages a stream of *loggingpb.LogMetric.
-type LogMetricIterator struct {
- items []*loggingpb.LogMetric
- pageInfo *iterator.PageInfo
- nextFunc func() error
-
- // 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 (it *LogMetricIterator) PageInfo() *iterator.PageInfo {
- return it.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 (it *LogMetricIterator) Next() (*loggingpb.LogMetric, error) {
- var item *loggingpb.LogMetric
- if err := it.nextFunc(); err != nil {
- return item, err
- }
- item = it.items[0]
- it.items = it.items[1:]
- return item, nil
-}
-
-func (it *LogMetricIterator) bufLen() int {
- return len(it.items)
-}
-
-func (it *LogMetricIterator) takeBuf() interface{} {
- b := it.items
- it.items = nil
- return b
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/metrics_client_example_test.go b/vendor/cloud.google.com/go/logging/apiv2/metrics_client_example_test.go
deleted file mode 100644
index c92412047..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/metrics_client_example_test.go
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging_test
-
-import (
- "cloud.google.com/go/logging/apiv2"
- "golang.org/x/net/context"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
-)
-
-func ExampleNewMetricsClient() {
- ctx := context.Background()
- c, err := logging.NewMetricsClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use client.
- _ = c
-}
-
-func ExampleMetricsClient_ListLogMetrics() {
- ctx := context.Background()
- c, err := logging.NewMetricsClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.ListLogMetricsRequest{
- // TODO: Fill request struct fields.
- }
- it := c.ListLogMetrics(ctx, req)
- for {
- resp, err := it.Next()
- if err != nil {
- // TODO: Handle error.
- break
- }
- // TODO: Use resp.
- _ = resp
- }
-}
-
-func ExampleMetricsClient_GetLogMetric() {
- ctx := context.Background()
- c, err := logging.NewMetricsClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.GetLogMetricRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.GetLogMetric(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleMetricsClient_CreateLogMetric() {
- ctx := context.Background()
- c, err := logging.NewMetricsClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.CreateLogMetricRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.CreateLogMetric(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleMetricsClient_UpdateLogMetric() {
- ctx := context.Background()
- c, err := logging.NewMetricsClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.UpdateLogMetricRequest{
- // TODO: Fill request struct fields.
- }
- resp, err := c.UpdateLogMetric(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
- // TODO: Use resp.
- _ = resp
-}
-
-func ExampleMetricsClient_DeleteLogMetric() {
- ctx := context.Background()
- c, err := logging.NewMetricsClient(ctx)
- if err != nil {
- // TODO: Handle error.
- }
-
- req := &loggingpb.DeleteLogMetricRequest{
- // TODO: Fill request struct fields.
- }
- err = c.DeleteLogMetric(ctx, req)
- if err != nil {
- // TODO: Handle error.
- }
-}
diff --git a/vendor/cloud.google.com/go/logging/apiv2/mock_test.go b/vendor/cloud.google.com/go/logging/apiv2/mock_test.go
deleted file mode 100644
index 30083a2a5..000000000
--- a/vendor/cloud.google.com/go/logging/apiv2/mock_test.go
+++ /dev/null
@@ -1,1248 +0,0 @@
-// Copyright 2017, Google Inc. All rights reserved.
-//
-// 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
-//
-// http://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.
-
-// AUTO-GENERATED CODE. DO NOT EDIT.
-
-package logging
-
-import (
- emptypb "github.com/golang/protobuf/ptypes/empty"
- monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
- loggingpb "google.golang.org/genproto/googleapis/logging/v2"
-)
-
-import (
- "flag"
- "fmt"
- "io"
- "log"
- "net"
- "os"
- "strings"
- "testing"
-
- "github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/ptypes"
- "golang.org/x/net/context"
- "google.golang.org/api/option"
- status "google.golang.org/genproto/googleapis/rpc/status"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
-)
-
-var _ = io.EOF
-var _ = ptypes.MarshalAny
-var _ status.Status
-
-type mockLoggingServer struct {
- // Embed for forward compatibility.
- // Tests will keep working if more methods are added
- // in the future.
- loggingpb.LoggingServiceV2Server
-
- reqs []proto.Message
-
- // If set, all calls return this error.
- err error
-
- // responses to return if err == nil
- resps []proto.Message
-}
-
-func (s *mockLoggingServer) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest) (*emptypb.Empty, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*emptypb.Empty), nil
-}
-
-func (s *mockLoggingServer) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest) (*loggingpb.WriteLogEntriesResponse, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.WriteLogEntriesResponse), nil
-}
-
-func (s *mockLoggingServer) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest) (*loggingpb.ListLogEntriesResponse, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.ListLogEntriesResponse), nil
-}
-
-func (s *mockLoggingServer) ListMonitoredResourceDescriptors(ctx context.Context, req *loggingpb.ListMonitoredResourceDescriptorsRequest) (*loggingpb.ListMonitoredResourceDescriptorsResponse, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.ListMonitoredResourceDescriptorsResponse), nil
-}
-
-func (s *mockLoggingServer) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest) (*loggingpb.ListLogsResponse, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.ListLogsResponse), nil
-}
-
-type mockConfigServer struct {
- // Embed for forward compatibility.
- // Tests will keep working if more methods are added
- // in the future.
- loggingpb.ConfigServiceV2Server
-
- reqs []proto.Message
-
- // If set, all calls return this error.
- err error
-
- // responses to return if err == nil
- resps []proto.Message
-}
-
-func (s *mockConfigServer) ListSinks(ctx context.Context, req *loggingpb.ListSinksRequest) (*loggingpb.ListSinksResponse, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.ListSinksResponse), nil
-}
-
-func (s *mockConfigServer) GetSink(ctx context.Context, req *loggingpb.GetSinkRequest) (*loggingpb.LogSink, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.LogSink), nil
-}
-
-func (s *mockConfigServer) CreateSink(ctx context.Context, req *loggingpb.CreateSinkRequest) (*loggingpb.LogSink, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.LogSink), nil
-}
-
-func (s *mockConfigServer) UpdateSink(ctx context.Context, req *loggingpb.UpdateSinkRequest) (*loggingpb.LogSink, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.LogSink), nil
-}
-
-func (s *mockConfigServer) DeleteSink(ctx context.Context, req *loggingpb.DeleteSinkRequest) (*emptypb.Empty, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*emptypb.Empty), nil
-}
-
-type mockMetricsServer struct {
- // Embed for forward compatibility.
- // Tests will keep working if more methods are added
- // in the future.
- loggingpb.MetricsServiceV2Server
-
- reqs []proto.Message
-
- // If set, all calls return this error.
- err error
-
- // responses to return if err == nil
- resps []proto.Message
-}
-
-func (s *mockMetricsServer) ListLogMetrics(ctx context.Context, req *loggingpb.ListLogMetricsRequest) (*loggingpb.ListLogMetricsResponse, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.ListLogMetricsResponse), nil
-}
-
-func (s *mockMetricsServer) GetLogMetric(ctx context.Context, req *loggingpb.GetLogMetricRequest) (*loggingpb.LogMetric, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.LogMetric), nil
-}
-
-func (s *mockMetricsServer) CreateLogMetric(ctx context.Context, req *loggingpb.CreateLogMetricRequest) (*loggingpb.LogMetric, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.LogMetric), nil
-}
-
-func (s *mockMetricsServer) UpdateLogMetric(ctx context.Context, req *loggingpb.UpdateLogMetricRequest) (*loggingpb.LogMetric, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*loggingpb.LogMetric), nil
-}
-
-func (s *mockMetricsServer) DeleteLogMetric(ctx context.Context, req *loggingpb.DeleteLogMetricRequest) (*emptypb.Empty, error) {
- md, _ := metadata.FromIncomingContext(ctx)
- if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") {
- return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
- }
- s.reqs = append(s.reqs, req)
- if s.err != nil {
- return nil, s.err
- }
- return s.resps[0].(*emptypb.Empty), nil
-}
-
-// clientOpt is the option tests should use to connect to the test server.
-// It is initialized by TestMain.
-var clientOpt option.ClientOption
-
-var (
- mockLogging mockLoggingServer
- mockConfig mockConfigServer
- mockMetrics mockMetricsServer
-)
-
-func TestMain(m *testing.M) {
- flag.Parse()
-
- serv := grpc.NewServer()
- loggingpb.RegisterLoggingServiceV2Server(serv, &mockLogging)
- loggingpb.RegisterConfigServiceV2Server(serv, &mockConfig)
- loggingpb.RegisterMetricsServiceV2Server(serv, &mockMetrics)
-
- lis, err := net.Listen("tcp", "localhost:0")
- if err != nil {
- log.Fatal(err)
- }
- go serv.Serve(lis)
-
- conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure())
- if err != nil {
- log.Fatal(err)
- }
- clientOpt = option.WithGRPCConn(conn)
-
- os.Exit(m.Run())
-}
-
-func TestLoggingServiceV2DeleteLog(t *testing.T) {
- var expectedResponse *emptypb.Empty = &emptypb.Empty{}
-
- mockLogging.err = nil
- mockLogging.reqs = nil
-
- mockLogging.resps = append(mockLogging.resps[:0], expectedResponse)
-
- var formattedLogName string = LoggingLogPath("[PROJECT]", "[LOG]")
- var request = &loggingpb.DeleteLogRequest{
- LogName: formattedLogName,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- err = c.DeleteLog(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockLogging.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
-}
-
-func TestLoggingServiceV2DeleteLogError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockLogging.err = grpc.Errorf(errCode, "test error")
-
- var formattedLogName string = LoggingLogPath("[PROJECT]", "[LOG]")
- var request = &loggingpb.DeleteLogRequest{
- LogName: formattedLogName,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- err = c.DeleteLog(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
-}
-func TestLoggingServiceV2WriteLogEntries(t *testing.T) {
- var expectedResponse *loggingpb.WriteLogEntriesResponse = &loggingpb.WriteLogEntriesResponse{}
-
- mockLogging.err = nil
- mockLogging.reqs = nil
-
- mockLogging.resps = append(mockLogging.resps[:0], expectedResponse)
-
- var entries []*loggingpb.LogEntry = nil
- var request = &loggingpb.WriteLogEntriesRequest{
- Entries: entries,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.WriteLogEntries(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockLogging.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestLoggingServiceV2WriteLogEntriesError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockLogging.err = grpc.Errorf(errCode, "test error")
-
- var entries []*loggingpb.LogEntry = nil
- var request = &loggingpb.WriteLogEntriesRequest{
- Entries: entries,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.WriteLogEntries(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestLoggingServiceV2ListLogEntries(t *testing.T) {
- var nextPageToken string = ""
- var entriesElement *loggingpb.LogEntry = &loggingpb.LogEntry{}
- var entries = []*loggingpb.LogEntry{entriesElement}
- var expectedResponse = &loggingpb.ListLogEntriesResponse{
- NextPageToken: nextPageToken,
- Entries: entries,
- }
-
- mockLogging.err = nil
- mockLogging.reqs = nil
-
- mockLogging.resps = append(mockLogging.resps[:0], expectedResponse)
-
- var resourceNames []string = nil
- var request = &loggingpb.ListLogEntriesRequest{
- ResourceNames: resourceNames,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListLogEntries(context.Background(), request).Next()
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockLogging.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- want := (interface{})(expectedResponse.Entries[0])
- got := (interface{})(resp)
- var ok bool
-
- switch want := (want).(type) {
- case proto.Message:
- ok = proto.Equal(want, got.(proto.Message))
- default:
- ok = want == got
- }
- if !ok {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestLoggingServiceV2ListLogEntriesError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockLogging.err = grpc.Errorf(errCode, "test error")
-
- var resourceNames []string = nil
- var request = &loggingpb.ListLogEntriesRequest{
- ResourceNames: resourceNames,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListLogEntries(context.Background(), request).Next()
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestLoggingServiceV2ListMonitoredResourceDescriptors(t *testing.T) {
- var nextPageToken string = ""
- var resourceDescriptorsElement *monitoredrespb.MonitoredResourceDescriptor = &monitoredrespb.MonitoredResourceDescriptor{}
- var resourceDescriptors = []*monitoredrespb.MonitoredResourceDescriptor{resourceDescriptorsElement}
- var expectedResponse = &loggingpb.ListMonitoredResourceDescriptorsResponse{
- NextPageToken: nextPageToken,
- ResourceDescriptors: resourceDescriptors,
- }
-
- mockLogging.err = nil
- mockLogging.reqs = nil
-
- mockLogging.resps = append(mockLogging.resps[:0], expectedResponse)
-
- var request *loggingpb.ListMonitoredResourceDescriptorsRequest = &loggingpb.ListMonitoredResourceDescriptorsRequest{}
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListMonitoredResourceDescriptors(context.Background(), request).Next()
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockLogging.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- want := (interface{})(expectedResponse.ResourceDescriptors[0])
- got := (interface{})(resp)
- var ok bool
-
- switch want := (want).(type) {
- case proto.Message:
- ok = proto.Equal(want, got.(proto.Message))
- default:
- ok = want == got
- }
- if !ok {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestLoggingServiceV2ListMonitoredResourceDescriptorsError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockLogging.err = grpc.Errorf(errCode, "test error")
-
- var request *loggingpb.ListMonitoredResourceDescriptorsRequest = &loggingpb.ListMonitoredResourceDescriptorsRequest{}
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListMonitoredResourceDescriptors(context.Background(), request).Next()
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestLoggingServiceV2ListLogs(t *testing.T) {
- var nextPageToken string = ""
- var logNamesElement string = "logNamesElement-1079688374"
- var logNames = []string{logNamesElement}
- var expectedResponse = &loggingpb.ListLogsResponse{
- NextPageToken: nextPageToken,
- LogNames: logNames,
- }
-
- mockLogging.err = nil
- mockLogging.reqs = nil
-
- mockLogging.resps = append(mockLogging.resps[:0], expectedResponse)
-
- var formattedParent string = LoggingProjectPath("[PROJECT]")
- var request = &loggingpb.ListLogsRequest{
- Parent: formattedParent,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListLogs(context.Background(), request).Next()
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockLogging.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- want := (interface{})(expectedResponse.LogNames[0])
- got := (interface{})(resp)
- var ok bool
-
- switch want := (want).(type) {
- case proto.Message:
- ok = proto.Equal(want, got.(proto.Message))
- default:
- ok = want == got
- }
- if !ok {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestLoggingServiceV2ListLogsError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockLogging.err = grpc.Errorf(errCode, "test error")
-
- var formattedParent string = LoggingProjectPath("[PROJECT]")
- var request = &loggingpb.ListLogsRequest{
- Parent: formattedParent,
- }
-
- c, err := NewClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListLogs(context.Background(), request).Next()
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestConfigServiceV2ListSinks(t *testing.T) {
- var nextPageToken string = ""
- var sinksElement *loggingpb.LogSink = &loggingpb.LogSink{}
- var sinks = []*loggingpb.LogSink{sinksElement}
- var expectedResponse = &loggingpb.ListSinksResponse{
- NextPageToken: nextPageToken,
- Sinks: sinks,
- }
-
- mockConfig.err = nil
- mockConfig.reqs = nil
-
- mockConfig.resps = append(mockConfig.resps[:0], expectedResponse)
-
- var formattedParent string = ConfigProjectPath("[PROJECT]")
- var request = &loggingpb.ListSinksRequest{
- Parent: formattedParent,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListSinks(context.Background(), request).Next()
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockConfig.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- want := (interface{})(expectedResponse.Sinks[0])
- got := (interface{})(resp)
- var ok bool
-
- switch want := (want).(type) {
- case proto.Message:
- ok = proto.Equal(want, got.(proto.Message))
- default:
- ok = want == got
- }
- if !ok {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestConfigServiceV2ListSinksError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockConfig.err = grpc.Errorf(errCode, "test error")
-
- var formattedParent string = ConfigProjectPath("[PROJECT]")
- var request = &loggingpb.ListSinksRequest{
- Parent: formattedParent,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListSinks(context.Background(), request).Next()
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestConfigServiceV2GetSink(t *testing.T) {
- var name string = "name3373707"
- var destination string = "destination-1429847026"
- var filter string = "filter-1274492040"
- var writerIdentity string = "writerIdentity775638794"
- var includeChildren bool = true
- var expectedResponse = &loggingpb.LogSink{
- Name: name,
- Destination: destination,
- Filter: filter,
- WriterIdentity: writerIdentity,
- IncludeChildren: includeChildren,
- }
-
- mockConfig.err = nil
- mockConfig.reqs = nil
-
- mockConfig.resps = append(mockConfig.resps[:0], expectedResponse)
-
- var formattedSinkName string = ConfigSinkPath("[PROJECT]", "[SINK]")
- var request = &loggingpb.GetSinkRequest{
- SinkName: formattedSinkName,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.GetSink(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockConfig.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestConfigServiceV2GetSinkError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockConfig.err = grpc.Errorf(errCode, "test error")
-
- var formattedSinkName string = ConfigSinkPath("[PROJECT]", "[SINK]")
- var request = &loggingpb.GetSinkRequest{
- SinkName: formattedSinkName,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.GetSink(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestConfigServiceV2CreateSink(t *testing.T) {
- var name string = "name3373707"
- var destination string = "destination-1429847026"
- var filter string = "filter-1274492040"
- var writerIdentity string = "writerIdentity775638794"
- var includeChildren bool = true
- var expectedResponse = &loggingpb.LogSink{
- Name: name,
- Destination: destination,
- Filter: filter,
- WriterIdentity: writerIdentity,
- IncludeChildren: includeChildren,
- }
-
- mockConfig.err = nil
- mockConfig.reqs = nil
-
- mockConfig.resps = append(mockConfig.resps[:0], expectedResponse)
-
- var formattedParent string = ConfigProjectPath("[PROJECT]")
- var sink *loggingpb.LogSink = &loggingpb.LogSink{}
- var request = &loggingpb.CreateSinkRequest{
- Parent: formattedParent,
- Sink: sink,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.CreateSink(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockConfig.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestConfigServiceV2CreateSinkError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockConfig.err = grpc.Errorf(errCode, "test error")
-
- var formattedParent string = ConfigProjectPath("[PROJECT]")
- var sink *loggingpb.LogSink = &loggingpb.LogSink{}
- var request = &loggingpb.CreateSinkRequest{
- Parent: formattedParent,
- Sink: sink,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.CreateSink(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestConfigServiceV2UpdateSink(t *testing.T) {
- var name string = "name3373707"
- var destination string = "destination-1429847026"
- var filter string = "filter-1274492040"
- var writerIdentity string = "writerIdentity775638794"
- var includeChildren bool = true
- var expectedResponse = &loggingpb.LogSink{
- Name: name,
- Destination: destination,
- Filter: filter,
- WriterIdentity: writerIdentity,
- IncludeChildren: includeChildren,
- }
-
- mockConfig.err = nil
- mockConfig.reqs = nil
-
- mockConfig.resps = append(mockConfig.resps[:0], expectedResponse)
-
- var formattedSinkName string = ConfigSinkPath("[PROJECT]", "[SINK]")
- var sink *loggingpb.LogSink = &loggingpb.LogSink{}
- var request = &loggingpb.UpdateSinkRequest{
- SinkName: formattedSinkName,
- Sink: sink,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.UpdateSink(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockConfig.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestConfigServiceV2UpdateSinkError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockConfig.err = grpc.Errorf(errCode, "test error")
-
- var formattedSinkName string = ConfigSinkPath("[PROJECT]", "[SINK]")
- var sink *loggingpb.LogSink = &loggingpb.LogSink{}
- var request = &loggingpb.UpdateSinkRequest{
- SinkName: formattedSinkName,
- Sink: sink,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.UpdateSink(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestConfigServiceV2DeleteSink(t *testing.T) {
- var expectedResponse *emptypb.Empty = &emptypb.Empty{}
-
- mockConfig.err = nil
- mockConfig.reqs = nil
-
- mockConfig.resps = append(mockConfig.resps[:0], expectedResponse)
-
- var formattedSinkName string = ConfigSinkPath("[PROJECT]", "[SINK]")
- var request = &loggingpb.DeleteSinkRequest{
- SinkName: formattedSinkName,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- err = c.DeleteSink(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockConfig.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
-}
-
-func TestConfigServiceV2DeleteSinkError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockConfig.err = grpc.Errorf(errCode, "test error")
-
- var formattedSinkName string = ConfigSinkPath("[PROJECT]", "[SINK]")
- var request = &loggingpb.DeleteSinkRequest{
- SinkName: formattedSinkName,
- }
-
- c, err := NewConfigClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- err = c.DeleteSink(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
-}
-func TestMetricsServiceV2ListLogMetrics(t *testing.T) {
- var nextPageToken string = ""
- var metricsElement *loggingpb.LogMetric = &loggingpb.LogMetric{}
- var metrics = []*loggingpb.LogMetric{metricsElement}
- var expectedResponse = &loggingpb.ListLogMetricsResponse{
- NextPageToken: nextPageToken,
- Metrics: metrics,
- }
-
- mockMetrics.err = nil
- mockMetrics.reqs = nil
-
- mockMetrics.resps = append(mockMetrics.resps[:0], expectedResponse)
-
- var formattedParent string = MetricsProjectPath("[PROJECT]")
- var request = &loggingpb.ListLogMetricsRequest{
- Parent: formattedParent,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListLogMetrics(context.Background(), request).Next()
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockMetrics.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- want := (interface{})(expectedResponse.Metrics[0])
- got := (interface{})(resp)
- var ok bool
-
- switch want := (want).(type) {
- case proto.Message:
- ok = proto.Equal(want, got.(proto.Message))
- default:
- ok = want == got
- }
- if !ok {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestMetricsServiceV2ListLogMetricsError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockMetrics.err = grpc.Errorf(errCode, "test error")
-
- var formattedParent string = MetricsProjectPath("[PROJECT]")
- var request = &loggingpb.ListLogMetricsRequest{
- Parent: formattedParent,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.ListLogMetrics(context.Background(), request).Next()
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestMetricsServiceV2GetLogMetric(t *testing.T) {
- var name string = "name3373707"
- var description string = "description-1724546052"
- var filter string = "filter-1274492040"
- var expectedResponse = &loggingpb.LogMetric{
- Name: name,
- Description: description,
- Filter: filter,
- }
-
- mockMetrics.err = nil
- mockMetrics.reqs = nil
-
- mockMetrics.resps = append(mockMetrics.resps[:0], expectedResponse)
-
- var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
- var request = &loggingpb.GetLogMetricRequest{
- MetricName: formattedMetricName,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.GetLogMetric(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockMetrics.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestMetricsServiceV2GetLogMetricError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockMetrics.err = grpc.Errorf(errCode, "test error")
-
- var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
- var request = &loggingpb.GetLogMetricRequest{
- MetricName: formattedMetricName,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.GetLogMetric(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestMetricsServiceV2CreateLogMetric(t *testing.T) {
- var name string = "name3373707"
- var description string = "description-1724546052"
- var filter string = "filter-1274492040"
- var expectedResponse = &loggingpb.LogMetric{
- Name: name,
- Description: description,
- Filter: filter,
- }
-
- mockMetrics.err = nil
- mockMetrics.reqs = nil
-
- mockMetrics.resps = append(mockMetrics.resps[:0], expectedResponse)
-
- var formattedParent string = MetricsProjectPath("[PROJECT]")
- var metric *loggingpb.LogMetric = &loggingpb.LogMetric{}
- var request = &loggingpb.CreateLogMetricRequest{
- Parent: formattedParent,
- Metric: metric,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.CreateLogMetric(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockMetrics.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestMetricsServiceV2CreateLogMetricError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockMetrics.err = grpc.Errorf(errCode, "test error")
-
- var formattedParent string = MetricsProjectPath("[PROJECT]")
- var metric *loggingpb.LogMetric = &loggingpb.LogMetric{}
- var request = &loggingpb.CreateLogMetricRequest{
- Parent: formattedParent,
- Metric: metric,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.CreateLogMetric(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestMetricsServiceV2UpdateLogMetric(t *testing.T) {
- var name string = "name3373707"
- var description string = "description-1724546052"
- var filter string = "filter-1274492040"
- var expectedResponse = &loggingpb.LogMetric{
- Name: name,
- Description: description,
- Filter: filter,
- }
-
- mockMetrics.err = nil
- mockMetrics.reqs = nil
-
- mockMetrics.resps = append(mockMetrics.resps[:0], expectedResponse)
-
- var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
- var metric *loggingpb.LogMetric = &loggingpb.LogMetric{}
- var request = &loggingpb.UpdateLogMetricRequest{
- MetricName: formattedMetricName,
- Metric: metric,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.UpdateLogMetric(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockMetrics.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
- if want, got := expectedResponse, resp; !proto.Equal(want, got) {
- t.Errorf("wrong response %q, want %q)", got, want)
- }
-}
-
-func TestMetricsServiceV2UpdateLogMetricError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockMetrics.err = grpc.Errorf(errCode, "test error")
-
- var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
- var metric *loggingpb.LogMetric = &loggingpb.LogMetric{}
- var request = &loggingpb.UpdateLogMetricRequest{
- MetricName: formattedMetricName,
- Metric: metric,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- resp, err := c.UpdateLogMetric(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
- _ = resp
-}
-func TestMetricsServiceV2DeleteLogMetric(t *testing.T) {
- var expectedResponse *emptypb.Empty = &emptypb.Empty{}
-
- mockMetrics.err = nil
- mockMetrics.reqs = nil
-
- mockMetrics.resps = append(mockMetrics.resps[:0], expectedResponse)
-
- var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
- var request = &loggingpb.DeleteLogMetricRequest{
- MetricName: formattedMetricName,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- err = c.DeleteLogMetric(context.Background(), request)
-
- if err != nil {
- t.Fatal(err)
- }
-
- if want, got := request, mockMetrics.reqs[0]; !proto.Equal(want, got) {
- t.Errorf("wrong request %q, want %q", got, want)
- }
-
-}
-
-func TestMetricsServiceV2DeleteLogMetricError(t *testing.T) {
- errCode := codes.PermissionDenied
- mockMetrics.err = grpc.Errorf(errCode, "test error")
-
- var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
- var request = &loggingpb.DeleteLogMetricRequest{
- MetricName: formattedMetricName,
- }
-
- c, err := NewMetricsClient(context.Background(), clientOpt)
- if err != nil {
- t.Fatal(err)
- }
-
- err = c.DeleteLogMetric(context.Background(), request)
-
- if c := grpc.Code(err); c != errCode {
- t.Errorf("got error code %q, want %q", c, errCode)
- }
-}