mirror of
https://github.com/restic/restic.git
synced 2025-08-23 14:57:37 +00:00
Vendor dependencies for GCS
This commit is contained in:
86
vendor/cloud.google.com/go/errorreporting/apiv1beta1/ReportErrorEvent_smoke_test.go
generated
vendored
Normal file
86
vendor/cloud.google.com/go/errorreporting/apiv1beta1/ReportErrorEvent_smoke_test.go
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
// 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 errorreporting
|
||||
|
||||
import (
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
)
|
||||
|
||||
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 TestReportErrorsServiceSmoke(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 := NewReportErrorsClient(ctx, option.WithTokenSource(ts))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var formattedProjectName string = ReportErrorsProjectPath(projectId)
|
||||
var message string = "[MESSAGE]"
|
||||
var service string = "[SERVICE]"
|
||||
var serviceContext = &clouderrorreportingpb.ServiceContext{
|
||||
Service: service,
|
||||
}
|
||||
var filePath string = "path/to/file.lang"
|
||||
var lineNumber int32 = 42
|
||||
var functionName string = "meaningOfLife"
|
||||
var reportLocation = &clouderrorreportingpb.SourceLocation{
|
||||
FilePath: filePath,
|
||||
LineNumber: lineNumber,
|
||||
FunctionName: functionName,
|
||||
}
|
||||
var context = &clouderrorreportingpb.ErrorContext{
|
||||
ReportLocation: reportLocation,
|
||||
}
|
||||
var event = &clouderrorreportingpb.ReportedErrorEvent{
|
||||
Message: message,
|
||||
ServiceContext: serviceContext,
|
||||
Context: context,
|
||||
}
|
||||
var request = &clouderrorreportingpb.ReportErrorEventRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
Event: event,
|
||||
}
|
||||
|
||||
if _, err := c.ReportErrorEvent(ctx, request); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
43
vendor/cloud.google.com/go/errorreporting/apiv1beta1/doc.go
generated
vendored
Normal file
43
vendor/cloud.google.com/go/errorreporting/apiv1beta1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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 errorreporting is an experimental, auto-generated package for the
|
||||
// Stackdriver Error Reporting API.
|
||||
//
|
||||
// Stackdriver Error Reporting groups and counts similar errors from cloud
|
||||
// services. The Stackdriver Error Reporting API provides a way to report new
|
||||
// errors and read access to error groups and their associated errors.
|
||||
package errorreporting // import "cloud.google.com/go/errorreporting/apiv1beta1"
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// DefaultAuthScopes reports the authentication scopes required
|
||||
// by this package.
|
||||
func DefaultAuthScopes() []string {
|
||||
return []string{
|
||||
"https://www.googleapis.com/auth/cloud-platform",
|
||||
}
|
||||
}
|
166
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_group_client.go
generated
vendored
Normal file
166
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_group_client.go
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
// 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 errorreporting
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/internal/version"
|
||||
gax "github.com/googleapis/gax-go"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/api/transport"
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
var (
|
||||
errorGroupGroupPathTemplate = gax.MustCompilePathTemplate("projects/{project}/groups/{group}")
|
||||
)
|
||||
|
||||
// ErrorGroupCallOptions contains the retry settings for each method of ErrorGroupClient.
|
||||
type ErrorGroupCallOptions struct {
|
||||
GetGroup []gax.CallOption
|
||||
UpdateGroup []gax.CallOption
|
||||
}
|
||||
|
||||
func defaultErrorGroupClientOptions() []option.ClientOption {
|
||||
return []option.ClientOption{
|
||||
option.WithEndpoint("clouderrorreporting.googleapis.com:443"),
|
||||
option.WithScopes(DefaultAuthScopes()...),
|
||||
}
|
||||
}
|
||||
|
||||
func defaultErrorGroupCallOptions() *ErrorGroupCallOptions {
|
||||
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: 60000 * time.Millisecond,
|
||||
Multiplier: 1.3,
|
||||
})
|
||||
}),
|
||||
},
|
||||
}
|
||||
return &ErrorGroupCallOptions{
|
||||
GetGroup: retry[[2]string{"default", "idempotent"}],
|
||||
UpdateGroup: retry[[2]string{"default", "idempotent"}],
|
||||
}
|
||||
}
|
||||
|
||||
// ErrorGroupClient is a client for interacting with Stackdriver Error Reporting API.
|
||||
type ErrorGroupClient struct {
|
||||
// The connection to the service.
|
||||
conn *grpc.ClientConn
|
||||
|
||||
// The gRPC API client.
|
||||
errorGroupClient clouderrorreportingpb.ErrorGroupServiceClient
|
||||
|
||||
// The call options for this service.
|
||||
CallOptions *ErrorGroupCallOptions
|
||||
|
||||
// The metadata to be sent with each request.
|
||||
xGoogHeader []string
|
||||
}
|
||||
|
||||
// NewErrorGroupClient creates a new error group service client.
|
||||
//
|
||||
// Service for retrieving and updating individual error groups.
|
||||
func NewErrorGroupClient(ctx context.Context, opts ...option.ClientOption) (*ErrorGroupClient, error) {
|
||||
conn, err := transport.DialGRPC(ctx, append(defaultErrorGroupClientOptions(), opts...)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &ErrorGroupClient{
|
||||
conn: conn,
|
||||
CallOptions: defaultErrorGroupCallOptions(),
|
||||
|
||||
errorGroupClient: clouderrorreportingpb.NewErrorGroupServiceClient(conn),
|
||||
}
|
||||
c.SetGoogleClientInfo()
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Connection returns the client's connection to the API service.
|
||||
func (c *ErrorGroupClient) 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 *ErrorGroupClient) 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 *ErrorGroupClient) 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...)}
|
||||
}
|
||||
|
||||
// ErrorGroupGroupPath returns the path for the group resource.
|
||||
func ErrorGroupGroupPath(project, group string) string {
|
||||
path, err := errorGroupGroupPathTemplate.Render(map[string]string{
|
||||
"project": project,
|
||||
"group": group,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// GetGroup get the specified group.
|
||||
func (c *ErrorGroupClient) GetGroup(ctx context.Context, req *clouderrorreportingpb.GetGroupRequest, opts ...gax.CallOption) (*clouderrorreportingpb.ErrorGroup, error) {
|
||||
ctx = insertXGoog(ctx, c.xGoogHeader)
|
||||
opts = append(c.CallOptions.GetGroup[0:len(c.CallOptions.GetGroup):len(c.CallOptions.GetGroup)], opts...)
|
||||
var resp *clouderrorreportingpb.ErrorGroup
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.errorGroupClient.GetGroup(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateGroup replace the data for the specified group.
|
||||
// Fails if the group does not exist.
|
||||
func (c *ErrorGroupClient) UpdateGroup(ctx context.Context, req *clouderrorreportingpb.UpdateGroupRequest, opts ...gax.CallOption) (*clouderrorreportingpb.ErrorGroup, error) {
|
||||
ctx = insertXGoog(ctx, c.xGoogHeader)
|
||||
opts = append(c.CallOptions.UpdateGroup[0:len(c.CallOptions.UpdateGroup):len(c.CallOptions.UpdateGroup)], opts...)
|
||||
var resp *clouderrorreportingpb.ErrorGroup
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.errorGroupClient.UpdateGroup(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
69
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_group_client_example_test.go
generated
vendored
Normal file
69
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_group_client_example_test.go
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// 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 errorreporting_test
|
||||
|
||||
import (
|
||||
"cloud.google.com/go/errorreporting/apiv1beta1"
|
||||
"golang.org/x/net/context"
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
)
|
||||
|
||||
func ExampleNewErrorGroupClient() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorGroupClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use client.
|
||||
_ = c
|
||||
}
|
||||
|
||||
func ExampleErrorGroupClient_GetGroup() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorGroupClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &clouderrorreportingpb.GetGroupRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.GetGroup(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
|
||||
func ExampleErrorGroupClient_UpdateGroup() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorGroupClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &clouderrorreportingpb.UpdateGroupRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.UpdateGroup(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
307
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_stats_client.go
generated
vendored
Normal file
307
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_stats_client.go
generated
vendored
Normal file
@@ -0,0 +1,307 @@
|
||||
// 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 errorreporting
|
||||
|
||||
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"
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
var (
|
||||
errorStatsProjectPathTemplate = gax.MustCompilePathTemplate("projects/{project}")
|
||||
)
|
||||
|
||||
// ErrorStatsCallOptions contains the retry settings for each method of ErrorStatsClient.
|
||||
type ErrorStatsCallOptions struct {
|
||||
ListGroupStats []gax.CallOption
|
||||
ListEvents []gax.CallOption
|
||||
DeleteEvents []gax.CallOption
|
||||
}
|
||||
|
||||
func defaultErrorStatsClientOptions() []option.ClientOption {
|
||||
return []option.ClientOption{
|
||||
option.WithEndpoint("clouderrorreporting.googleapis.com:443"),
|
||||
option.WithScopes(DefaultAuthScopes()...),
|
||||
}
|
||||
}
|
||||
|
||||
func defaultErrorStatsCallOptions() *ErrorStatsCallOptions {
|
||||
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: 60000 * time.Millisecond,
|
||||
Multiplier: 1.3,
|
||||
})
|
||||
}),
|
||||
},
|
||||
}
|
||||
return &ErrorStatsCallOptions{
|
||||
ListGroupStats: retry[[2]string{"default", "idempotent"}],
|
||||
ListEvents: retry[[2]string{"default", "idempotent"}],
|
||||
DeleteEvents: retry[[2]string{"default", "idempotent"}],
|
||||
}
|
||||
}
|
||||
|
||||
// ErrorStatsClient is a client for interacting with Stackdriver Error Reporting API.
|
||||
type ErrorStatsClient struct {
|
||||
// The connection to the service.
|
||||
conn *grpc.ClientConn
|
||||
|
||||
// The gRPC API client.
|
||||
errorStatsClient clouderrorreportingpb.ErrorStatsServiceClient
|
||||
|
||||
// The call options for this service.
|
||||
CallOptions *ErrorStatsCallOptions
|
||||
|
||||
// The metadata to be sent with each request.
|
||||
xGoogHeader []string
|
||||
}
|
||||
|
||||
// NewErrorStatsClient creates a new error stats service client.
|
||||
//
|
||||
// An API for retrieving and managing error statistics as well as data for
|
||||
// individual events.
|
||||
func NewErrorStatsClient(ctx context.Context, opts ...option.ClientOption) (*ErrorStatsClient, error) {
|
||||
conn, err := transport.DialGRPC(ctx, append(defaultErrorStatsClientOptions(), opts...)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &ErrorStatsClient{
|
||||
conn: conn,
|
||||
CallOptions: defaultErrorStatsCallOptions(),
|
||||
|
||||
errorStatsClient: clouderrorreportingpb.NewErrorStatsServiceClient(conn),
|
||||
}
|
||||
c.SetGoogleClientInfo()
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Connection returns the client's connection to the API service.
|
||||
func (c *ErrorStatsClient) 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 *ErrorStatsClient) 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 *ErrorStatsClient) 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...)}
|
||||
}
|
||||
|
||||
// ErrorStatsProjectPath returns the path for the project resource.
|
||||
func ErrorStatsProjectPath(project string) string {
|
||||
path, err := errorStatsProjectPathTemplate.Render(map[string]string{
|
||||
"project": project,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// ListGroupStats lists the specified groups.
|
||||
func (c *ErrorStatsClient) ListGroupStats(ctx context.Context, req *clouderrorreportingpb.ListGroupStatsRequest, opts ...gax.CallOption) *ErrorGroupStatsIterator {
|
||||
ctx = insertXGoog(ctx, c.xGoogHeader)
|
||||
opts = append(c.CallOptions.ListGroupStats[0:len(c.CallOptions.ListGroupStats):len(c.CallOptions.ListGroupStats)], opts...)
|
||||
it := &ErrorGroupStatsIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*clouderrorreportingpb.ErrorGroupStats, string, error) {
|
||||
var resp *clouderrorreportingpb.ListGroupStatsResponse
|
||||
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.errorStatsClient.ListGroupStats(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return resp.ErrorGroupStats, 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
|
||||
}
|
||||
|
||||
// ListEvents lists the specified events.
|
||||
func (c *ErrorStatsClient) ListEvents(ctx context.Context, req *clouderrorreportingpb.ListEventsRequest, opts ...gax.CallOption) *ErrorEventIterator {
|
||||
ctx = insertXGoog(ctx, c.xGoogHeader)
|
||||
opts = append(c.CallOptions.ListEvents[0:len(c.CallOptions.ListEvents):len(c.CallOptions.ListEvents)], opts...)
|
||||
it := &ErrorEventIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*clouderrorreportingpb.ErrorEvent, string, error) {
|
||||
var resp *clouderrorreportingpb.ListEventsResponse
|
||||
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.errorStatsClient.ListEvents(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return resp.ErrorEvents, 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
|
||||
}
|
||||
|
||||
// DeleteEvents deletes all error events of a given project.
|
||||
func (c *ErrorStatsClient) DeleteEvents(ctx context.Context, req *clouderrorreportingpb.DeleteEventsRequest, opts ...gax.CallOption) (*clouderrorreportingpb.DeleteEventsResponse, error) {
|
||||
ctx = insertXGoog(ctx, c.xGoogHeader)
|
||||
opts = append(c.CallOptions.DeleteEvents[0:len(c.CallOptions.DeleteEvents):len(c.CallOptions.DeleteEvents)], opts...)
|
||||
var resp *clouderrorreportingpb.DeleteEventsResponse
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.errorStatsClient.DeleteEvents(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// ErrorEventIterator manages a stream of *clouderrorreportingpb.ErrorEvent.
|
||||
type ErrorEventIterator struct {
|
||||
items []*clouderrorreportingpb.ErrorEvent
|
||||
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 []*clouderrorreportingpb.ErrorEvent, nextPageToken string, err error)
|
||||
}
|
||||
|
||||
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
|
||||
func (it *ErrorEventIterator) 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 *ErrorEventIterator) Next() (*clouderrorreportingpb.ErrorEvent, error) {
|
||||
var item *clouderrorreportingpb.ErrorEvent
|
||||
if err := it.nextFunc(); err != nil {
|
||||
return item, err
|
||||
}
|
||||
item = it.items[0]
|
||||
it.items = it.items[1:]
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (it *ErrorEventIterator) bufLen() int {
|
||||
return len(it.items)
|
||||
}
|
||||
|
||||
func (it *ErrorEventIterator) takeBuf() interface{} {
|
||||
b := it.items
|
||||
it.items = nil
|
||||
return b
|
||||
}
|
||||
|
||||
// ErrorGroupStatsIterator manages a stream of *clouderrorreportingpb.ErrorGroupStats.
|
||||
type ErrorGroupStatsIterator struct {
|
||||
items []*clouderrorreportingpb.ErrorGroupStats
|
||||
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 []*clouderrorreportingpb.ErrorGroupStats, nextPageToken string, err error)
|
||||
}
|
||||
|
||||
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
|
||||
func (it *ErrorGroupStatsIterator) 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 *ErrorGroupStatsIterator) Next() (*clouderrorreportingpb.ErrorGroupStats, error) {
|
||||
var item *clouderrorreportingpb.ErrorGroupStats
|
||||
if err := it.nextFunc(); err != nil {
|
||||
return item, err
|
||||
}
|
||||
item = it.items[0]
|
||||
it.items = it.items[1:]
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (it *ErrorGroupStatsIterator) bufLen() int {
|
||||
return len(it.items)
|
||||
}
|
||||
|
||||
func (it *ErrorGroupStatsIterator) takeBuf() interface{} {
|
||||
b := it.items
|
||||
it.items = nil
|
||||
return b
|
||||
}
|
100
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_stats_client_example_test.go
generated
vendored
Normal file
100
vendor/cloud.google.com/go/errorreporting/apiv1beta1/error_stats_client_example_test.go
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
// 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 errorreporting_test
|
||||
|
||||
import (
|
||||
"cloud.google.com/go/errorreporting/apiv1beta1"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/api/iterator"
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
)
|
||||
|
||||
func ExampleNewErrorStatsClient() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorStatsClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use client.
|
||||
_ = c
|
||||
}
|
||||
|
||||
func ExampleErrorStatsClient_ListGroupStats() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorStatsClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &clouderrorreportingpb.ListGroupStatsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListGroupStats(ctx, req)
|
||||
for {
|
||||
resp, err := it.Next()
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleErrorStatsClient_ListEvents() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorStatsClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &clouderrorreportingpb.ListEventsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListEvents(ctx, req)
|
||||
for {
|
||||
resp, err := it.Next()
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleErrorStatsClient_DeleteEvents() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewErrorStatsClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &clouderrorreportingpb.DeleteEventsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.DeleteEvents(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
587
vendor/cloud.google.com/go/errorreporting/apiv1beta1/mock_test.go
generated
vendored
Normal file
587
vendor/cloud.google.com/go/errorreporting/apiv1beta1/mock_test.go
generated
vendored
Normal file
@@ -0,0 +1,587 @@
|
||||
// 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 errorreporting
|
||||
|
||||
import (
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
)
|
||||
|
||||
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"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var _ = io.EOF
|
||||
var _ = ptypes.MarshalAny
|
||||
var _ status.Status
|
||||
|
||||
type mockErrorGroupServer struct {
|
||||
// Embed for forward compatibility.
|
||||
// Tests will keep working if more methods are added
|
||||
// in the future.
|
||||
clouderrorreportingpb.ErrorGroupServiceServer
|
||||
|
||||
reqs []proto.Message
|
||||
|
||||
// If set, all calls return this error.
|
||||
err error
|
||||
|
||||
// responses to return if err == nil
|
||||
resps []proto.Message
|
||||
}
|
||||
|
||||
func (s *mockErrorGroupServer) GetGroup(ctx context.Context, req *clouderrorreportingpb.GetGroupRequest) (*clouderrorreportingpb.ErrorGroup, 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].(*clouderrorreportingpb.ErrorGroup), nil
|
||||
}
|
||||
|
||||
func (s *mockErrorGroupServer) UpdateGroup(ctx context.Context, req *clouderrorreportingpb.UpdateGroupRequest) (*clouderrorreportingpb.ErrorGroup, 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].(*clouderrorreportingpb.ErrorGroup), nil
|
||||
}
|
||||
|
||||
type mockErrorStatsServer struct {
|
||||
// Embed for forward compatibility.
|
||||
// Tests will keep working if more methods are added
|
||||
// in the future.
|
||||
clouderrorreportingpb.ErrorStatsServiceServer
|
||||
|
||||
reqs []proto.Message
|
||||
|
||||
// If set, all calls return this error.
|
||||
err error
|
||||
|
||||
// responses to return if err == nil
|
||||
resps []proto.Message
|
||||
}
|
||||
|
||||
func (s *mockErrorStatsServer) ListGroupStats(ctx context.Context, req *clouderrorreportingpb.ListGroupStatsRequest) (*clouderrorreportingpb.ListGroupStatsResponse, 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].(*clouderrorreportingpb.ListGroupStatsResponse), nil
|
||||
}
|
||||
|
||||
func (s *mockErrorStatsServer) ListEvents(ctx context.Context, req *clouderrorreportingpb.ListEventsRequest) (*clouderrorreportingpb.ListEventsResponse, 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].(*clouderrorreportingpb.ListEventsResponse), nil
|
||||
}
|
||||
|
||||
func (s *mockErrorStatsServer) DeleteEvents(ctx context.Context, req *clouderrorreportingpb.DeleteEventsRequest) (*clouderrorreportingpb.DeleteEventsResponse, 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].(*clouderrorreportingpb.DeleteEventsResponse), nil
|
||||
}
|
||||
|
||||
type mockReportErrorsServer struct {
|
||||
// Embed for forward compatibility.
|
||||
// Tests will keep working if more methods are added
|
||||
// in the future.
|
||||
clouderrorreportingpb.ReportErrorsServiceServer
|
||||
|
||||
reqs []proto.Message
|
||||
|
||||
// If set, all calls return this error.
|
||||
err error
|
||||
|
||||
// responses to return if err == nil
|
||||
resps []proto.Message
|
||||
}
|
||||
|
||||
func (s *mockReportErrorsServer) ReportErrorEvent(ctx context.Context, req *clouderrorreportingpb.ReportErrorEventRequest) (*clouderrorreportingpb.ReportErrorEventResponse, 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].(*clouderrorreportingpb.ReportErrorEventResponse), nil
|
||||
}
|
||||
|
||||
// clientOpt is the option tests should use to connect to the test server.
|
||||
// It is initialized by TestMain.
|
||||
var clientOpt option.ClientOption
|
||||
|
||||
var (
|
||||
mockErrorGroup mockErrorGroupServer
|
||||
mockErrorStats mockErrorStatsServer
|
||||
mockReportErrors mockReportErrorsServer
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
|
||||
serv := grpc.NewServer()
|
||||
clouderrorreportingpb.RegisterErrorGroupServiceServer(serv, &mockErrorGroup)
|
||||
clouderrorreportingpb.RegisterErrorStatsServiceServer(serv, &mockErrorStats)
|
||||
clouderrorreportingpb.RegisterReportErrorsServiceServer(serv, &mockReportErrors)
|
||||
|
||||
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 TestErrorGroupServiceGetGroup(t *testing.T) {
|
||||
var name string = "name3373707"
|
||||
var groupId string = "groupId506361563"
|
||||
var expectedResponse = &clouderrorreportingpb.ErrorGroup{
|
||||
Name: name,
|
||||
GroupId: groupId,
|
||||
}
|
||||
|
||||
mockErrorGroup.err = nil
|
||||
mockErrorGroup.reqs = nil
|
||||
|
||||
mockErrorGroup.resps = append(mockErrorGroup.resps[:0], expectedResponse)
|
||||
|
||||
var formattedGroupName string = ErrorGroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var request = &clouderrorreportingpb.GetGroupRequest{
|
||||
GroupName: formattedGroupName,
|
||||
}
|
||||
|
||||
c, err := NewErrorGroupClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.GetGroup(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockErrorGroup.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 TestErrorGroupServiceGetGroupError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockErrorGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedGroupName string = ErrorGroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var request = &clouderrorreportingpb.GetGroupRequest{
|
||||
GroupName: formattedGroupName,
|
||||
}
|
||||
|
||||
c, err := NewErrorGroupClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.GetGroup(context.Background(), request)
|
||||
|
||||
if st, ok := gstatus.FromError(err); !ok {
|
||||
t.Errorf("got error %v, expected grpc error", err)
|
||||
} else if c := st.Code(); c != errCode {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
_ = resp
|
||||
}
|
||||
func TestErrorGroupServiceUpdateGroup(t *testing.T) {
|
||||
var name string = "name3373707"
|
||||
var groupId string = "groupId506361563"
|
||||
var expectedResponse = &clouderrorreportingpb.ErrorGroup{
|
||||
Name: name,
|
||||
GroupId: groupId,
|
||||
}
|
||||
|
||||
mockErrorGroup.err = nil
|
||||
mockErrorGroup.reqs = nil
|
||||
|
||||
mockErrorGroup.resps = append(mockErrorGroup.resps[:0], expectedResponse)
|
||||
|
||||
var group *clouderrorreportingpb.ErrorGroup = &clouderrorreportingpb.ErrorGroup{}
|
||||
var request = &clouderrorreportingpb.UpdateGroupRequest{
|
||||
Group: group,
|
||||
}
|
||||
|
||||
c, err := NewErrorGroupClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.UpdateGroup(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockErrorGroup.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 TestErrorGroupServiceUpdateGroupError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockErrorGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var group *clouderrorreportingpb.ErrorGroup = &clouderrorreportingpb.ErrorGroup{}
|
||||
var request = &clouderrorreportingpb.UpdateGroupRequest{
|
||||
Group: group,
|
||||
}
|
||||
|
||||
c, err := NewErrorGroupClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.UpdateGroup(context.Background(), request)
|
||||
|
||||
if st, ok := gstatus.FromError(err); !ok {
|
||||
t.Errorf("got error %v, expected grpc error", err)
|
||||
} else if c := st.Code(); c != errCode {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
_ = resp
|
||||
}
|
||||
func TestErrorStatsServiceListGroupStats(t *testing.T) {
|
||||
var nextPageToken string = ""
|
||||
var errorGroupStatsElement *clouderrorreportingpb.ErrorGroupStats = &clouderrorreportingpb.ErrorGroupStats{}
|
||||
var errorGroupStats = []*clouderrorreportingpb.ErrorGroupStats{errorGroupStatsElement}
|
||||
var expectedResponse = &clouderrorreportingpb.ListGroupStatsResponse{
|
||||
NextPageToken: nextPageToken,
|
||||
ErrorGroupStats: errorGroupStats,
|
||||
}
|
||||
|
||||
mockErrorStats.err = nil
|
||||
mockErrorStats.reqs = nil
|
||||
|
||||
mockErrorStats.resps = append(mockErrorStats.resps[:0], expectedResponse)
|
||||
|
||||
var formattedProjectName string = ErrorStatsProjectPath("[PROJECT]")
|
||||
var timeRange *clouderrorreportingpb.QueryTimeRange = &clouderrorreportingpb.QueryTimeRange{}
|
||||
var request = &clouderrorreportingpb.ListGroupStatsRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
TimeRange: timeRange,
|
||||
}
|
||||
|
||||
c, err := NewErrorStatsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListGroupStats(context.Background(), request).Next()
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockErrorStats.reqs[0]; !proto.Equal(want, got) {
|
||||
t.Errorf("wrong request %q, want %q", got, want)
|
||||
}
|
||||
|
||||
want := (interface{})(expectedResponse.ErrorGroupStats[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 TestErrorStatsServiceListGroupStatsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockErrorStats.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedProjectName string = ErrorStatsProjectPath("[PROJECT]")
|
||||
var timeRange *clouderrorreportingpb.QueryTimeRange = &clouderrorreportingpb.QueryTimeRange{}
|
||||
var request = &clouderrorreportingpb.ListGroupStatsRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
TimeRange: timeRange,
|
||||
}
|
||||
|
||||
c, err := NewErrorStatsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListGroupStats(context.Background(), request).Next()
|
||||
|
||||
if st, ok := gstatus.FromError(err); !ok {
|
||||
t.Errorf("got error %v, expected grpc error", err)
|
||||
} else if c := st.Code(); c != errCode {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
_ = resp
|
||||
}
|
||||
func TestErrorStatsServiceListEvents(t *testing.T) {
|
||||
var nextPageToken string = ""
|
||||
var errorEventsElement *clouderrorreportingpb.ErrorEvent = &clouderrorreportingpb.ErrorEvent{}
|
||||
var errorEvents = []*clouderrorreportingpb.ErrorEvent{errorEventsElement}
|
||||
var expectedResponse = &clouderrorreportingpb.ListEventsResponse{
|
||||
NextPageToken: nextPageToken,
|
||||
ErrorEvents: errorEvents,
|
||||
}
|
||||
|
||||
mockErrorStats.err = nil
|
||||
mockErrorStats.reqs = nil
|
||||
|
||||
mockErrorStats.resps = append(mockErrorStats.resps[:0], expectedResponse)
|
||||
|
||||
var formattedProjectName string = ErrorStatsProjectPath("[PROJECT]")
|
||||
var groupId string = "groupId506361563"
|
||||
var request = &clouderrorreportingpb.ListEventsRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
GroupId: groupId,
|
||||
}
|
||||
|
||||
c, err := NewErrorStatsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListEvents(context.Background(), request).Next()
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockErrorStats.reqs[0]; !proto.Equal(want, got) {
|
||||
t.Errorf("wrong request %q, want %q", got, want)
|
||||
}
|
||||
|
||||
want := (interface{})(expectedResponse.ErrorEvents[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 TestErrorStatsServiceListEventsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockErrorStats.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedProjectName string = ErrorStatsProjectPath("[PROJECT]")
|
||||
var groupId string = "groupId506361563"
|
||||
var request = &clouderrorreportingpb.ListEventsRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
GroupId: groupId,
|
||||
}
|
||||
|
||||
c, err := NewErrorStatsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListEvents(context.Background(), request).Next()
|
||||
|
||||
if st, ok := gstatus.FromError(err); !ok {
|
||||
t.Errorf("got error %v, expected grpc error", err)
|
||||
} else if c := st.Code(); c != errCode {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
_ = resp
|
||||
}
|
||||
func TestErrorStatsServiceDeleteEvents(t *testing.T) {
|
||||
var expectedResponse *clouderrorreportingpb.DeleteEventsResponse = &clouderrorreportingpb.DeleteEventsResponse{}
|
||||
|
||||
mockErrorStats.err = nil
|
||||
mockErrorStats.reqs = nil
|
||||
|
||||
mockErrorStats.resps = append(mockErrorStats.resps[:0], expectedResponse)
|
||||
|
||||
var formattedProjectName string = ErrorStatsProjectPath("[PROJECT]")
|
||||
var request = &clouderrorreportingpb.DeleteEventsRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
}
|
||||
|
||||
c, err := NewErrorStatsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.DeleteEvents(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockErrorStats.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 TestErrorStatsServiceDeleteEventsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockErrorStats.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedProjectName string = ErrorStatsProjectPath("[PROJECT]")
|
||||
var request = &clouderrorreportingpb.DeleteEventsRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
}
|
||||
|
||||
c, err := NewErrorStatsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.DeleteEvents(context.Background(), request)
|
||||
|
||||
if st, ok := gstatus.FromError(err); !ok {
|
||||
t.Errorf("got error %v, expected grpc error", err)
|
||||
} else if c := st.Code(); c != errCode {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
_ = resp
|
||||
}
|
||||
func TestReportErrorsServiceReportErrorEvent(t *testing.T) {
|
||||
var expectedResponse *clouderrorreportingpb.ReportErrorEventResponse = &clouderrorreportingpb.ReportErrorEventResponse{}
|
||||
|
||||
mockReportErrors.err = nil
|
||||
mockReportErrors.reqs = nil
|
||||
|
||||
mockReportErrors.resps = append(mockReportErrors.resps[:0], expectedResponse)
|
||||
|
||||
var formattedProjectName string = ReportErrorsProjectPath("[PROJECT]")
|
||||
var event *clouderrorreportingpb.ReportedErrorEvent = &clouderrorreportingpb.ReportedErrorEvent{}
|
||||
var request = &clouderrorreportingpb.ReportErrorEventRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
Event: event,
|
||||
}
|
||||
|
||||
c, err := NewReportErrorsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ReportErrorEvent(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockReportErrors.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 TestReportErrorsServiceReportErrorEventError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockReportErrors.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedProjectName string = ReportErrorsProjectPath("[PROJECT]")
|
||||
var event *clouderrorreportingpb.ReportedErrorEvent = &clouderrorreportingpb.ReportedErrorEvent{}
|
||||
var request = &clouderrorreportingpb.ReportErrorEventRequest{
|
||||
ProjectName: formattedProjectName,
|
||||
Event: event,
|
||||
}
|
||||
|
||||
c, err := NewReportErrorsClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ReportErrorEvent(context.Background(), request)
|
||||
|
||||
if st, ok := gstatus.FromError(err); !ok {
|
||||
t.Errorf("got error %v, expected grpc error", err)
|
||||
} else if c := st.Code(); c != errCode {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
_ = resp
|
||||
}
|
137
vendor/cloud.google.com/go/errorreporting/apiv1beta1/report_errors_client.go
generated
vendored
Normal file
137
vendor/cloud.google.com/go/errorreporting/apiv1beta1/report_errors_client.go
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
// 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 errorreporting
|
||||
|
||||
import (
|
||||
"cloud.google.com/go/internal/version"
|
||||
gax "github.com/googleapis/gax-go"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/api/transport"
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
var (
|
||||
reportErrorsProjectPathTemplate = gax.MustCompilePathTemplate("projects/{project}")
|
||||
)
|
||||
|
||||
// ReportErrorsCallOptions contains the retry settings for each method of ReportErrorsClient.
|
||||
type ReportErrorsCallOptions struct {
|
||||
ReportErrorEvent []gax.CallOption
|
||||
}
|
||||
|
||||
func defaultReportErrorsClientOptions() []option.ClientOption {
|
||||
return []option.ClientOption{
|
||||
option.WithEndpoint("clouderrorreporting.googleapis.com:443"),
|
||||
option.WithScopes(DefaultAuthScopes()...),
|
||||
}
|
||||
}
|
||||
|
||||
func defaultReportErrorsCallOptions() *ReportErrorsCallOptions {
|
||||
retry := map[[2]string][]gax.CallOption{}
|
||||
return &ReportErrorsCallOptions{
|
||||
ReportErrorEvent: retry[[2]string{"default", "non_idempotent"}],
|
||||
}
|
||||
}
|
||||
|
||||
// ReportErrorsClient is a client for interacting with Stackdriver Error Reporting API.
|
||||
type ReportErrorsClient struct {
|
||||
// The connection to the service.
|
||||
conn *grpc.ClientConn
|
||||
|
||||
// The gRPC API client.
|
||||
reportErrorsClient clouderrorreportingpb.ReportErrorsServiceClient
|
||||
|
||||
// The call options for this service.
|
||||
CallOptions *ReportErrorsCallOptions
|
||||
|
||||
// The metadata to be sent with each request.
|
||||
xGoogHeader []string
|
||||
}
|
||||
|
||||
// NewReportErrorsClient creates a new report errors service client.
|
||||
//
|
||||
// An API for reporting error events.
|
||||
func NewReportErrorsClient(ctx context.Context, opts ...option.ClientOption) (*ReportErrorsClient, error) {
|
||||
conn, err := transport.DialGRPC(ctx, append(defaultReportErrorsClientOptions(), opts...)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &ReportErrorsClient{
|
||||
conn: conn,
|
||||
CallOptions: defaultReportErrorsCallOptions(),
|
||||
|
||||
reportErrorsClient: clouderrorreportingpb.NewReportErrorsServiceClient(conn),
|
||||
}
|
||||
c.SetGoogleClientInfo()
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Connection returns the client's connection to the API service.
|
||||
func (c *ReportErrorsClient) 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 *ReportErrorsClient) 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 *ReportErrorsClient) 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...)}
|
||||
}
|
||||
|
||||
// ReportErrorsProjectPath returns the path for the project resource.
|
||||
func ReportErrorsProjectPath(project string) string {
|
||||
path, err := reportErrorsProjectPathTemplate.Render(map[string]string{
|
||||
"project": project,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// ReportErrorEvent report an individual error event.
|
||||
//
|
||||
// This endpoint accepts <strong>either</strong> an OAuth token,
|
||||
// <strong>or</strong> an
|
||||
// <a href="https://support.google.com/cloud/answer/6158862">API key</a>
|
||||
// for authentication. To use an API key, append it to the URL as the value of
|
||||
// a `key` parameter. For example:
|
||||
// <pre>POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456</pre>
|
||||
func (c *ReportErrorsClient) ReportErrorEvent(ctx context.Context, req *clouderrorreportingpb.ReportErrorEventRequest, opts ...gax.CallOption) (*clouderrorreportingpb.ReportErrorEventResponse, error) {
|
||||
ctx = insertXGoog(ctx, c.xGoogHeader)
|
||||
opts = append(c.CallOptions.ReportErrorEvent[0:len(c.CallOptions.ReportErrorEvent):len(c.CallOptions.ReportErrorEvent)], opts...)
|
||||
var resp *clouderrorreportingpb.ReportErrorEventResponse
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.reportErrorsClient.ReportErrorEvent(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
51
vendor/cloud.google.com/go/errorreporting/apiv1beta1/report_errors_client_example_test.go
generated
vendored
Normal file
51
vendor/cloud.google.com/go/errorreporting/apiv1beta1/report_errors_client_example_test.go
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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 errorreporting_test
|
||||
|
||||
import (
|
||||
"cloud.google.com/go/errorreporting/apiv1beta1"
|
||||
"golang.org/x/net/context"
|
||||
clouderrorreportingpb "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1"
|
||||
)
|
||||
|
||||
func ExampleNewReportErrorsClient() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewReportErrorsClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use client.
|
||||
_ = c
|
||||
}
|
||||
|
||||
func ExampleReportErrorsClient_ReportErrorEvent() {
|
||||
ctx := context.Background()
|
||||
c, err := errorreporting.NewReportErrorsClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &clouderrorreportingpb.ReportErrorEventRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.ReportErrorEvent(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
Reference in New Issue
Block a user